You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
176 lines
6.1 KiB
176 lines
6.1 KiB
14 years ago
|
#! /bin/sh
|
||
13 years ago
|
# prerm script for tdm-trinity
|
||
14 years ago
|
#
|
||
|
# see: dh_installdeb(1)
|
||
|
|
||
|
set -e
|
||
|
|
||
|
# summary of how this script can be called:
|
||
|
# * <prerm> `remove'
|
||
|
# * <old-prerm> `upgrade' <new-version>
|
||
|
# * <new-prerm> `failed-upgrade' <old-version>
|
||
|
# * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
|
||
|
# * <deconfigured's-prerm> `deconfigure' `in-favour'
|
||
|
# <package-being-installed> <version> `removing'
|
||
|
# <conflicting-package> <version>
|
||
|
# for details, see http://www.debian.org/doc/debian-policy/ or
|
||
|
# the debian-policy package
|
||
|
|
||
|
# debconf may not be available if some massive purging is going on
|
||
|
HAVE_DEBCONF=
|
||
|
if [ -e /usr/share/debconf/confmodule ]; then
|
||
|
. /usr/share/debconf/confmodule
|
||
|
HAVE_DEBCONF=yes
|
||
|
fi
|
||
|
|
||
|
case "$1" in
|
||
11 years ago
|
# we NEVER want to unconditionally stop tdm-trinity; see below
|
||
14 years ago
|
upgrade|failed-upgrade)
|
||
|
REMOVING=
|
||
|
;;
|
||
|
|
||
|
remove|deconfigure)
|
||
|
REMOVING=yes
|
||
|
;;
|
||
|
|
||
|
*)
|
||
|
echo "prerm called with unknown argument \`$1'" >&2
|
||
|
exit 1
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
STOP=
|
||
11 years ago
|
# are we supposed to restart on upgrade? if REMOVING tdm-trinity, we don't care what
|
||
14 years ago
|
# the user says, we have to stop the daemon
|
||
13 years ago
|
if grep -qs ^restart-on-upgrade /etc/trinity/tdm/tdm.options ||
|
||
14 years ago
|
[ -n "$REMOVING" ]; then
|
||
13 years ago
|
# is there an tdm process running?
|
||
11 years ago
|
if start-stop-daemon --stop --quiet --signal 0 --exec /opt/trinity/bin/tdm; then
|
||
14 years ago
|
# any children?
|
||
11 years ago
|
PARENTS=$(pidof /opt/trinity/bin/tdm || true)
|
||
14 years ago
|
CHILDREN=
|
||
11 years ago
|
if [ -n "$PARENTS" ]; then
|
||
14 years ago
|
for PROCESS in $PARENTS; do
|
||
|
# make sure we got numbers back
|
||
|
[ $PROCESS -eq $PROCESS ] 2> /dev/null ||
|
||
|
exit
|
||
|
# FIXME - redo this part uses shell-lib.sh from xfree86
|
||
|
# die "pidof returned non-numeric value"
|
||
|
# we could use grep -q here if ps would ignore SIGPIPE :-P
|
||
|
if (ps axj | grep "^ *$PROCESS" > /dev/null 2>&1); then
|
||
|
CHILDREN=yes
|
||
|
fi
|
||
|
done
|
||
|
if [ -n "$CHILDREN" ]; then
|
||
|
if [ -n "$HAVE_DEBCONF" ]; then
|
||
|
# ask the question
|
||
11 years ago
|
db_input high tdm-trinity/stop_running_server_with_children || true
|
||
14 years ago
|
db_go
|
||
|
# what did the user say?
|
||
|
ANSWER=
|
||
11 years ago
|
if db_get tdm-trinity/stop_running_server_with_children; then
|
||
14 years ago
|
ANSWER="$RET"
|
||
|
fi
|
||
|
if [ "$ANSWER" = "true" ]; then
|
||
|
STOP=yes
|
||
|
fi
|
||
|
# forget that we have seen the question; this is the sort of
|
||
|
# non-configuration question that should be asked every time
|
||
11 years ago
|
db_fset tdm-trinity/stop_running_server_with_children seen false
|
||
14 years ago
|
fi
|
||
|
else
|
||
|
STOP=yes
|
||
|
fi
|
||
|
fi
|
||
|
fi
|
||
|
fi
|
||
|
|
||
|
if [ -n "$STOP" ]; then
|
||
|
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
|
||
13 years ago
|
invoke-rc.d tdm-trinity stop || true
|
||
14 years ago
|
else
|
||
13 years ago
|
/etc/init.d/tdm-trinity stop || true
|
||
14 years ago
|
fi
|
||
|
else
|
||
|
if [ "$1" = "upgrade" -o "$1" = "failed-upgrade" ]; then
|
||
13 years ago
|
touch /var/run/tdm-trinity.upgrade
|
||
14 years ago
|
fi
|
||
|
fi
|
||
|
|
||
|
DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager
|
||
|
|
||
|
if [ "$1" = "remove" -o "$1" = "deconfigure" ]; then
|
||
|
if [ -n "$HAVE_DEBCONF" ]; then
|
||
|
# disown this question
|
||
|
db_unregister shared/default-x-display-manager || true
|
||
|
# does the question still exist?
|
||
|
if db_get shared/default-x-display-manager; then
|
||
|
if db_metaget shared/default-x-display-manager owners; then
|
||
|
# FIXME - redo this part uses shell-lib.sh from xfree86
|
||
|
#observe "X display managers now available are \"$OWNERS\""
|
||
|
db_subst shared/default-x-display-manager choices "$RET"
|
||
|
fi
|
||
|
DEFAULT_DISPLAY_MANAGER=
|
||
|
if db_get shared/default-x-display-manager; then
|
||
|
DEFAULT_DISPLAY_MANAGER="$RET"
|
||
|
fi
|
||
|
# are we removing the currently selected display manager?
|
||
|
if [ -n "$DEFAULT_DISPLAY_MANAGER" ]; then
|
||
13 years ago
|
if [ "tdm-trinity" = "$DEFAULT_DISPLAY_MANAGER" ]; then
|
||
14 years ago
|
if [ -e "$DEFAULT_DISPLAY_MANAGER_FILE" ]; then
|
||
|
if db_get "$DEFAULT_DISPLAY_MANAGER/daemon_name"; then
|
||
|
# does the display manager file reference the current default? if
|
||
|
# so, remove it because it will now be wrong
|
||
|
if [ -n "$RET" ]; then
|
||
|
if [ "$(cat "$DEFAULT_DISPLAY_MANAGER_FILE")" = "$RET" ]; then
|
||
|
rm "$DEFAULT_DISPLAY_MANAGER_FILE"
|
||
|
fi
|
||
|
fi
|
||
|
fi
|
||
|
fi
|
||
|
# ask the user to choose a new default
|
||
|
db_fset shared/default-x-display-manager seen false
|
||
|
db_input critical shared/default-x-display-manager || true
|
||
|
db_go
|
||
|
# if the default display manager file doesn't exist, write it with
|
||
|
# the path to the new default display manager
|
||
|
if [ ! -e "$DEFAULT_DISPLAY_MANAGER_FILE" ]; then
|
||
|
DEFAULT_DISPLAY_MANAGER=
|
||
|
if db_get shared/default-x-display-manager; then
|
||
|
DEFAULT_DISPLAY_MANAGER="$RET"
|
||
|
fi
|
||
|
if [ -n "$DEFAULT_DISPLAY_MANAGER" ]; then
|
||
|
# FIXME - redo this part uses shell-lib.sh from xfree86
|
||
|
#warn "new default display manager has been selected; please be" \
|
||
|
# "sure to run \"dpkg-reconfigure $RET\" to ensure that it" \
|
||
|
# "is configured"
|
||
|
DAEMON_NAME=
|
||
|
if db_get "$DEFAULT_DISPLAY_MANAGER"/daemon_name; then
|
||
|
DAEMON_NAME="$RET"
|
||
|
fi
|
||
|
if [ ! -n "$DAEMON_NAME" ]; then
|
||
|
# if we were unable to determine the name of the selected daemon (for
|
||
|
# instance, if the selected default display manager doesn't provide a
|
||
|
# daemon_name question), guess
|
||
|
DAEMON_NAME=$(which "$DEFAULT_DISPLAY_MANAGER" 2>/dev/null)
|
||
|
if [ ! -n "$DAEMON_NAME" ]; then
|
||
|
echo .
|
||
|
# FIXME - redo this part uses shell-lib.sh from xfree86
|
||
|
#warn "unable to determine path to default X display manager" \
|
||
|
# "$DEFAULT_DISPLAY_MANAGER; not updating" \
|
||
|
# "$DEFAULT_DISPLAY_MANAGER_FILE"
|
||
|
fi
|
||
|
fi
|
||
|
if [ -n "$DAEMON_NAME" ]; then
|
||
|
echo "$DAEMON_NAME" > "$DEFAULT_DISPLAY_MANAGER_FILE"
|
||
|
fi
|
||
|
fi
|
||
|
fi
|
||
|
fi
|
||
|
fi
|
||
|
fi
|
||
|
fi
|
||
|
fi
|
||
|
|
||
|
exit 0
|