attempt to add systemd-support for gentoo
This commit is contained in:
parent
cd33f98b8b
commit
5e5b77ed5e
6
bin/sau
6
bin/sau
@ -46,6 +46,12 @@ def init():
|
|||||||
|
|
||||||
def fork_and_reboot():
|
def fork_and_reboot():
|
||||||
log = logging.getLogger(sau.LOGNAME)
|
log = logging.getLogger(sau.LOGNAME)
|
||||||
|
if os.path.exist('/proc/1/comm'):
|
||||||
|
with open('/proc/1/comm', 'r') as f:
|
||||||
|
if f.readline() == 'systemd':
|
||||||
|
os.execl('/usr/bin/systemctl', 'reboot')
|
||||||
|
log.error("Failed to execl?")
|
||||||
|
sys.exit(1)
|
||||||
try:
|
try:
|
||||||
pid = os.fork()
|
pid = os.fork()
|
||||||
if pid != 0:
|
if pid != 0:
|
||||||
|
@ -7,6 +7,7 @@ import sau.helpers
|
|||||||
|
|
||||||
EIX_SYNC_PATH='/usr/bin/eix-sync'
|
EIX_SYNC_PATH='/usr/bin/eix-sync'
|
||||||
RC_SERVICE_PATH='/sbin/rc-service'
|
RC_SERVICE_PATH='/sbin/rc-service'
|
||||||
|
SYSTEMCTL='/usr/bin/systemctl'
|
||||||
EMERGE_PATH='/usr/bin/emerge'
|
EMERGE_PATH='/usr/bin/emerge'
|
||||||
EQUERY_PATH='/usr/bin/equery'
|
EQUERY_PATH='/usr/bin/equery'
|
||||||
EMAINT_PATH='/usr/sbin/emaint'
|
EMAINT_PATH='/usr/sbin/emaint'
|
||||||
@ -20,7 +21,11 @@ slot_re = re.compile('^(\(~\))?([^\(]+)(\([^\)]+\))$')
|
|||||||
def identify_service_from_bin(exe):
|
def identify_service_from_bin(exe):
|
||||||
log = logging.getLogger(sau.LOGNAME)
|
log = logging.getLogger(sau.LOGNAME)
|
||||||
|
|
||||||
init_script_re = re.compile(r'/etc/init\.d/(.*)')
|
with open('/proc/1/comm', 'r') as f:
|
||||||
|
if f.readline() == 'systemd':
|
||||||
|
init_script_re = re.compile(r'[^/]*(.*)\.service$')
|
||||||
|
else:
|
||||||
|
init_script_re = re.compile(r'/etc/init\.d/(.*)')
|
||||||
|
|
||||||
cmd = [ EQUERY_PATH, '-Cq', 'b', exe ]
|
cmd = [ EQUERY_PATH, '-Cq', 'b', exe ]
|
||||||
ret, out, err = sau.helpers.exec_cmd(cmd)
|
ret, out, err = sau.helpers.exec_cmd(cmd)
|
||||||
@ -55,7 +60,11 @@ def identify_service_from_bin(exe):
|
|||||||
|
|
||||||
def restart_service(service):
|
def restart_service(service):
|
||||||
log = logging.getLogger(sau.LOGNAME)
|
log = logging.getLogger(sau.LOGNAME)
|
||||||
cmd = [ RC_SERVICE_PATH, service, 'restart' ]
|
with open('/proc/1/comm', 'r') as f:
|
||||||
|
if f.readline() == 'systemd':
|
||||||
|
cmd = [ SYSTEMCTL, 'restart', service ]
|
||||||
|
else:
|
||||||
|
cmd = [ RC_SERVICE_PATH, service, 'restart' ]
|
||||||
ret, out, err = sau.helpers.exec_cmd(cmd)
|
ret, out, err = sau.helpers.exec_cmd(cmd)
|
||||||
|
|
||||||
if ret != 0:
|
if ret != 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user