#!/bin/sh
# postinst script for xcat-ui
#
# 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


case "$1" in
    configure)
        apachedaemon=apache2
        /bin/rm -f /etc/apache2/conf.d/xcat-ui.conf
        /bin/ln -s /opt/xcat/ui/etc/apache2/conf.d/xcat-ui.conf /etc/apache2/conf.d/xcat-ui.conf
        /etc/init.d/apache2 restart
        # automatically put the encrypted passwd into the xcat passwd db
        /opt/xcat/sbin/chtab key=xcat,username=root passwd.password=`grep root /etc/shadow|cut -d : -f 2`

        echo "To use xCAT-UI, point your browser to http://"`hostname -f`"/xcat"
    ;;

    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