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
|
#!/bin/sh
# Debian wdm package pre-removal script
# Copyright 1998 Marcelo Magallon.
# Based on xdm's prerm script
# Copyright 1998 Branden Robinson. Licensed under the GNU GPL.
# Acknowlegements to Stephen Early, Mark Eichin, and Manoj Srivastava.
set -e
DAEMON=/usr/bin/X11/wdm
parseans () {
if [ ! $1 ]; then
echo $default
else
echo $1 | cut -c1 | tr '[A-Z]' '[a-z]';
fi;
}
trap "echo ;\
echo 'Received signal. Aborting removal of wdm package.' ;\
echo ;\
exit 1" 1 3 15
trap "echo ;\
echo 'Received keyboard interrupt. Not stopping wdm daemon.' ;\
echo 'To activate the new version of the wdm daemon, type the' ;\
echo 'command \"/etc/init.d/wdm restart\" at the shell prompt.' ;\
echo ;\
exit 0" 2
case "$1" in
remove|upgrade|failed-upgrade|deconfigure)
# we NEVER want to stop wdm without doing some checks first, see below
;;
*)
echo "ERROR: wdm prerm called with unknown argument \"$1\"."
echo "Aborting removal of wdm package."
exit 1 ;;
esac
condecho=:
nostop=
# is there an wdm process running?
if [ "$(pidof $DAEMON)" ] ; then
# any children?
parents="$(pidof $DAEMON)"
children=
for process in $parents; do
# make sure we got numbers back
if [ ! $process -eq $process ]; then
# freak out
echo "wdm.prerm: pidof returned non-numeric value!"
exit 1
fi
if ps ajhx | grep -q "^ *$process"; then
children=yes
fi
done
if [ "${children}" ]; then
# are we supposed to restart on upgrade?
if grep -q ^restart-on-upgrade /etc/X11/wdm/wdm.options 2>/dev/null; then
$condecho
echo "WARNING: Preparing to stop X display manager (wdm) daemon, and it"
echo "appears to be managing at least one running session. If wdm is"
echo "stopped now, those sessions will be terminated. Otherwise you"
echo "may leave wdm running, and the new version will take effect the"
echo "next time wdm is restarted."
echo
condecho=echo
default=n
echo -n "Do you wish to stop the wdm daemon? (y/n) [$default] "
read answer
answer=$(parseans $answer)
case $answer in
y) ;;
n) nostop=yes ;;
*) echo "\"$answer\" not understood. Using default of \"$default\"." ;;
esac
else
nostop=yes
fi
fi
fi
[ "$nostop" ] || /etc/init.d/wdm stop
exit
|