Új hozzászólás Aktív témák

  • bpmcwap

    senior tag

    Sziasztok, mivel többen is vannak itt akik írtak már shel scriptet a routerra ezért bátorkodom előjönni a témával újfent mert mostanra már nagyon aktuális lett a dolog
    Szóval van a vargaalex buildben egy olyan ahol meg lehet adni az ftp jelszot és formázni lehet a hdd-t, ide tennék be egy olyat hogy csak magát a netet be lehessen állítani anélkül hogy be kéne menni az open menüjébe- ettől anyám mindig megijed, hugom meg nem is hajlandó belépni... EL is kezdtem írni aztán Alex is segített csak félbe maradt az egész, itt van ameddig eljutottam, de ez sajnos semmit nem csinál.... Ha tudna nekem segíteni valaki az nagyon jó lenne...
    Köszönöm
    #!/bin/sh

    header()
    {
    cat << __EOF__
    Content-type: text/html

    <html>
    <head>
    <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
    <meta http-equiv="Content-Type" content="text/html" charset="UTF-8" />
    <title>NET CONFIG </title>
    <script>
    function setprotocol(protocol)
    {
    var prot = document.getElementById(protocol);
    prot.selected = true;
    }
    </script>
    </head>
    <body onload="setprotocol('$PROTOKOLL')">
    <form action=net_config method=post>
    <h2>NET CONFIG</h2>
    __EOF__
    }

    footer()
    {
    cat << __EOF__
    </body>
    </html>
    __EOF__
    }

    protokoll()
    {
    cat << __EOF__

    <label for="PROTOKOLL">Protokoll:</label>
    <select name=PROTOKOLL id="my_protokoll" onChange="this.form.submit();">
    <option id="static" value="static">Statikus cím</option>
    <option id="dhcp" value="dhcp">DHCP ügyfél</option>
    <option id="none" value="none">Nem kezelt</option>
    <option id="ppp" value="ppp">PPP</option>
    <option id="pptp" value="pptp">PPtP</option>
    <option id="pppoe" value="pppoe">PPPoE</option>
    <option id="pppoa" value="pppoa">PPPoATM</option>
    <option id="3g" value="3g">UMTS/GPRS/EV-DO</option>
    </select>
    <br>
    __EOF__

    if [ "$PROTOKOLL" == "pppoe" ]
    then
    cat << __EOF__
    <label for="P_USERNAME">Username:</label><input name=P_USERNAME id="p_username" type="text"/><br>
    <label for="P_PASSWORD">Password:</label><input name=P_PASSWORD id="p_password" type="text"/><br>
    __EOF__
    fi

    if [ "$PROTOKOLL" == "dhcp" ]
    then
    cat << __EOF__
    <label for="P_GATEWAY">gateway:</label><input name=P_GATEWAY id="p_gateway" type="text"/><br>
    __EOF__
    fi

    if [ "$PROTOKOLL" == "static" ]
    then
    cat << __EOF__
    <label for="P_IPADDR">IP address:</label><input name=P_IPADDR id="p_ipaddr" type="text"/><br>
    <label for="P_NETMASK">Netmask:</label><input name=P_NETMASK id="p_netmask" type="text"/><br>
    <label for="P_DNS">DNS:</label><input name=P_DNS id="p_dns" type="text"/><br>
    __EOF__
    fi
    echo "<input type=submit accesskey=c name=ACTION value=\"Change\">"
    }

    changing()
    {

    # ide jon a protokoll atallitasa pl. uci parancsokkal:

    uci set network.wan.proto = $PROTOKOLL

    ###DHCP
    if [ "$PROTOKOLL" == "dhcp" ]
    then
    uci set network.wan.gateway=$GATEWAY
    fi

    ###PPPoE
    if [ "$PROTOKOLL" == "pppoe" ]
    then
    uci set network.wan.username=$P_USERNAME
    uci set network.wan.password=$P_PASSWORD
    fi

    ###STATIC
    if [ "$PROTOKOLL" == "static" ]
    then
    uci set network.wan.ipadr=$P_IPADR
    uci set network.wan.netmask=$P_NETMASK
    uci set network.wan.dns=$P_DNS
    fi

    }

    PROTOKOLL=$(uci get network.wan.proto)
    query_string=`dd count=$CONTENT_LENGTH bs=1 2> /dev/null | sed 's/&/;/g'`
    eval ${query_string}
    case "${ACTION}" in
    "change") header ; changing ; footer ;;
    *) header ; protokoll ; footer ;;
    esac

Új hozzászólás Aktív témák