4
# Required-Start: mountkernfs
6
# Default-Start: 2 3 4 5
8
# Short-Description: Cgroup manager daemon
10
# The cgroup manager accepts cgroup administration requests
11
# over dbus, honoring privilege by root users in mapped user
12
# namespaces over the non-root mapped uids. This allows safe
13
# nesting of lxc containers by unprivileged users.
20
DAEMON=/sbin/cgmanager
22
DESC="cgroup management daemon"
24
BASEOPTS="--daemon -m name=systemd"
26
test -x $DAEMON || exit 0
28
PIDFILE=/run/$NAME.pid
30
if [ -f /etc/default/cgmanager ]; then
31
# get cgmanager_opts if specified
32
. /etc/default/cgmanager
35
# Load the VERBOSE setting and other rcS variables
38
# Define LSB log_* functions.
39
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
40
# and status_of_proc is working.
41
. /lib/lsb/init-functions
43
DAEMON_ARGS="$BASEOPTS $cgmanager_opts $cgm_extra_mounts"
47
# If the cgmanager stops, the proxy must stop
48
/etc/init.d/cgproxy stop >/dev/null 2>&1 || true
50
# 0 if daemon has been stopped
51
# 1 if daemon was already stopped
52
# 2 if daemon could not be stopped
53
# other if a failure occurred
54
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
56
[ "$RETVAL" = 2 ] && return 2
57
# Wait for children to finish too if this is a daemon that forks
58
# and if the daemon is only ever run from this initscript.
59
# If the above conditions are not satisfied then add some other code
60
# that waits for the process to drop all resources that could be
61
# needed by services started subsequently. A last resort is to
62
# sleep for some time.
63
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
64
[ "$?" = 2 ] && return 2
65
# Many daemons don't delete their pidfiles when they exit.
73
# 0 if daemon has been started
74
# 1 if daemon was already running
75
# 2 if daemon could not be started
76
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
79
# Kill any existing cgproxy
80
/etc/init.d/cgproxy stop >/dev/null 2>&1 || true
81
# check whether to start cgproxy or cgmanager
82
if /sbin/cgproxy --check-master; then
83
NESTED=yes /etc/init.d/cgproxy start || true && { exit 0; }
86
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
89
# Todo - once the compiled cgm is installed we could use it here to ping
90
# cgmanager as our test for readiness.
96
log_daemon_msg "Restarting $DESC" "$NAME"
103
1) log_end_msg 1 ;; # Old process is still running
104
*) log_end_msg 1 ;; # Failed to start
114
log_daemon_msg "Starting $DESC" "$NAME"
117
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
118
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
122
log_daemon_msg "Stopping $DESC" "$NAME"
125
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
126
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
130
status_of_proc -p $PIDFILE "$DAEMON" "$NAME" && exit 0 || exit $?
133
echo "Usage: $0 {start|stop|restart|force-reload}" >&2