-
Notifications
You must be signed in to change notification settings - Fork 5
/
installer.sh
297 lines (249 loc) · 7.79 KB
/
installer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#!/bin/sh /etc/rc.common
if [ -f /etc/config/pppoe ]; then
rm -r /etc/config/pppoe
fi
if [ -f /etc/config/pw ]; then
rm -r /etc/config/pw
fi
if [ -f /etc/init.d/pppoe-server ]; then
rm -r /etc/init.d/pppoe-server
fi
if [ -f /etc/init.d/pw ]; then
rm -r /etc/init.d/pw
fi
if [ -f /etc/ppp/chap-secrets ]; then
rm -f /etc/ppp/chap-secrets
fi
if [ -f /etc/ppp/pap-secrets ]; then
rm -f /etc/ppp/pap-secrets
fi
if [ -f /etc/ppp/pppoe-server-options ]; then
rm -f /etc/ppp/pppoe-server-options
fi
if [ -f /tmp/main.zip ]; then
rm -r /tmp/main.zip
fi
if [ -d /root/offsets ]; then
rm -r /root/offsets
fi
if [ -d /root/stage1 ]; then
rm -r /root/stage1
fi
if [ -d /root/stage2 ]; then
rm -r /root/stage2
fi
if [ -d /www/assets ]; then
rm -r /www/assets
fi
if [ -f /www/cgi-bin/pw.cgi ]; then
rm /www/cgi-bin/pw.cgi
fi
if [ -f /www/pppwn.html ]; then
rm /www/pppwn.html
fi
if [ -f /root/pw.conf ]; then
rm /root/pw.conf
fi
if [ -f /root/version ]; then
rm /root/version
fi
if [ -f /root/run.sh ]; then
rm /root/run.sh
fi
installer_setup(){
dir_root=""
if [ "$1" = "download" ]; then
dir_root="/tmp/PPPwn_ow-main/"
wget -O /tmp/main.zip https://github.com/CodeInvers3/PPPwn_ow/archive/refs/heads/main.zip
unzip /tmp/main.zip -d /tmp
rm /tmp/main.zip
fi
echo "Confirm installation type."
read -p "Complete installacion? y/n: " optyn
if [ "$optyn" = "y" ]; then
if [ "$1" = "offline" ]; then
if [ -f rp-pppoe-common*.ipk ]; then
opkg install rp-pppoe-common*.ipk
fi
if [ -f rp-pppoe-server*.ipk ]; then
opkg install rp-pppoe-server*.ipk
fi
fi
if [ "$1" = "download" ]; then
if ! command -v pppoe-server >/dev/null 2>&1; then
opkg update
opkg install rp-pppoe-common
opkg install rp-pppoe-server
fi
fi
mv -f ${dir_root}etc/config/pw /etc/config
mv -f ${dir_root}etc/config/pppoe /etc/config
mv -f ${dir_root}etc/init.d/pppoe-server /etc/init.d
mv -f ${dir_root}etc/ppp/pap-secrets /etc/ppp
mv -f ${dir_root}etc/ppp/chap-secrets /etc/ppp
mv -f ${dir_root}etc/ppp/pppoe-server-options /etc/ppp
mv -f ${dir_root}www/cgi-bin/pw.cgi /www/cgi-bin/
mv -f ${dir_root}www/pppwn.html /www/
mv -f ${dir_root}www/assets /www/
chmod +x /etc/init.d/pppoe-server /www/cgi-bin/pw.cgi
uci del_list firewall.@zone[0].device='ppp+'
uci add_list firewall.@zone[0].device='ppp+'
uci set firewall.@zone[1].input='ACCEPT'
uci commit firewall
/etc/init.d/pppoe-server enable
/etc/init.d/pppoe-server start
else
mtype=$(uname -m)
echo "Download PPPWN that is compatible with your chip."
echo "Your machine type: $mtype"
echo "1) aarch64-linux-musl"
echo "2) arm-linux-musleabi(cortex_a7)"
echo "3) arm-linux-musleabi(pi_zero_w)"
echo "4) arm-linux-musleabi(mpcorenovfp)"
echo "5) x86_64-linux-musl"
echo "6) mipsel-linux-musl"
echo "7) mips-linux-musl"
while true; do
read -p "Select a option: " optdwn
case $optdwn in
1)
repo_ref="https://raw.githubusercontent.com/CodeInvers3/codeinvers3.github.io/master/custom/stored/aarch64-linux-musl.tar.gz"
break
;;
2)
repo_ref="https://raw.githubusercontent.com/CodeInvers3/codeinvers3.github.io/master/custom/stored/arm-linux-musleabi(cortex_a7).tar.gz"
break
;;
3)
repo_ref="https://raw.githubusercontent.com/CodeInvers3/codeinvers3.github.io/master/custom/stored/arm-linux-musleabi(pi_zero_w).tar.gz"
break
;;
4)
repo_ref="https://raw.githubusercontent.com/CodeInvers3/codeinvers3.github.io/master/custom/stored/arm-linux-musleabi(mpcorenovfp).tar.gz"
break
;;
5)
repo_ref="https://raw.githubusercontent.com/CodeInvers3/codeinvers3.github.io/master/custom/stored/x86_64-linux-musl.tar.gz"
break
;;
6)
repo_ref="https://raw.githubusercontent.com/CodeInvers3/codeinvers3.github.io/master/custom/stored/mipsel-linux-musl.tar.gz"
break
;;
7)
repo_ref="https://raw.githubusercontent.com/CodeInvers3/codeinvers3.github.io/master/custom/stored/mips-linux-musl.tar.gz"
break
;;
*)
echo "Invalid selection, retry again."
;;
esac
done
echo "Select ethernet connection"
echo "1) eth0"
echo "2) br-lan"
read -p "Select option: " opt1
case $opt1 in
1)
adapter="eth0"
;;
2)
adapter="br-lan"
;;
*)
adapter="br-lan"
;;
esac
echo "Set firmware version"
echo "1) 9.00"
echo "2) 9.50"
echo "3) 9.51"
echo "4) 9.60"
echo "5) 10.00"
echo "6) 10.01"
echo "7) 11.00"
read -p "Select option: " opt2
case $opt2 in
1)
version=900
;;
2)
version=950
;;
3)
version=951
;;
4)
version=960
;;
5)
version=1000
;;
6)
version=1001
;;
7)
version=1100
;;
*)
version=1100
;;
esac
read -p "Set timeout 0 to 60 (default 0): " timeout
if [ -z "$timeout" ]; then
timeout=0
fi
wget -O ${dir_root}pppwn.tar.gz $repo_ref
tar -xvzf ${dir_root}pppwn.tar.gz -C $dir_root
rm ${dir_root}pppwn.tar.gz
mv -f ${dir_root}etc/config/pw /etc/config
uci set pw.@params[0].interface="$adapter"
uci set pw.@params[0].version="$version"
uci set pw.@params[0].timeout="$timeout"
uci set pw.@params[0].stage1="/root/stage1/$version.bin"
uci set pw.@params[0].stage2="/root/stage2/$version.bin"
uci commit pw
fi
if [ -f ${dir_root}pppwn ]; then
mv -f ${dir_root}pppwn /usr/sbin
chmod +x /usr/sbin/pppwn
fi
mv -f ${dir_root}etc/init.d/pw /etc/init.d
mv -f ${dir_root}version /root
mv -f ${dir_root}stage1 /root
mv -f ${dir_root}stage2 /root
chmod +x /etc/init.d/pw
if [ "$optyn" = "n" ]; then
/etc/init.d/pw enable
fi
if [ "$1" = "offline" ]; then
if [ -d /root/PPPwn_ow ]; then
rm -rf /root/PPPwn_ow
fi
if [ -d /root/PPPwn_ow-main ]; then
rm -rf /root/PPPwn_ow-main
fi
fi
if [ "$1" = "download" ]; then
rm /tmp/installer.sh
if [ -d /tmp/PPPwn_ow-main ]; then
rm -r /tmp/PPPwn_ow-main
fi
fi
echo "PPPwn web is hosted at http://ip_address/pppwn.html"
echo "--- INSTALLATION COMPLETED! ---"
exit 0
break
}
echo "PPPwn installer"
echo "The complete installation includes settings from a web interface."
echo "the minimal installation only includes the necessary executables."
if ping -c 1 www.google.com >/dev/null 2>&1; then
if [ -f /tmp/installer.sh ]; then
installer_setup "download"
else
installer_setup "offline"
fi
else
installer_setup "offline"
fi