Update of /cvsroot/leaf/src/config/webconf/var/webconf/www
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv5330

Added Files:
        dnsmasq.cgi pppoe.cgi 
Log Message:
ppp/pppoe lwp source
dnsmasq source


--- NEW FILE: pppoe.cgi ---
#!/usr/bin/haserl -u
<? title="DSL Settings"  /var/webconf/lib/preamble.sh  ?>

<H1>DSL Account Settings</H1>
<p>This page allows you to manage the DSL Account settings (pppoe). 
After adding your username and password, save the configuration 
and (re)start your DSL connection.
</p>

<? # This gets the current settings 

get_settings () {
        grep "^name.*" $PPPOE_CONFFILE | sed 's/ /=/' >/tmp/$SESSIONID.vars
        grep "^maxfail.*$" $PPPOE_CONFFILE | sed 's/ /=/' >>/tmp/$SESSIONID.vars

        . /tmp/$SESSIONID.vars

        cp /tmp/$SESSIONID.vars /my.vars


        }

save_settings () {
        # get_settings must already have been called...
        sed "s|^name.*$|name \"$FORM_DSLUSER\"|" < $PPPOE_CONFFILE 
>/tmp/$SESSIONID.conf
        cp /tmp/$SESSIONID.conf $PPPOE_CONFFILE
        sed "s/^maxfail.*$/maxfail $FORM_MAXFAIL/" < $PPPOE_CONFFILE 
>/tmp/$SESSIONID.conf
        cp /tmp/$SESSIONID.conf $PPPOE_CONFFILE
        chmod +x $PPPOE_CONFFILE
        echo '#This is a pap-secrets file' > /tmp/$SESSIONID.ppp
        echo '#papname * papsecret' >> /tmp/$SESSIONID.ppp
        echo $FORM_DSLUSER   '* ' $FORM_password >> /tmp/$SESSIONID.ppp
        cp /tmp/$SESSIONID.ppp $PAP_CONFFILE
        }

start_ppp () {
        /sbin/ifdown ppp0 2>/dev/null; /sbin/ifup ppp0 1>/dev/null
        }

PPPOE_CONFFILE=/etc/ppp/peers/dsl-provider
PAP_CONFFILE=/etc/ppp/pap-secrets
get_settings

. /var/webconf/lib/validator.sh
        if [ "$FORM_cmd" = "Save" ]; then
        . /var/webconf/lib/validator.sh
        if [ "$FORM_password" != "$FORM_password2" ]; then
        echo -e "+Passwords\nPasswords do not match." | report_validation_fail
        else
        report_validation_ok
        fi
                                                                    
        # This actually makes the changes...
#               report_validation_ok
        save_settings
        get_settings
#               fi                                  
        fi
        if [ "$FORM_ppp_start" = "Start" ]; 
        then start_ppp
        fi
?>


<form action="<? echo -n $SCRIPT_NAME ?>" method=post 
enctype="multipart/form-data">

<h1>Configuration</h1>
<? if [ "$FORM_cmd" = "List" ]; then
        cat <<-EOF
        <!-- 
        #BEGIN WEBCONF SETTINGS LIST 
        $( cat /tmp/$SESSIONID.vars )
        #END WEBCONF SETTINGS LIST 
        -->
        EOF
        fi
        ?>

<h2>Account Settings</h2>
<p>Insert your DSL Username and DSL password given by your Internet
Service Provider.</p>
<table> 
<tr><td>DSL Username</td>
<td><input type=text size="30" name=DSLUSER value="<? . /tmp/$SESSIONID.vars
                                        [ -z "$FORM_DSLUSER" ] && 
FORM_DSLUSER=$name
                                        echo -n "$FORM_DSLUSER" ?>">

<tr><td>DSL Password:</td>
<td><input type=password name=password></td>
<tr><td>Re-enter DSL Password:</td>
<td><input type=password name=password2></td>
<td>Re-enter the DSL password for verification</td></tr>
</table>

<h2>Connection attempts</h2>
<p>Define how often pppoe should try to establish a connection until it quits.
Set to "0" if pppoe should try to connect forever.</p>
<table> 
<tr><td><b>Maximal connection attempts</b></td>
<td><input type=text size="3" maxlength="5" name=MAXFAIL value="<? . 
/tmp/$SESSIONID.vars
                                        [ -z "$FORM_MAXFAIL" ] && 
FORM_MAXFAIL=$maxfail
                                        echo -n "$FORM_MAXFAIL" ?>">
</td></tr>
</table>

<h2>&nbsp;</h2>

<table><tr><td><input type=submit name="cmd" value="Save"></td>
<td>Saves data to configuration files.</td></tr>
</table>
<input type=hidden name=UI value="<? echo -n $FORM_UI ?>">

<h2>&nbsp;</h2>

<h1>(Re)Start your pppoe connection</h1>
<table><tr><td><input type=submit name="ppp_start" value="Start"</td>
<td>(Re)start your internet connection. This may take a minute.</td>
</tr>
</table>
</form>


<? rm /tmp/$SESSIONID.*; 
   /var/webconf/lib/footer.sh ?>        

--- NEW FILE: dnsmasq.cgi ---
#!/usr/bin/haserl -u
<? title="DNS/DHCP Settings"  /var/webconf/lib/preamble.sh  ?>

<H1>DNS/DHCP Settings</H1>
<p>Choose your DNS (Domain Name Server) settings and setup your local DHCP 
daemon.
<br>
(Re)start the DNS and DHCP daemon after saving the configuration.
</p>

<? # This gets the current settings 
get_settings () {
        grep "^domain.*=.*$" $DNSMASQ_CONFFILE >/tmp/$SESSIONID.vars
        grep "resolv-file.*=.*$" $DNSMASQ_CONFFILE | sed 's/^#//' | sed 
's/-/_/' >>/tmp/$SESSIONID.vars
        
        while read line; do
        echo $line | grep "dhcp-range.*=.*$" > /dev/null
                if [ "$?" -eq "0" ]; then
                echo $line | sed 's/^#//' | sed 's/-/_/' >>/tmp/$SESSIONID.vars
                break
        fi
        done < $DNSMASQ_CONFFILE
        . /tmp/$SESSIONID.vars
        }
        
save_settings () {
        # get_settings must already have been called...
        if [ -z $FORM_RESOLV ]; then 
                sed -e "s|resolv-file.*$|#resolv-file=|" < $DNSMASQ_CONFFILE > 
/tmp/$SESSIONID.conf
        else
                sed -e "s|resolv-file.*$|resolv-file=$FORM_RESOLV|" -e 
"/resolv-file.*/ s/#//" < $DNSMASQ_CONFFILE >/tmp/$SESSIONID.conf
        fi
        cp /tmp/$SESSIONID.conf $DNSMASQ_CONFFILE

#       if [ -z $FORM_DOMAIN ]; then 
#               sed -e "s|domain.*$|#domain=|" < $DNSMASQ_CONFFILE > 
/tmp/$SESSIONID.conf
#       else
                sed -e "s|^domain=.*$|domain=$FORM_DOMAIN|" < $DNSMASQ_CONFFILE 
>/tmp/$SESSIONID.conf
#       fi
        cp /tmp/$SESSIONID.conf $DNSMASQ_CONFFILE

        if [ -z $FORM_DHCPRANGE ]; then 
                sed -e "1,/dhcp-range/ s/dhcp-range.*$/#dhcp-range=/" < 
$DNSMASQ_CONFFILE > /tmp/$SESSIONID.conf
        else
                sed -e "1,/dhcp-range/ 
s/dhcp-range.*$/dhcp-range=$FORM_DHCPRANGE/" -e "/dhcp-range=$FORM_DHCPRANGE/ 
s/#//" < $DNSMASQ_CONFFILE >/tmp/$SESSIONID.conf
        fi

        cp /tmp/$SESSIONID.conf $DNSMASQ_CONFFILE

        }

DNSMASQ_CONFFILE=/etc/dnsmasq.conf
get_settings
. /var/webconf/lib/validator.sh

        if [ "$FORM_cmd" = "Save" ]; then
        . /var/webconf/lib/validator.sh
        report_validation_ok
                                                                    
        save_settings
        get_settings
        fi
?>

<form action="<? echo -n $SCRIPT_NAME ?>" method=post 
enctype="multipart/form-data">

<h1>Daemon Status</h1>
<? /var/webconf/lib/svcstat.sh "$FORM_cmd" "The DNS/DHCP daemon" dnsmasq ?>

<h1>Configuration</h1>
<? if [ "$FORM_cmd" = "List" ]; then
        cat <<-EOF
        <!-- 
        #BEGIN WEBCONF SETTINGS LIST 
        $( cat /tmp/$SESSIONID.vars )
        #END WEBCONF SETTINGS LIST 
        -->
        EOF
        fi
        ?>

<h2>DNS and DHCP Settings</h2>
<p>Configure the Domain Name Resolution (DNS) and enable DHCP for dynamic host 
configuration.</p>
<table> 

<tr><td>Domain</td>
<td><p>Set optionally the domain for dnsmasq. If set, it
does the following things.
<br>
 1) Allows DHCP hosts to have fully qualified domain names, as long
     as the domain part matches this setting.
<br>
 2) Sets the "domain" DHCP option thereby potentially setting the
    domain of all systems configured by DHCP
</p>
<input type=text size="40" name=DOMAIN value="<? . /tmp/$SESSIONID.vars
                                        [ -z "$FORM_DOMAIN" ] && 
FORM_DOMAIN=$domain
                                        echo -n "$FORM_DOMAIN" ?>">
<hr>
<tr><td>DHCP-Range</td>
<td><p>To enable DHCP you need to supply the range of addresses available for 
lease and optionally a lease time.</p>
<input type=text size="40" name=DHCPRANGE value="<? . /tmp/$SESSIONID.vars
                                        [ -z "$FORM_DHCPRANGE" ] && 
FORM_DHCPRANGE=$dhcp_range
                                        echo -n "$FORM_DHCPRANGE" ?>">
<hr>
<tr><td>resolv-file</td>
<td><p>Change if you rely on your Internet Service Provider's Domain Name 
Service. 
<br>
ADSL users change to: <i>/etc/ppp/resolv.conf</i>
<br>
Cable users change to: <i>/etc/dhcpc/resolv.conf</i>
<br>
If empty it defaults to: <i>/etc/resolv.conf</i>
</p>
<input type=text size="40" name=RESOLV value="<? . /tmp/$SESSIONID.vars
                                        [ -z "$FORM_RESOLV" ] && 
FORM_RESOLV=$resolv_file
                                        echo -n "$FORM_RESOLV" ?>">
</table>


<h2>&nbsp;</h2>

<table><tr><td><input type=submit name="cmd" value="Save"></td>
<td>Saves data to configuration file.</td></tr>
</table>
<input type=hidden name=UI value="<? echo -n $FORM_UI ?>">

</form>

<? rm /tmp/$SESSIONID.*; 
   /var/webconf/lib/footer.sh ?>        


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
leaf-cvs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/leaf-cvs-commits

Reply via email to