-
Notifications
You must be signed in to change notification settings - Fork 27
/
web-run.sh
67 lines (59 loc) · 1.94 KB
/
web-run.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
#!/bin/sh
read_json() {
local key=$1
awk -F"[,:}]" '/"'$key'"/{gsub(/"/, "", $2); print $2}' $CONFIG_FILE | tr -d ' '
}
# Define the path to the configuration file
CONFIG_FILE="/etc/pppwn/config.json"
# Read configuration values from config.json
FW_VERSION=$(read_json 'FW_VERSION')
TIMEOUT=$(read_json 'TIMEOUT')
WAIT_AFTER_PIN=$(read_json 'WAIT_AFTER_PIN')
GROOM_DELAY=$(read_json 'GROOM_DELAY')
BUFFER_SIZE=$(read_json 'BUFFER_SIZE')
AUTO_RETRY=$(read_json 'AUTO_RETRY')
NO_WAIT_PADI=$(read_json 'NO_WAIT_PADI')
REAL_SLEEP=$(read_json 'REAL_SLEEP')
AUTO_START=$(read_json 'AUTO_START')
HALT_CHOICE=$(read_json 'HALT_CHOICE')
PPPWN_IPV6=$(read_json 'PPPWN_IPV6')
DIR=$(read_json 'install_dir')
LOG_FILE=$(read_json 'log_file')
STAGE1_FILE="$DIR/stage1/${FW_VERSION}/stage1.bin"
STAGE2_FILE="$DIR/stage2/${FW_VERSION}/stage2.bin"
CMD="$DIR/pppwn --interface eth0 --fw $FW_VERSION --stage1 $STAGE1_FILE --stage2 $STAGE2_FILE"
# Append optional parameters
[ "$TIMEOUT" != "null" ] && CMD="$CMD --timeout $TIMEOUT"
[ "$WAIT_AFTER_PIN" != "null" ] && CMD="$CMD --wait-after-pin $WAIT_AFTER_PIN"
[ "$GROOM_DELAY" != "null" ] && CMD="$CMD --groom-delay $GROOM_DELAY"
[ "$BUFFER_SIZE" != "null" ] && CMD="$CMD --buffer-size $BUFFER_SIZE"
[ "$AUTO_RETRY" == "true" ] && CMD="$CMD --auto-retry"
[ "$NO_WAIT_PADI" == "true" ] && CMD="$CMD --no-wait-padi"
[ "$REAL_SLEEP" == "true" ] && CMD="$CMD --real-sleep"
[ "$PPPWN_IPV6" != "true" ] && CMD="$CMD --old-ipv6"
reseteth() {
ifconfig eth0 down
sleep 1
ifconfig eth0 up
sleep 3
}
killall nginx
killall php-fpm
killall pppoe-server
>$LOG_FILE
sleep 1
reseteth
$CMD >>$LOG_FILE 2>&1
if grep -q "\[+\] Done!" $LOG_FILE; then
if [ "$HALT_CHOICE" = "true" ]; then
sleep 1
halt
else
sleep 5
reseteth
pppoe-server -I eth0 -T 60 -N 1 -C isp -S isp -L 192.168.1.1 -R 192.168.1.2 &
sleep 5
/etc/init.d/S50nginx start
/etc/init.d/S49php-fpm start
fi
fi