monotone

monotone Mtn Source Tree

Root/monotone-server.postrm

1#! /bin/sh
2# vim: set ft=sh sw=4 et:
3# postrm script for #PACKAGE#
4#
5# see: dh_installdeb(1)
6
7set -e
8
9# summary of how this script can be called:
10# * <postrm> `remove'
11# * <postrm> `purge'
12# * <old-postrm> `upgrade' <new-version>
13# * <new-postrm> `failed-upgrade' <old-version>
14# * <new-postrm> `abort-install'
15# * <new-postrm> `abort-install' <old-version>
16# * <new-postrm> `abort-upgrade' <old-version>
17# * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
18# for details, see http://www.debian.org/doc/debian-policy/ or
19# the debian-policy package
20
21case "$1" in
22 purge)
23 # note: when executing in this mode, this script cannot assume
24 # the existence of _any_ of the package dependencies. it must
25 # work using only Essential packages. hence, in several cases
26 # below we do cleanups only if the relevant program exists.
27
28 # remove config files from ucf database and filesystem
29 for conf in write-permissions read-permissions hooks.lua; do
30
31 # mimic dpkg and remove backups too
32 for ext in '' '~' '%' .bak .ucf-new .ucf-old .ucf-dist; do
33 rm -f /etc/monotone/$conf$ext || true
34 done
35
36 # clear entries in ucf database
37 # note: we cannot assume ucf is still installed at this point
38 # (if it isn't, we don't need to worry about its database)
39 if which ucf > /dev/null; then
40 ucf --purge /etc/monotone/$conf
41 fi
42 if which ucfr > /dev/null; then
43 ucfr --purge monotone-server /etc/monotone/$conf
44 fi
45 done
46
47 # if debconf still exists and we were asked to auto-manage the
48 # database, delete the auto-generated key and database. don't
49 # delete anything else in /var/lib/monotone - there might be
50 # hand-created databases and keys that the admin wants to keep.
51 # in any case remove /var/lib/monotone(/keys) if empty.
52
53 if [ -e /usr/share/debconf/confmodule ]; then
54 . /usr/share/debconf/confmodule
55
56 db_get monotone-server/manage-db
57 if [ "$RET" = true ]; then
58 db_get monotone-server/key
59 rm -f /var/lib/monotone/keys/"$RET"
60
61 rm -f /var/lib/monotone/default.mtn
62 rm -f /var/lib/monotone/default.mtn~
63 rm -f /var/lib/monotone/default.mtn-journal
64
65 grep -v "$RET" /etc/monotone/passphrases \
66 > /etc/monotone/passphrases.dpkg-new || true
67 if [ -s /etc/monotone/passphrases.dpkg-new ]; then
68 mv -f /etc/monotone/passphrases.dpkg-new \
69 /etc/monotone/passphrases
70 else
71 rm -f /etc/monotone/passphrases.dpkg-new \
72 /etc/monotone/passphrases
73 fi
74
75 fi
76 # do not stop debconf, the debhelper additions will need it.
77 fi
78 rmdir --ignore-fail-on-non-empty /var/lib/monotone/keys
79 rmdir --ignore-fail-on-non-empty /var/lib/monotone
80
81 # if deluser/delgroup exist, remove the server user and group.
82 # do not do this if /var/lib/monotone still exists (so that it
83 # will still have a named user owning it).
84 if which deluser > /dev/null && [ ! -e /var/lib/monotone ]; then
85 if [ -n "`id -u monotone 2>/dev/null`" ]; then
86 deluser --quiet monotone 2>/dev/null >/dev/null
87 fi
88
89 if [ -n "`id -g monotone 2>/dev/null`" ]; then
90 delgroup --quiet monotone 2>/dev/null >/dev/null
91 fi
92 else
93 if [ -e /var/lib/monotone ]; then
94 reason="/var/lib/monotone still exists"
95 else
96 reason="deluser is not available"
97 fi
98 echo "warning: not deleting monotone user or group because $reason" >&2
99 fi
100 ;;
101 remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
102 ;;
103
104 *)
105 echo "postrm called with unknown argument \`$1'" >&2
106 exit 1
107
108esac
109
110# dh_installdeb will replace this with shell code automatically
111# generated by other debhelper scripts.
112
113#DEBHELPER#
114
115exit 0

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status