1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
#!/bin/sh
# /etc/init.d/wdm: start or stop the WINGs display manager
set -e
# To start wdm even if it is not the default display manager, change
# HEED_DEFAULT_DISPLAY_MANAGER to "false."
HEED_DEFAULT_DISPLAY_MANAGER=true
DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager
PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/bin/X11/wdm
PIDFILE=/var/run/wdm.pid
UPGRADEFILE=/var/run/wdm.upgrade
test -x $DAEMON || exit 0
# If we upgraded the daemon, we can't use the --exec argument to
# start-stop-daemon since the inode will have changed. The risk here is that
# in a situation where the daemon died, its pidfile was not cleaned up, and
# some other process is now running under that pid, start-stop-daemon will send
# signals to an innocent process. However, this seems like a corner case.
# C'est la vie!
if [ -e $UPGRADEFILE ]; then
SSD_ARGS="--pidfile $PIDFILE --startas $DAEMON"
else
SSD_ARGS="--pidfile $PIDFILE --exec $DAEMON"
fi
stillrunning () {
if [ "$DAEMON" = "$(cat /proc/$DAEMONPID/cmdline 2> /dev/null)" ]; then
true
else
# if the daemon does not remove its own pidfile, we will
rm -f $PIDFILE $UPGRADEFILE
false
fi;
}
case "$1" in
start)
if [ -e $DEFAULT_DISPLAY_MANAGER_FILE -a \
"$HEED_DEFAULT_DISPLAY_MANAGER" = "true" -a \
"$(cat $DEFAULT_DISPLAY_MANAGER_FILE)" != "$DAEMON" ]; then
echo "Not starting WINGs display manager (wdm); it is not the default display manager."
else
echo -n "Starting WINGs display manager: wdm"
if grep -qs ^auto-update-wmlist /etc/X11/wdm/wdm.options; then
update_wdm_wmlist
fi
start-stop-daemon --start --quiet $SSD_ARGS || echo -n " already running"
echo "."
fi
;;
restart)
/etc/init.d/wdm stop
if [ -f $PIDFILE ]; then
if stillrunning; then
exit 1
fi
fi
/etc/init.d/wdm start
;;
reload)
echo -n "Reloading WINGs display manager configuration..."
if grep -qs ^auto-update-wmlist /etc/X11/wdm/wdm.options; then
update_wdm_wmlist
fi
if start-stop-daemon --stop --signal 1 --quiet $SSD_ARGS; then
echo "done."
else
echo "wdm not running."
fi
;;
force-reload)
/etc/init.d/wdm reload
;;
stop)
echo -n "Stopping WINGs display manager: wdm"
if [ ! -f $PIDFILE ]; then
echo " not running ($PIDFILE not found)."
exit 0
else
DAEMONPID=$(cat $PIDFILE | tr -d '[:blank:]')
KILLCOUNT=1
if [ ! -e $UPGRADEFILE ]; then
start-stop-daemon --stop --quiet $SSD_ARGS || echo -n " not running"
fi
while [ $KILLCOUNT -le 5 ]; do
if stillrunning; then
kill $DAEMONPID
else
break
fi
sleep 1
KILLCOUNT=$(expr $KILLCOUNT + 1)
done
if stillrunning; then
echo -n " not responding to TERM signal (pid $DAEMONPID)"
else
rm -f $UPGRADEFILE
fi
fi
echo "."
;;
*)
echo "Usage: /etc/init.d/wdm {start|stop|restart|reload|force-reload}"
exit 1
;;
esac
exit 0
# vim:set ai et sts=2 sw=2 tw=0:
|