#! /bin/sh
# postinst script for wlanthermo

# Trage alle Dienste im Autostart ein
insserv WLANThermo
insserv WLANThermoWD
insserv WLANThermoDIS
# update-rc.d WLANThermoSERVO defaults
# update-rc.d WLANThermoSERVO defaults

lighty-enable-mod auth

if [ -f /etc/lighttpd/lighttpd.conf ]
then
    echo Backing up old lighttpd.conf
    mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.bak
fi

mv /var/www/conf/lighttpd.conf /etc/lighttpd/lighttpd.conf

if [ -f /var/www/tmp/update ] #Pruefen, ob ueber das GUI ein Passwort gesetzt wurde
then
    passwort=`cat /var/www/tmp/update`
    htpasswd -c -b /etc/lighttpd/htpasswd wlanthermo $passwort
    rm /var/www/tmp/update # Updateflag zuruecksetzen
else
    echo 'Jetzt das Passwort für den Benutzer >wlanthermo< des geschützten Bereichs eingeben!'
    htpasswd -c /etc/lighttpd/htpasswd wlanthermo
fi
service lighttpd restart
service WLANThermo start
service WLANThermoWD start

