| 1 |
#! /bin/sh |
| 2 |
|
| 3 |
set -e |
| 4 |
|
| 5 |
# We need debconf |
| 6 |
. /usr/share/debconf/confmodule |
| 7 |
|
| 8 |
# The following function does the real stuff |
| 9 |
debconf_dialog() { |
| 10 |
# Ask the user if he wants this stuff at all |
| 11 |
db_input medium quota/run_warnquota || true |
| 12 |
db_go |
| 13 |
|
| 14 |
# Ask more questions if warnquota enabled |
| 15 |
db_get quota/run_warnquota |
| 16 |
if [ "$RET" = "true" ]; then |
| 17 |
# Set the defaults for email addresses |
| 18 |
if [ -f /etc/mailname ]; then |
| 19 |
email="root@`cat /etc/mailname`" |
| 20 |
else |
| 21 |
email="root@`hostname -f`" |
| 22 |
fi |
| 23 |
|
| 24 |
db_fget quota/mailfrom seen |
| 25 |
if [ "$RET" = "false" ]; then |
| 26 |
db_set quota/mailfrom "$email" |
| 27 |
fi |
| 28 |
db_fget quota/supportemail seen |
| 29 |
if [ "$RET" = "false" ]; then |
| 30 |
db_set quota/supportemail "$email" |
| 31 |
fi |
| 32 |
db_fget quota/message seen |
| 33 |
if [ "$RET" = "false" ]; then |
| 34 |
db_set quota/message "" |
| 35 |
fi |
| 36 |
db_fget quota/signature seen |
| 37 |
if [ "$RET" = "false" ]; then |
| 38 |
db_set quota/signature "" |
| 39 |
fi |
| 40 |
db_fget quota/subject seen |
| 41 |
if [ "$RET" = "false" ]; then |
| 42 |
db_set quota/subject "" |
| 43 |
fi |
| 44 |
db_fget quota/cc seen |
| 45 |
if [ "$RET" = "false" ]; then |
| 46 |
db_set quota/cc "" |
| 47 |
fi |
| 48 |
db_fget quota/charset seen |
| 49 |
if [ "$RET" = "false" ]; then |
| 50 |
db_set quota/charset "" |
| 51 |
fi |
| 52 |
db_fget quota/cc_before seen |
| 53 |
if [ "$RET" = "false" ]; then |
| 54 |
db_set quota/cc_before "" |
| 55 |
fi |
| 56 |
db_fget quota/group_message seen |
| 57 |
if [ "$RET" = "false" ]; then |
| 58 |
db_set quota/group_message "" |
| 59 |
fi |
| 60 |
db_fget quota/group_signature seen |
| 61 |
if [ "$RET" = "false" ]; then |
| 62 |
db_set quota/group_signature "" |
| 63 |
fi |
| 64 |
|
| 65 |
# Now ask the user |
| 66 |
db_input medium quota/supportemail || true |
| 67 |
db_input high quota/supportphone || true |
| 68 |
db_input low quota/mailfrom || true |
| 69 |
db_input low quota/message || true |
| 70 |
db_input low quota/signature || true |
| 71 |
db_input low quota/subject || true |
| 72 |
db_input low quota/cc || true |
| 73 |
db_input low quota/charset || true |
| 74 |
db_input low quota/cc_before || true |
| 75 |
db_input low quota/group_message || true |
| 76 |
db_input low quota/group_signature || true |
| 77 |
db_go |
| 78 |
|
| 79 |
# If we did not get a support phone we'll set it to "*unknown*" |
| 80 |
db_get quota/supportphone |
| 81 |
if [ -z "$RET" ]; then |
| 82 |
db_set quota/supportphone "*unknown*" |
| 83 |
fi |
| 84 |
fi |
| 85 |
} |
| 86 |
|
| 87 |
# Check if we need to run the configuration dialog |
| 88 |
# a) explicitely requested |
| 89 |
if [ "$1" = "reconfigure" ]; then |
| 90 |
debconf_dialog |
| 91 |
# Move the old configuration files out of the way |
| 92 |
rm -f /etc/warnquota.conf /etc/default/quota |
| 93 |
fi |
| 94 |
|
| 95 |
# b) new installation |
| 96 |
if [ "$1" = "configure" ] && [ -z "$2" ]; then |
| 97 |
debconf_dialog |
| 98 |
db_get quota/run_warnquota |
| 99 |
if [ "$RET" = "true" ]; then |
| 100 |
# Move the old configuration file out of the way |
| 101 |
rm -f /etc/warnquota.conf /etc/default/quota |
| 102 |
fi |
| 103 |
fi |
| 104 |
|
| 105 |
# c) upgrading from before debconf |
| 106 |
# In this case only the debconf data is updated - it is not written to |
| 107 |
# the config file, only after dpkg-reconfigure something will happen. |
| 108 |
if [ "$1" = "configure" ] && dpkg --compare-versions "$2" le-nl "3.03-4"; then |
| 109 |
# Figure out what we can from /etc/warnquota.conf |
| 110 |
if grep -q "<enter your phone number here>" /etc/warnquota.conf; then |
| 111 |
db_set quota/run_warnquota false |
| 112 |
db_fset quota/run_warnquota seen true |
| 113 |
db_set quota/supportphone "*unknown*" |
| 114 |
else |
| 115 |
db_set quota/run_warnquota true |
| 116 |
db_fset quota/run_warnquota seen true |
| 117 |
db_set quota/mailfrom \ |
| 118 |
"`sed -n 's/^FROM[^=]*=[[:space:]]*"\([^"]*\)"$/\1/p' \ |
| 119 |
/etc/warnquota.conf`" |
| 120 |
db_fset quota/mailfrom seen true |
| 121 |
db_set quota/supportemail \ |
| 122 |
"`sed -n 's/^SUPPORT[^=]*=[[:space:]]*"\([^"]*\)"$/\1/p' \ |
| 123 |
/etc/warnquota.conf`" |
| 124 |
db_fset quota/supportemail seen true |
| 125 |
db_set quota/supportphone \ |
| 126 |
"`sed -n 's/^PHONE[^=]*=[[:space:]]*"\([^"]*\)"$/\1/p' \ |
| 127 |
/etc/warnquota.conf`" |
| 128 |
db_fset quota/supportphone seen true |
| 129 |
fi |
| 130 |
fi |
| 131 |
|
| 132 |
# d) upgrading changes behaviour of rpc.rquotad |
| 133 |
if [ "$1" = "configure" ] && dpkg --compare-versions "$2" le-nl "3.06-1"; then |
| 134 |
db_input high quota/rquota_setquota || true |
| 135 |
db_go |
| 136 |
fi |
| 137 |
|
| 138 |
# e) upgrading add warnquota group email |
| 139 |
if [ "$1" = "configure" ] && dpkg --compare-versions "$2" le-nl "3.06-2"; then |
| 140 |
db_input low quota/group_message || true |
| 141 |
db_input low quota/group_signature || true |
| 142 |
db_go |
| 143 |
fi |
| 144 |
|
| 145 |
# f) upgrading from a version that did not ask for SUBJECT and CC |
| 146 |
if [ "$1" = "configure" ] && dpkg --compare-versions "$2" le-nl "3.11-1"; then |
| 147 |
# Figure out what we can from /etc/warnquota.conf |
| 148 |
db_set quota/subject \ |
| 149 |
"`sed -n 's/^SUBJECT[^=]*=[[:space:]]*"\([^"]*\)"$/\1/p' \ |
| 150 |
/etc/warnquota.conf`" |
| 151 |
db_fset quota/subject seen true |
| 152 |
db_set quota/cc \ |
| 153 |
"`sed -n 's/^CC_TO[^=]*=[[:space:]]*"\([^"]*\)"$/\1/p' \ |
| 154 |
/etc/warnquota.conf`" |
| 155 |
db_fset quota/cc seen true |
| 156 |
fi |
| 157 |
|
| 158 |
# g) upgrading from a version that did not have CC_BEFORE |
| 159 |
if [ "$1" = "configure" ] && dpkg --compare-versions "$2" le-nl "3.11-4"; then |
| 160 |
# Ask the question only if warnquota enabled |
| 161 |
db_get quota/run_warnquota |
| 162 |
if [ "$RET" = "true" ]; then |
| 163 |
db_input low quota/cc_before || true |
| 164 |
db_go |
| 165 |
fi |
| 166 |
fi |
| 167 |
|
| 168 |
# h) upgrading from a version that did not have CHARSET |
| 169 |
if [ "$1" = "configure" ] && dpkg --compare-versions "$2" le-nl "3.16-1"; then |
| 170 |
# Ask the question only if warnquota enabled |
| 171 |
db_get quota/run_warnquota |
| 172 |
if [ "$RET" = "true" ]; then |
| 173 |
db_input low quota/charset || true |
| 174 |
db_go |
| 175 |
fi |
| 176 |
fi |