1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
#!/bin/sh
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
. /usr/share/debconf/confmodule
CONFIG_FILE=/etc/email-reminder.conf
case "$1" in
configure)
# Ensure the email-reminder user exists before we try to use it
if ! getent passwd email-reminder > /dev/null; then
systemd-sysusers /usr/lib/sysusers.d/email-reminder.conf
fi
# The config file can include the SMTP password so hide it
touch $CONFIG_FILE
chmod 640 $CONFIG_FILE
chown email-reminder:root $CONFIG_FILE
# Update the config file with debconf settings
DEBCONF_START="### BEGIN DEBCONF SECTION - DO NOT EDIT ###"
DEBCONF_END="### END DEBCONF SECTION ###"
USER_SECTION="### Add your custom settings below this line ###"
# Save user customizations (everything after USER_SECTION marker)
USER_CUSTOMS=""
if [ -f "$CONFIG_FILE" ] && grep -q "^${USER_SECTION}" "$CONFIG_FILE" 2>/dev/null; then
USER_CUSTOMS=$(sed -n "/^${USER_SECTION}/,\$p" "$CONFIG_FILE" | tail -n +2)
fi
# Rebuild the config file from scratch
cat > $CONFIG_FILE <<EOF
${DEBCONF_START}
# WARNING: This section is automatically generated from debconf settings.
# DO NOT edit this section directly or your changes will be lost.
# To change these values, run: dpkg-reconfigure email-reminder
EOF
db_get email-reminder/send_reminders
echo "send_reminders = ${RET}" >> $CONFIG_FILE
db_get email-reminder/smtp_server
echo "smtp_server = ${RET}" >> $CONFIG_FILE
db_get email-reminder/smtp_username
echo "smtp_username = ${RET}" >> $CONFIG_FILE
db_get email-reminder/smtp_password
echo "smtp_password = ${RET}" >> $CONFIG_FILE
db_reset email-reminder/smtp_password
db_get email-reminder/smtp_ssl
echo "smtp_ssl = ${RET}" >> $CONFIG_FILE
db_get email-reminder/mail_from
echo "mail_from = ${RET}" >> $CONFIG_FILE
cat >> $CONFIG_FILE <<EOF
${DEBCONF_END}
${USER_SECTION}
EOF
# Append user customizations if any were saved
if [ -n "$USER_CUSTOMS" ]; then
echo "$USER_CUSTOMS" >> $CONFIG_FILE
fi
# Create the spool directory for that user
mkdir -p /var/spool/email-reminder
chown email-reminder:root /var/spool/email-reminder/
chmod 770 /var/spool/email-reminder/
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0
|