Skip to content

Commit 9783a7c

Browse files
committed
Support Alpine Linux & OpenRC
Resolves #50
1 parent a63e217 commit 9783a7c

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

src/mount_efs/__init__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@
268268
ROCKY8_RELEASE_NAME = "Rocky Linux release 8"
269269
ALMALINUX8_RELEASE_NAME = "AlmaLinux release 8"
270270
AMAZON_LINUX_2022_RELEASE_NAME = "Amazon Linux release 2022"
271+
ALPINE_RELEASE_NAME = "Alpine Linux"
271272

272273
SKIP_NO_LIBWRAP_RELEASES = [
273274
RHEL8_RELEASE_NAME,
@@ -280,6 +281,7 @@
280281
ROCKY8_RELEASE_NAME,
281282
AMAZON_LINUX_2022_RELEASE_NAME,
282283
ALMALINUX8_RELEASE_NAME,
284+
ALPINE_RELEASE_NAME,
283285
]
284286

285287
# Multiplier for max read ahead buffer size
@@ -1310,6 +1312,11 @@ def get_init_system(comm_file="/proc/1/comm"):
13101312
init_system = f.read().strip()
13111313
except IOError:
13121314
logging.warning("Unable to read %s", comm_file)
1315+
1316+
# OpenRC init system manages services a little differently
1317+
if init_system == "init" and os.path.isfile("/sbin/openrc"):
1318+
init_system = "openrc-init"
1319+
logging.debug("Detected OpenRC init system")
13131320
else:
13141321
init_system = "launchd"
13151322

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

1379+
elif init_system == "openrc-init":
1380+
proc = subprocess.Popen(
1381+
["/sbin/service", WATCHDOG_SERVICE, "status"],
1382+
stdout=subprocess.PIPE,
1383+
stderr=subprocess.PIPE,
1384+
close_fds=True,
1385+
)
1386+
status, _ = proc.communicate()
1387+
if "stopped" in str(status):
1388+
subprocess.Popen(
1389+
["/sbin/service", WATCHDOG_SERVICE, "start"],
1390+
stdout=subprocess.DEVNULL,
1391+
stderr=subprocess.DEVNULL,
1392+
close_fds=True,
1393+
)
1394+
elif "started" in str(status):
1395+
logging.debug("%s is already running", WATCHDOG_SERVICE)
1396+
13721397
elif init_system == "systemd":
13731398
rc = subprocess.call(
13741399
["systemctl", "is-active", "--quiet", WATCHDOG_SERVICE], close_fds=True

0 commit comments

Comments
 (0)