#!/bin/sh set -e CONFIG=/etc/default/mailgraph CONFIG_BAK=/etc/default/mailgraph.bak RRD_DIR=/var/lib/mailgraph NEED_UPDATE=0 # load debconf library . /usr/share/debconf/confmodule write_config() { cat < "${CONFIG}" # variables for /etc/init.d/mailgraph # # Should Mailgraph start on boot (true|false) [debconf] BOOT_START=${BOOT_START} # Logfile used by mailgraph (default: /var/log/mail.log) [debconf] MAIL_LOG=${MAIL_LOG} # Ignore mails from localhost (true|false) [debconf] IGNORE_LOCALHOST=${IGNORE_LOCALHOST} # see mailgraph -h output EXTRA_OPTIONS="${EXTRA_OPTIONS}" EOF return $? } update_config() { # create backup cp ${CONFIG} ${CONFIG_BAK} # write new configuration write_config # remove backup, if configuration was created successfully if [ $? -eq 0 ]; then rm ${CONFIG_BAK} else mv ${CONFIG_BAK} ${CONFIG} fi } make_rrd_dir() { if [ ! -d ${RRD_DIR} ]; then mkdir ${RRD_DIR} fi chown www-data:www-data ${RRD_DIR} } if [ -f ${CONFIG} ]; then . ${CONFIG} NEED_UPDATE=1 fi db_get mailgraph/start_on_boot BOOT_START=${RET} db_get mailgraph/mail_log MAIL_LOG=${RET} db_get mailgraph/ignore_localhost IGNORE_LOCALHOST=${RET} if [ ! -n "${EXTRA_OPTIONS}" ]; then EXTRA_OPTIONS="" fi if [ ${NEED_UPDATE} -eq 0 ]; then write_config else update_config fi make_rrd_dir #DEBHELPER# exit 0