Skip to content

Commit ad0f5bc

Browse files
committed
implement legacy actions (bnc#861124)
1 parent 7f76f64 commit ad0f5bc

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

files/usr/sbin/service

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ fi
2121
#
2222
RCDIR="/etc/init.d"
2323

24+
# legacy actions
25+
actiondir="/usr/lib/initscripts/legacy-actions"
26+
2427
#
2528
# Clean environment
2629
#
@@ -53,11 +56,19 @@ is_target()
5356
test "$state" = "LoadState=loaded"
5457
}
5558

59+
60+
is_systemd_action()
61+
{
62+
case "$1" in
63+
start|stop|reload|restart|try-restart|force-reload|status) return 0 ;;
64+
esac
65+
return 1
66+
}
5667
exec_rc ()
5768
{
69+
local rc=''
5870
if sd_booted && test -z "$SYSTEMD_NO_WRAP"; then
59-
case "$2" in
60-
start|stop|reload|restart|try-restart|force-reload|status)
71+
if is_systemd_action "$2"; then
6172
if is_service "$1"; then
6273
daemon_reload "$1.service"
6374
systemctl "$2" "$1.service"
@@ -78,15 +89,18 @@ exec_rc ()
7889
fi
7990
echo "$1 is neither service nor target!?" >&2
8091
return "1"
81-
;;
82-
*)
92+
elif [ -x "$actiondir/$1/$2" ]; then
93+
rc="$actiondir/$1/$2"
94+
shift 2
95+
else
8396
echo "Usage: $0 "$1" {start|stop|reload|restart|try-restart|force-reload|status}"
8497
return 1
85-
;;
86-
esac
98+
fi
99+
fi
100+
if [ -z "$rc" ]; then
101+
rc="${RCDIR}/$1"
102+
shift
87103
fi
88-
local rc="${RCDIR}/$1"
89-
shift
90104
env -i LANG=$LANG PATH=$PATH TERM=$TERM SYSTEMD_NO_WRAP=$SYSTEMD_NO_WRAP "$rc" ${1+"$@"}
91105
}
92106

0 commit comments

Comments
 (0)