#!/bin/sh set -e # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-remove' # * `abort-deconfigure' `in-favour' # `removing' # # 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" <> "$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" <> "$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