aports/main/openresolv/detect_init-remove-irrelevant.patch

95 lines
2.9 KiB
Diff

From: Jakub Jirutka <jakub@jirutka.cz>
Date: Sat, 25 Jun 2022 19:51:00 +0200
Subject: Remove support for init systems we don't have, add support for s6
Don't waste resources looking for init systems we don't have in Alpine.
diff --git a/resolvconf.in b/resolvconf.in
index d1cdc71..42023ff 100644
--- a/resolvconf.in
+++ b/resolvconf.in
@@ -299,80 +299,25 @@ detect_init()
[ -n "$RESTARTCMD" ] && return 0
# Detect the running init system.
- # As systemd and OpenRC can be installed on top of legacy init
- # systems we try to detect them first.
status="@STATUSARG@"
: ${status:=status}
- if [ -x /bin/systemctl ] && [ -S /run/systemd/private ]; then
- RESTARTCMD='
- if /bin/systemctl --quiet is-active $1.service
- then
- /bin/systemctl restart $1.service
- fi'
- elif [ -x /usr/bin/systemctl ] && [ -S /run/systemd/private ]; then
- RESTARTCMD='
- if /usr/bin/systemctl --quiet is-active $1.service
- then
- /usr/bin/systemctl restart $1.service
- fi'
- elif [ -x /sbin/rc-service ] &&
+ if [ -x /sbin/rc-service ] &&
{ [ -s /libexec/rc/init.d/softlevel ] ||
[ -s /run/openrc/softlevel ]; }
then
RESTARTCMD='/sbin/rc-service -i $1 -- -Ds restart'
- elif [ -x /usr/sbin/invoke-rc.d ]; then
- RCDIR=/etc/init.d
- RESTARTCMD='
- if /usr/sbin/invoke-rc.d --quiet $1 status >/dev/null 2>&1
- then
- /usr/sbin/invoke-rc.d $1 restart
- fi'
elif [ -x /usr/bin/s6-rc ] && [ -x /usr/bin/s6-svc ]; then
RESTARTCMD='
if s6-rc -a list 2>/dev/null | grep -qFx $1-srv
then
s6-svc -r /run/service/$1-srv
fi'
- elif [ -x /sbin/service ]; then
- # Old RedHat
- RCDIR=/etc/init.d
- RESTARTCMD='
- if /sbin/service $1; then
- /sbin/service $1 restart
- fi'
- elif [ -x /usr/sbin/service ]; then
- # Could be FreeBSD
- RESTARTCMD="
- if /usr/sbin/service \$1 $status >/dev/null 2>&1
- then
- /usr/sbin/service \$1 restart
- fi"
elif [ -x /bin/sv ]; then
RESTARTCMD='/bin/sv status $1 >/dev/null 2>&1 &&
/bin/sv try-restart $1'
- elif [ -x /usr/bin/sv ]; then
- RESTARTCMD='/usr/bin/sv status $1 >/dev/null 2>&1 &&
- /usr/bin/sv try-restart $1'
- elif [ -e /etc/arch-release ] && [ -d /etc/rc.d ]; then
- RCDIR=/etc/rc.d
- RESTARTCMD='
- if [ -e /var/run/daemons/$1 ]
- then
- /etc/rc.d/$1 restart
- fi'
- elif [ -e /etc/slackware-version ] && [ -d /etc/rc.d ]; then
- RESTARTCMD='
- if /etc/rc.d/rc.$1 status >/dev/null 2>&1
- then
- /etc/rc.d/rc.$1 restart
- fi'
- elif [ -e /etc/rc.d/rc.subr ] && [ -d /etc/rc.d ]; then
- # OpenBSD
- RESTARTCMD='
- if /etc/rc.d/$1 check >/dev/null 2>&1
- then
- /etc/rc.d/$1 restart
- fi'
+ # TODO: Test if this works correctly.
+ elif [ -x /bin/s6-svc ] && [ -e /run/s6-rc ]; then
+ RESTARTCMD='/bin/s6-svc -r /run/service/$1'
elif [ -d /etc/dinit.d ] && command -v dinitctl >/dev/null 2>&1; then
RESTARTCMD='dinitctl --quiet restart --ignore-unstarted $1'
else