Commit c04d0f71 authored by Michael Biebl's avatar Michael Biebl Committed by Tollef Fog Heen
Browse files

Try to catch direct init script invocations and redirect to systemctl

Install lsb-base hook which redirects calls to SysV init scripts to
systemctl: /etc/init.d/<foo> <action> → systemctl <action> <foo.service>
parent f07be1bf
......@@ -11,6 +11,8 @@ systemd (13-1) experimental; urgency=low
* Revert upstream change which requires libnotify 0.7 (not yet available in
Debian).
* Use dh-autoreconf for updating the build system.
* Install lsb-base hook which redirects calls to SysV init scripts to
systemctl: /etc/init.d/<foo> <action> → systemctl <action> <foo.service>
* Install a (auto)mount unit to mount /lib/init/rw early during boot.
-- Tollef Fog Heen <tfheen@debian.org> Sat, 20 Nov 2010 09:28:01 +0100
......
# -*-Shell-script-*-
# /etc/lsb-base-logging.sh
if [ -e /sys/fs/cgroup/systemd ] ; then
# Some init scripts use "set -e" and "set -u", we don't want that
# here
set +e
set +u
if [ -n "$DPKG_MAINTSCRIPT_PACKAGE" ] ; then
# If we are called by a maintainer script, chances are good that a
# new or updated sysv init script was installed. Reload daemon to
# pick up any changes.
echo "Reloading systemd"
systemctl daemon-reload
fi
# Redirect SysV init scripts when executed by the user
if [ $PPID -ne 1 ] && [ -z "$init" ] && [ -z "$_SYSTEMCTL_SKIP_REDIRECT" ] ; then
case "$0" in
/etc/init.d/*)
_use_systemctl=1
;;
esac
else
export _SYSTEMCTL_SKIP_REDIRECT="true"
fi
else
_use_systemctl=0
fi
systemctl_redirect () {
local s
local rc
local prog=${1##*/}
local command=$2
case "$command" in
start)
s="Starting $prog (via systemctl)"
;;
stop)
s="Stopping $prog (via systemctl)"
;;
reload|force-reload)
s="Reloading $prog configuration (via systemctl)"
;;
restart)
s="Restarting $prog (via systemctl)"
;;
esac
service="${prog%.sh}.service"
[ "$command" = status ] || log_daemon_msg "$s" "$service"
/bin/systemctl $command "$service"
rc=$?
[ "$command" = status ] || log_end_msg $rc
return $rc
}
if [ "$_use_systemctl" = "1" ]; then
if [ "x$1" = xstart -o \
"x$1" = xstop -o \
"x$1" = xrestart -o \
"x$1" = xreload -o \
"x$1" = xforce-reload -o \
"x$1" = xstatus ] ; then
systemctl_redirect $0 $1
exit $?
fi
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment