Re: Error!

#47411

kasus
Member

I tried to do like you say, but USERNAME and PASSWORD files in /var/register/net/interfaces/ppp0 are empty now 🙁

I have this /root/kerbynet.cgi/template/3Gconfig file:


#!/bin/sh
. /etc/kerbynet.conf
. $SCRIPTS/net.inc
NAME="$1"
DESCRIPTION="$2"
TTY="$3"
APN="$4"
DIAL="$5"
OPTIONAL="$6"
DEFAULTROUTE="$7"
AUTO="$8"
NAT="$9"
USERNAME=${10}
PASSWORD=${11}
[ -z "$NAME" ] && exit 1
CONFIG="$REGISTER/system/net/interfaces/"
PPPDIR="$CONFIG/$NAME"
echo "$DESCRIPTION" > $PPPDIR/Description
echo "$TTY" > $PPPDIR/TTY
echo "$APN" > $PPPDIR/APN
echo "$DIAL" > $PPPDIR/Dial
echo "$OPTIONAL" > $PPPDIR/Optional
echo "$DEFAULTROUTE" > $PPPDIR/DEFAULTROUTE
echo "$AUTO" > $PPPDIR/Auto
echo "$USERNAME" > $PPPDIR/USERNAME
echo "$PASSWORD" > $PPPDIR/PASSWORD
if [ "$NAT" == yes ] ; then
mkdir -p $PPPDIR/NAT/Masquerade
iptables -t nat -D POSTROUTING -o $NAME -j MASQUERADE 2> /dev/null
iptables -t nat -A POSTROUTING -o $NAME -j MASQUERADE
else
rm -rf $PPPDIR/NAT/Masquerade
iptables -t nat -D POSTROUTING -o $NAME -j MASQUERADE 2>/dev/null
fi
if ps -ef |grep 3Gconnect |grep -q $NAME || [ "$AUTO" == yes ] ; then
$SCRIPTS/3Gconnect_stop $NAME
$SCRIPTS/3Gconnect $NAME &
fi

And this is my make3G file is made like-this.

This is my 3Gconnect file:

#!/bin/bash
. /etc/kerbynet.conf
export PPP="$1"
[ -z "$PPP" ] && exit 1
UNIT=${PPP:3:1}
I=0
PID=`ps -ef |grep -w pppd |grep $PPP| awk '{print $2}'`
while [ -n "$PID" -a $I -lt 15 ] ; do
kill $PID
sleep 1
I=$((I+1))
PID=`ps -ef |grep -w pppd |grep $PPP| awk '{print $2}'`
done
if [ -n "$PID" ] ; then
kill -9 $PID
sleep 1
rm -f /var/run/$PPP.pid
fi
TTY="`cat $REGISTER/system/net/interfaces/$PPP/TTY 2>/dev/null`"
if [ "$TTY" = NotDetected ] ; then
exit 1
fi
APN="`cat $REGISTER/system/net/interfaces/$PPP/APN 2>/dev/null`"
DIAL="`cat $REGISTER/system/net/interfaces/$PPP/Dial 2>/dev/null`"
OPTIONAL="`cat $REGISTER/system/net/interfaces/$PPP/Optional 2>/dev/null`"
DEFAULTROUTE="`cat $REGISTER/system/net/interfaces/$PPP/DEFAULTROUTE 2>/dev/null`"
USERNAME="`cat $REGISTER/system/net/interfaces/$PPP/USERNAME 2>/dev/null`"
PASSWORD="`cat $REGISTER/system/net/interfaces/$PPP/PASSWORD 2>/dev/null`"
if [ -n "$OPTIONAL" ] ; then
OPTIONAL=""OK" "$OPTIONAL""
fi
if [ -n "$APN" ] ; then
APN=""OK" 'AT+CGDCONT=1,"IP","$APN","",0,0'"
fi
if [ -n "$USERNAME" ] ; then
USERNAME="user $USERNAME"
else
USERNAME=""
fi
if [ -n "$PASSWORD" ] ; then
PASSWORD="password $PASSWORD"
else
PASSWORD=""
fi
if [ "$DEFAULTROUTE" == yes ] ; then
DEFAULTROUTE=defaultroute
else
DEFAULTROUTE=""
fi
cat > /tmp/$PPP.3G <<EOF
/udev/$TTY
921600
lock
crtscts
modem
noauth
$USERNAME
$PASSWORD
$DEFAULTROUTE
connect "$SCRIPTS/chat.sh"
unit $UNIT
EOF
cat > /tmp/$PPP.chat <<EOF
ABORT BUSY
ABORT 'NO CARRIER'
ABORT ERROR
REPORT CONNECT
TIMEOUT 15
"" AT
$OPTIONAL
$APN
"OK" "ATD$DIAL"
CONNECT c
EOF
while true; do
PID=`ps -ef |grep -w pppd |grep $PPP| awk '{print $2}'`
if [ -z "$PID" ] ; then
if [ -r /udev/$TTY ] ; then
pppd file /tmp/$PPP.3G 2>/dev/null
else
$SCRIPTS/usb_modem_try.sh 2>/dev/null >/dev/null
sleep 5
if ! [ -r /udev/$TTY ] ; then
logger -t pppd "ppp$UNIT: ERROR: Modem /udev/$TTY unavailable."
sleep 20
fi
fi
fi
sleep 10
done

And this is my /root/kerbynet.cgi/template/3Gconfig:



2G/3G Mobile Connection

function loaded() {
X=document.data;
X.TTY.value="";
X.Auto.value="";
X.Defaultroute.value="";
X.NAT.value="";
X.USERNAME.value="";
X.PASSWORD.value="";
}
function SubmitData() {
X=document.data;
if (X.TTY.value=="") {
alert('"Modem connected to" field cannot be empty.');
return;
}
X.submit();
}




<input type=hidden name=Section value="">
<input type=hidden name=Action value=""><input type=hidden name=STk value=>
<input type=hidden name=Name value="">
2G/3G Mobile Connection 

 >> Interface:        



Description
<input type=text name=Description style="width: 100%;" maxlength=60 value="">














   Modem connected to:
   APN:<input type=text name=APN value="">
   Dial string:<input type=text name=Dial value="">
   Optional AT string:<input type=text name=Optional value="">
   Autostart the connection at boot:NoYes
   Make this interface the Default Route:NoYes
   Enable NAT on this interface:NoYes
   USERNAME:<input type=text name=USERNAME value="">
   PASSWORD:<input type=text name=PASSWORD value="">









So, where is error? 🙂