2 # /etc/lsb-base-logging.sh
4 if [ -e /sys/fs/cgroup/systemd ] ; then
6 # Some init scripts use "set -e" and "set -u", we don't want that
11 if [ -n "$DPKG_MAINTSCRIPT_PACKAGE" ] ; then
12 # If we are called by a maintainer script, chances are good that a
13 # new or updated sysv init script was installed. Reload daemon to
14 # pick up any changes.
15 echo "Reloading systemd"
16 systemctl daemon-reload
19 # Redirect SysV init scripts when executed by the user
20 if [ $PPID -ne 1 ] && [ -z "$init" ] && [ -z "$_SYSTEMCTL_SKIP_REDIRECT" ] ; then
23 # Don't redirect if the init script has X-Interactive: true
24 if ! grep -qs "^# X-Interactive:.*true" "$0"; then
30 export _SYSTEMCTL_SKIP_REDIRECT="true"
36 systemctl_redirect () {
44 s="Starting $prog (via systemctl)"
47 s="Stopping $prog (via systemctl)"
50 s="Reloading $prog configuration (via systemctl)"
53 s="Restarting $prog (via systemctl)"
57 service="${prog%.sh}.service"
59 # Don't try to run masked services. Don't check for errors, if
60 # this errors, we'll just call systemctl and possibly explode
62 state=$(systemctl -p LoadState show $service 2>/dev/null)
63 [ "$state" = "LoadState=masked" ] && return 0
65 [ "$command" = status ] || log_daemon_msg "$s" "$service"
66 /bin/systemctl $command "$service"
68 [ "$command" = status ] || log_end_msg $rc
73 if [ "$_use_systemctl" = "1" ]; then
74 if [ "x$1" = xstart -o \
78 "x$1" = xforce-reload -o \
79 "x$1" = xstatus ] ; then
81 systemctl_redirect $0 $1