fix systemd test
This commit is contained in:
parent
5e5b77ed5e
commit
6305fd053b
2
bin/sau
2
bin/sau
@ -48,7 +48,7 @@ def fork_and_reboot():
|
|||||||
log = logging.getLogger(sau.LOGNAME)
|
log = logging.getLogger(sau.LOGNAME)
|
||||||
if os.path.exist('/proc/1/comm'):
|
if os.path.exist('/proc/1/comm'):
|
||||||
with open('/proc/1/comm', 'r') as f:
|
with open('/proc/1/comm', 'r') as f:
|
||||||
if f.readline() == 'systemd':
|
if f.readline().strip() == 'systemd':
|
||||||
os.execl('/usr/bin/systemctl', 'reboot')
|
os.execl('/usr/bin/systemctl', 'reboot')
|
||||||
log.error("Failed to execl?")
|
log.error("Failed to execl?")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -22,7 +22,7 @@ def identify_service_from_bin(exe):
|
|||||||
log = logging.getLogger(sau.LOGNAME)
|
log = logging.getLogger(sau.LOGNAME)
|
||||||
|
|
||||||
with open('/proc/1/comm', 'r') as f:
|
with open('/proc/1/comm', 'r') as f:
|
||||||
if f.readline() == 'systemd':
|
if f.readline().strip() == 'systemd':
|
||||||
init_script_re = re.compile(r'[^/]*(.*)\.service$')
|
init_script_re = re.compile(r'[^/]*(.*)\.service$')
|
||||||
else:
|
else:
|
||||||
init_script_re = re.compile(r'/etc/init\.d/(.*)')
|
init_script_re = re.compile(r'/etc/init\.d/(.*)')
|
||||||
@ -61,7 +61,7 @@ def identify_service_from_bin(exe):
|
|||||||
def restart_service(service):
|
def restart_service(service):
|
||||||
log = logging.getLogger(sau.LOGNAME)
|
log = logging.getLogger(sau.LOGNAME)
|
||||||
with open('/proc/1/comm', 'r') as f:
|
with open('/proc/1/comm', 'r') as f:
|
||||||
if f.readline() == 'systemd':
|
if f.readline().strip() == 'systemd':
|
||||||
cmd = [ SYSTEMCTL, 'restart', service ]
|
cmd = [ SYSTEMCTL, 'restart', service ]
|
||||||
else:
|
else:
|
||||||
cmd = [ RC_SERVICE_PATH, service, 'restart' ]
|
cmd = [ RC_SERVICE_PATH, service, 'restart' ]
|
||||||
|
Loading…
Reference in New Issue
Block a user