Skip to content

Commit 88e157c

Browse files
committed
correction script
update pw.cgi update run.sh update main.js
1 parent 48d8922 commit 88e157c

5 files changed

Lines changed: 51 additions & 36 deletions

File tree

install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ if [ -d /tmp/PPPwn_ow-main ]; then
5151
rm -r /tmp/PPPwn_ow-main
5252
fi
5353

54-
chmod +x /etc/init.d/pppoe-server
5554
chmod +x /www/cgi-bin/pw.cgi
55+
chmod +x /root/run.sh
5656

5757
if ! grep -q "list device 'ppp+'" /etc/config/firewall; then
5858
sed -i "s/option name 'lan'/option name 'lan'\n\t list device 'ppp+'/" /etc/config/firewall

run.sh

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
#!/bin/sh
22

3-
interface=""
4-
version=""
5-
root="/root"
6-
timeout=0
7-
stage1=""
8-
stage2=""
3+
source /root/pw.conf
94

105
if /etc/init.d/pppoe-server status | grep -q "running"; then
116
/etc/init.d/pppoe-server stop
@@ -15,15 +10,15 @@ ip link set $interface down
1510
sleep 5
1611
ip link set $interface up
1712

18-
pppwn --interface "$interface" --fw "$version" --stage1 $stage1 --stage2 $stage2 --timeout $timeout --auto-retry
13+
res=$(pppwn --interface "$interface" --fw "$version" --stage1 "$stage1" --stage2 "$stage2" --timeout $timeout --auto-retry)
1914

20-
if [ $? -eq 0 ]; then
15+
if [ $res -eq 0 ]; then
2116
if /etc/init.d/pppoe-server status | grep -q "inactive"; then
2217
/etc/init.d/pppoe-server start
2318
fi
24-
echo "Console attempts($attempts) PPPwned!\n" > "log"
19+
echo "$res" > "log"
2520
exit 0
2621
else
27-
echo "Fail attempts($attempts)\n" > "log"
22+
echo "$res" > "log"
2823
exit 1
2924
fi

version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1
1+
0.1.6

www/cgi-bin/pw.cgi

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ if [ "$token" = "token_id" ]; then
146146
echo "},"
147147
if [ -f /root/pw.conf ];then
148148
source /root/pw.conf
149-
echo "\"adapter\":\"$inputAdapter\","
150-
echo "\"timeout\":\"$inputTimeout\","
151-
echo "\"version\":\"$inputVersion\","
149+
echo "\"adapter\":\"$interface\","
150+
echo "\"timeout\":\"$timeout\","
151+
echo "\"version\":\"$version\","
152152
fi
153153
else
154154
echo "\"pppwn\":false,"
@@ -181,13 +181,13 @@ if [ "$token" = "token_id" ]; then
181181
"start")
182182

183183
if [ -f /root/pw.conf ]; then
184-
sed -i "s/inputAdapter=.*/inputAdapter=$adapter/" /root/pw.conf
185-
sed -i "s/inputTimeout=.*/inputTimeout=$timeout/" /root/pw.conf
186-
sed -i "s/inputVersion=.*/inputVersion=$version/" /root/pw.conf
184+
sed -i "s/interface=.*/interface=$adapter/" /root/pw.conf
185+
sed -i "s/timeout=.*/timeout=$timeout/" /root/pw.conf
186+
sed -i "s/version=.*/version=$version/" /root/pw.conf
187187
else
188-
echo -e "inputAdapter=$adapter\n" > /root/pw.conf
189-
echo -e "inputTimeout=$timeout\n" >> /root/pw.conf
190-
echo -e "inputVersion=$version\n" >> /root/pw.conf
188+
echo -e "interface=$adapter\n" > /root/pw.conf
189+
echo -e "timeout=$timeout\n" >> /root/pw.conf
190+
echo -e "version=$version\n" >> /root/pw.conf
191191
fi
192192

193193
if /etc/init.d/pppoe-server status | grep -q "running"; then
@@ -232,21 +232,38 @@ if [ "$token" = "token_id" ]; then
232232
echo "/root/run.sh &" >> /etc/rc.local
233233
echo "exit 0" >> /etc/rc.local
234234
fi
235-
236-
if grep -q "interface=" "/root/run.sh"; then
237-
sed -i "s/interface=\".*\"/interface=\"$adapter\"/" "/root/run.sh"
238-
fi
239-
if grep -q "version=" "/root/run.sh"; then
240-
sed -i "s/version=\".*\"/version=\"$version\"/" "/root/run.sh"
241-
fi
242-
if grep -q "timeout=" "/root/run.sh"; then
243-
sed -i "s/timeout=\".*\"/timeout=\"$timeout\"/" "/root/run.sh"
244-
fi
245-
if grep -q "stage1=" "/root/run.sh"; then
246-
sed -i "s/stage1=\".*\"/stage1=\"$stage1\"/" "/root/run.sh"
247-
fi
248-
if grep -q "stage2=" "/root/run.sh"; then
249-
sed -i "s/stage2=\".*\"/stage2=\"$stage2\"/" "/root/run.sh"
235+
236+
if [ -f /root/pw.conf ]; then
237+
238+
if grep -q "interface=" "/root/pw.conf"; then
239+
sed -i "s/interface=.*/interface=$adapter/" "/root/pw.conf"
240+
else
241+
echo -e "interface=$adapter" >> "/root/pw.conf"
242+
fi
243+
if grep -q "version=" "/root/pw.conf"; then
244+
sed -i "s/version=.*/version=$version/" "/root/pw.conf"
245+
else
246+
echo -e "version=$version" >> "/root/pw.conf"
247+
fi
248+
if grep -q "timeout=" "/root/pw.conf"; then
249+
sed -i "s/timeout=.*/timeout=$timeout/" "/root/pw.conf"
250+
else
251+
echo -e "timeout=$timeout" >> "/root/pw.conf"
252+
fi
253+
if grep -q "stage1=" "/root/pw.conf"; then
254+
sed -i "/stage1=.*/d" "/root/pw.conf"
255+
echo -e "stage1=$stage1" >> "/root/pw.conf"
256+
fi
257+
if grep -q "stage2=" "/root/pw.conf"; then
258+
sed -i "/stage2=.*/d" "/root/pw.conf"
259+
echo -e "stage2=$stage2" >> "/root/pw.conf"
260+
fi
261+
else
262+
echo -e "interface=$adapter" > /root/pw.conf
263+
echo -e "version=$version" >> /root/pw.conf
264+
echo -e "timeout=$timeout" >> /root/pw.conf
265+
echo -e "stage1=$stage1" >> /root/pw.conf
266+
echo -e "stage2=$stage2" >> /root/pw.conf
250267
fi
251268

252269
chmod +x /etc/rc.local

www/pppwn/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ var appView = Backbone.View.extend({
104104
task:task,
105105
token:'token_id',
106106
root:this.inputRoot.val(),
107+
stage1:this.stage1[this.inputVersion.val()],
108+
stage2:this.stage2[this.inputVersion.val()],
109+
timeout:this.inputTimeout.val(),
107110
adapter:this.inputAdapter.val(),
108111
version:this.inputVersion.val()
109112
}

0 commit comments

Comments
 (0)