* add some script to wrap the debian package build that does some magic about
[citadel.git] / citadel / debian / citadel-server.postrm
1 #! /bin/sh
2 # postrm.skeleton
3 # Skeleton maintainer script showing all the possible cases.
4 # Written by Charles Briscoe-Smith, March-June 1998.  Public Domain.
5 . /usr/share/debconf/confmodule
6
7 # Abort if any command returns an error value
8 set -e
9
10 # This script is called twice during the removal of the package; once
11 # after the removal of the package's files from the system, and as
12 # the final step in the removal of this package, after the package's
13 # conffiles have been removed.
14
15 # Ensure the menu system is updated
16 : [ ! -x /usr/bin/update-menus ] || /usr/bin/update-menus
17
18 case "$1" in
19   remove)
20     # This package is being removed, but its configuration has not yet
21     # been purged.
22                 export CREATE_INITTAB_ENTRY=no
23                 /usr/lib/citadel-server/setup -q
24                 killall -HUP init
25
26
27     # Remove diversion
28     #: dpkg-divert --package foo --remove --rename \
29     #:             --divert /usr/bin/other.real /usr/bin/other
30
31     # ldconfig is NOT needed during removal of a library, only during
32     # installation
33         
34     ;;
35   purge)
36     # This package has previously been removed and is now having
37     # its configuration purged from the system.
38         # remove the gunzipped setup executable.
39     rm -f /usr/share/doc/citadel-server/contrib/setup
40         for i in  '?' aide  floors  hours  intro  mail  network  nice  policy  software  summary; do
41                 ucf --purge "/var/lib/citadel/help/$i"
42                 rm -f "/var/lib/citadel/help/$i"
43         done
44         rmdir "/var/lib/citadel/help"
45
46         for i in aideopt  changepw  dotopt  entermsg  entopt  goodbye  hello  help  mainmenu  newuser  readopt  register  roomaccess  unlisted; do
47                 ucf --purge "/var/lib/citadel/messages/$i"
48                 rm -f "/var/lib/citadel/messages/$i"
49         done
50         rmdir "/var/lib/citadel/messages"
51
52         for i in mail.aliases public_clients citadel.conf; do 
53                 ucf --purge "/etc/citadel/$i"
54                 rm -f "/etc/citadel/$i"
55         done
56     # we mimic dpkg as closely as possible, so we remove configuration
57     # files with dpkg backup extensions too:
58     ### Some of the following is from Tore Anderson:
59     for ext in '~' '%' .bak .dpkg-tmp .dpkg-new .dpkg-old .dpkg-dist;  do
60                 rm -f /etc/citadel/*$ext
61                 rm -f /var/lib/citadel/messages/*$ext
62                 rm -f /var/lib/citadel/help/*$ext
63     done
64         echo "/var/lib/citadel/data not removed, as it may contain your personal data."
65         db_purge
66         db_go
67         ### TODO: remove citadel from inittab!
68     ;;
69   disappear)
70     if test "$2" != overwriter; then
71       echo "$0: undocumented call to \`postrm $*'" 1>&2
72       exit 0
73     fi
74     # This package has been completely overwritten by package $3
75     # (version $4).  All our files are already gone from the system.
76     # This is a special case: neither "prerm remove" nor "postrm remove"
77     # have been called, because dpkg didn't know that this package would
78     # disappear until this stage.
79     :
80
81     ;;
82   upgrade)
83     # About to upgrade FROM THIS VERSION to version $2 of this package.
84     # "prerm upgrade" has been called for this version, and "preinst
85     # upgrade" has been called for the new version.  Last chance to
86     # clean up.
87     :
88
89     ;;
90   failed-upgrade)
91     # About to upgrade from version $2 of this package TO THIS VERSION.
92     # "prerm upgrade" has been called for the old version, and "preinst
93     # upgrade" has been called for this version.  This is only used if
94     # the previous version's "postrm upgrade" couldn't handle it and
95     # returned non-zero. (Fix old postrm bugs here.)
96     :
97
98     ;;
99   abort-install)
100     # Back out of an attempt to install this package.  Undo the effects of
101     # "preinst install...".  There are two sub-cases.
102     :
103
104     if test "${2+set}" = set; then
105       # When the install was attempted, version $2's configuration
106       # files were still on the system.  Undo the effects of "preinst
107       # install $2".
108       :
109
110     else
111       # We were being installed from scratch.  Undo the effects of
112       # "preinst install".
113       :
114
115     fi ;;
116   abort-upgrade)
117     # Back out of an attempt to upgrade this package from version $2
118     # TO THIS VERSION.  Undo the effects of "preinst upgrade $2".
119     :
120
121     ;;
122   *) echo "$0: didn't understand being called with \`$1'" 1>&2
123      exit 0;;
124 esac
125
126 exit 0