Adding debian version 0.4.1-1 (FIXME).
[debian/lxdm.git] / debian / lxdm.prerm
1 #!/bin/sh
2 # Debian lxdm package pre-removal script
3 # Based on xdm.prerm
4 # Copyright 1998-2004 Branden Robinson.
5 # Licensed under the GNU General Public License, version 2.  See the file
6 # /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
7 # Acknowledgements to Stephen Early, Mark Eichin, and Manoj Srivastava.
8
9 set -e
10
11 THIS_PACKAGE=lxdm
12
13 DAEMON=/usr/bin/lxdm
14
15
16 DEFAULT_DISPLAY_MANAGER_FILE=/etc/X11/default-display-manager
17
18 if [ "$1" = "remove" ] || [ "$1" = "deconfigure" ]; then
19   if [ -e /usr/share/debconf/confmodule ]; then
20     . /usr/share/debconf/confmodule
21     # disown this question
22     db_unregister shared/default-x-display-manager
23     # does the question still exist?
24     if db_get shared/default-x-display-manager; then
25       db_metaget shared/default-x-display-manager owners
26       db_subst shared/default-x-display-manager choices "$RET"
27       db_get shared/default-x-display-manager
28       # are we removing the currently selected display manager?
29       if [ "$THIS_PACKAGE" = "$RET" ]; then
30         if [ -e "$DEFAULT_DISPLAY_MANAGER_FILE" ]; then
31           if db_get "$RET"/daemon_name; then
32             if [ "$(cat $DEFAULT_DISPLAY_MANAGER_FILE)" = "$RET" ]; then
33               rm "$DEFAULT_DISPLAY_MANAGER_FILE"
34             fi
35           else
36             if [ "$(cat $DEFAULT_DISPLAY_MANAGER_FILE)" = "$DAEMON" ]; then
37               rm "$DEFAULT_DISPLAY_MANAGER_FILE"
38             fi
39           fi
40         fi
41         # ask the user to choose a new default
42         db_fset shared/default-x-display-manager seen false
43         db_input critical shared/default-x-display-manager || true
44         db_go
45         # if the display manager file doesn't exist, write it with the path
46         # to the new default display manager
47         if [ ! -e $DEFAULT_DISPLAY_MANAGER_FILE ]; then
48           db_get shared/default-x-display-manager
49           db_get "$RET"/daemon_name
50           echo "$RET" > "$DEFAULT_DISPLAY_MANAGER_FILE"
51         fi
52       fi
53     fi
54   fi
55 fi
56
57 # Remove /etc/lxdm/lxdm.conf from alternative of lxdm configuration
58 if [ "$1" = "remove" ] ; then
59   update-alternatives --remove lxdm.conf /etc/lxdm/lxdm.conf
60 fi
61
62
63 #DEBHELPER#
64
65 exit 0