#!/bin/sh
# postinst script for sudosh2
#
# see: dh_installdeb(1)

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

CONFIG_FILE=/etc/sudosh.conf.sample

create_config_file() {
    TMP_CONFIG_FILE=`mktemp`

    cat  <<EOF > ${TMP_CONFIG_FILE}
# Sudosh Configuration File
logdir                  = /var/log/sudosh
default shell           = /bin/bash
delimiter               = -
syslog.priority         = LOG_NOTICE
syslog.facility         = LOG_DAEMON

# Allow Sudosh to execute -c arguements?  If so, what?
-c arg allow = scp
-c arg allow = sftp
-c arg allow = /usr/libexec/openssh/sftp-server
# -c arg allow = rsync
EOF
}





copy_config_file() {
    create_config_file
    D=`date +%Y-%m-%d__%H:%M:%S`
    if [ -e "${CONFIG_FILE}" ]; then
        cp ${TMP_CONFIG_FILE} ${CONFIG_FILE}-NEW-${D}
        return 0
    else
         cp ${TMP_CONFIG_FILE} ${CONFIG_FILE}
    fi
}


case "$1" in
    configure)
        copy_config_file
    ;;

    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
