Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
8a2c9c5e
Commit
8a2c9c5e
authored
Aug 25, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue_7757_upstart_centos' into devel
parents
500d8f1e
d6a8d467
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
2 deletions
+29
-2
library/system/service
+29
-2
No files found.
library/system/service
View file @
8a2c9c5e
...
@@ -105,6 +105,8 @@ import select
...
@@ -105,6 +105,8 @@ import select
import
time
import
time
import
string
import
string
from
distutils.version
import
LooseVersion
class
Service
(
object
):
class
Service
(
object
):
"""
"""
This is the generic Service manipulation class that is subclassed
This is the generic Service manipulation class that is subclassed
...
@@ -449,6 +451,26 @@ class LinuxService(Service):
...
@@ -449,6 +451,26 @@ class LinuxService(Service):
elif
check_systemd
(
self
.
name
):
elif
check_systemd
(
self
.
name
):
# service is managed by systemd
# service is managed by systemd
self
.
enable_cmd
=
location
[
'systemctl'
]
self
.
enable_cmd
=
location
[
'systemctl'
]
elif
location
[
'initctl'
]
and
os
.
path
.
exists
(
"/etc/init/
%
s.conf"
%
self
.
name
):
# service is managed by upstart
self
.
enable_cmd
=
location
[
'initctl'
]
# if this service is managed via upstart, get the current upstart version
if
self
.
enable_cmd
==
location
[
'initctl'
]:
# default the upstart version to something we can compare against
self
.
upstart_version
=
LooseVersion
(
'0.0.0'
)
try
:
# set the upstart version based on the output of 'initctl version'
version_re
=
re
.
compile
(
r'\(upstart (.*)\)'
)
rc
,
stdout
,
stderr
=
self
.
module
.
run_command
(
'initctl version'
)
if
rc
==
0
:
res
=
version_re
.
search
(
stdout
)
if
res
:
self
.
upstart_version
=
LooseVersion
(
res
.
groups
()[
0
])
except
:
# we'll use the default of 0.0.0 since we couldn't
# detect the current upstart version above
pass
# Locate a tool for runtime service management (start, stop etc.)
# Locate a tool for runtime service management (start, stop etc.)
if
location
.
get
(
'service'
,
None
)
and
os
.
path
.
exists
(
"/etc/init.d/
%
s"
%
self
.
name
):
if
location
.
get
(
'service'
,
None
)
and
os
.
path
.
exists
(
"/etc/init.d/
%
s"
%
self
.
name
):
...
@@ -576,7 +598,12 @@ class LinuxService(Service):
...
@@ -576,7 +598,12 @@ class LinuxService(Service):
override_file
.
close
()
override_file
.
close
()
initpath
=
'/etc/init'
initpath
=
'/etc/init'
if
self
.
upstart_version
>=
LooseVersion
(
'0.6.7'
):
manreg
=
re
.
compile
(
'^manual
\
s*$'
,
re
.
M
|
re
.
I
)
manreg
=
re
.
compile
(
'^manual
\
s*$'
,
re
.
M
|
re
.
I
)
config_line
=
'manual
\n
'
else
:
manreg
=
re
.
compile
(
'^start on manual
\
s*$'
,
re
.
M
|
re
.
I
)
config_line
=
'start on manual
\n
'
conf_file_name
=
"
%
s/
%
s.conf"
%
(
initpath
,
self
.
name
)
conf_file_name
=
"
%
s/
%
s.conf"
%
(
initpath
,
self
.
name
)
override_file_name
=
"
%
s/
%
s.override"
%
(
initpath
,
self
.
name
)
override_file_name
=
"
%
s/
%
s.override"
%
(
initpath
,
self
.
name
)
...
@@ -591,12 +618,12 @@ class LinuxService(Service):
...
@@ -591,12 +618,12 @@ class LinuxService(Service):
write_to_override_file
(
override_file_name
,
manreg
.
sub
(
''
,
override_file_contents
))
write_to_override_file
(
override_file_name
,
manreg
.
sub
(
''
,
override_file_contents
))
# Add manual stanza if not present and service disabled
# Add manual stanza if not present and service disabled
elif
not
(
self
.
enable
)
and
not
(
manreg
.
search
(
override_file_contents
)):
elif
not
(
self
.
enable
)
and
not
(
manreg
.
search
(
override_file_contents
)):
write_to_override_file
(
override_file_name
,
override_file_contents
+
'
\n
manual
\n
'
)
write_to_override_file
(
override_file_name
,
override_file_contents
+
'
\n
'
+
config_line
)
else
:
else
:
return
return
# Add file with manual stanza if service disabled
# Add file with manual stanza if service disabled
elif
not
(
self
.
enable
):
elif
not
(
self
.
enable
):
write_to_override_file
(
override_file_name
,
'manual
\n
'
)
write_to_override_file
(
override_file_name
,
config_line
)
else
:
else
:
return
return
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment