Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/mount_efs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@
ROCKY8_RELEASE_NAME = "Rocky Linux release 8"
ALMALINUX8_RELEASE_NAME = "AlmaLinux release 8"
AMAZON_LINUX_2022_RELEASE_NAME = "Amazon Linux release 2022"
ALPINE_RELEASE_NAME = "Alpine Linux"

SKIP_NO_LIBWRAP_RELEASES = [
RHEL8_RELEASE_NAME,
Expand All @@ -280,6 +281,7 @@
ROCKY8_RELEASE_NAME,
AMAZON_LINUX_2022_RELEASE_NAME,
ALMALINUX8_RELEASE_NAME,
ALPINE_RELEASE_NAME,
]

# Multiplier for max read ahead buffer size
Expand Down Expand Up @@ -1310,6 +1312,11 @@ def get_init_system(comm_file="/proc/1/comm"):
init_system = f.read().strip()
except IOError:
logging.warning("Unable to read %s", comm_file)

# OpenRC init system manages services a little differently
if init_system == "init" and os.path.isfile("/sbin/openrc"):
init_system = "openrc-init"
logging.debug("Detected OpenRC init system")
else:
init_system = "launchd"

Expand Down Expand Up @@ -1369,6 +1376,24 @@ def start_watchdog(init_system):
elif "start" in str(status):
logging.debug("%s is already running", WATCHDOG_SERVICE)

elif init_system == "openrc-init":
proc = subprocess.Popen(
["/sbin/service", WATCHDOG_SERVICE, "status"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=True,
)
status, _ = proc.communicate()
if "stopped" in str(status):
subprocess.Popen(
["/sbin/service", WATCHDOG_SERVICE, "start"],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
close_fds=True,
)
elif "started" in str(status):
logging.debug("%s is already running", WATCHDOG_SERVICE)

elif init_system == "systemd":
rc = subprocess.call(
["systemctl", "is-active", "--quiet", WATCHDOG_SERVICE], close_fds=True
Expand Down