Files
securityonion/salt/_modules/needs_restarting.py
Mike Reeves fee4c20912 add OS logic
2023-07-03 15:12:49 -04:00

33 lines
689 B
Python

from os import path
import subprocess
def check():
os = __grains__['os']
retval = 'False'
if os == 'Ubuntu':
if path.exists('/var/run/reboot-required'):
retval = 'True'
elif os == 'CentOS Stream':
cmd = 'needs-restarting -r > /dev/null 2>&1'
try:
needs_restarting = subprocess.check_call(cmd, shell=True)
except subprocess.CalledProcessError:
retval = 'True'
elif os == 'Rocky':
cmd = 'needs-restarting -r > /dev/null 2>&1'
try:
needs_restarting = subprocess.check_call(cmd, shell=True)
except subprocess.CalledProcessError:
retval = 'True'
else:
retval = 'Unsupported OS: %s' % os
return retval