#-----------------------------------------------------------------------------
# /etc/rc.d/rc610 - cgiconfig2 configuration
#
# Creation:     05.04.2004  benjamin h. <bosborros at web dot de>
# Last Update:  28.11.2005  hh <hh at fli4l dot de>
#-----------------------------------------------------------------------------

case $OPT_CGICONFIG2 in
yes)
    case "$OPT_HTTPD" in 
    yes)
        begin_script CGICONFIG2 "configuring OPT_CGIConfig2 ..."

        httpd-menu.sh add cgiconfig2.cgi CGIConfig2 Opt 150 cgiconfig

        # write variables
        case $OPT_DHCPD in
            yes) echo "leasefile='$DHCP_LEASES_DIR/dhcpd.leases'" > /var/run/cgiconfig2.conf ;;
        esac
        case $OPT_DNSDHCP in
            yes) echo "leasefile='$DNSDHCP_LEASES_DIR/dnsmasq.leases'" > /var/run/cgiconfig2.conf ;;
        esac
        echo "CGICONFIG2_SAVE_PATH='$CGICONFIG2_SAVE_PATH'" >> /var/run/cgiconfig2.conf

        mkdir -p $CGICONFIG2_SAVE_PATH
        
        # do some hacks if portfw_n='0' for the packet filter chains automatically be added by rc360.fwrules.new
        [ -f /etc/portfw.conf ] || > /etc/portfw.conf
        [ 0$PORTFW_N -gt 0 ] || PORTFW_N='1'

        end_script
    ;;
    *)
        log_error "OPT_HTTPD needed! Package was not found."
    ;;
    esac
;;
esac