-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathweb-run.sh
58 lines (51 loc) · 1.98 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
#!/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_EXEC=$(read_json 'PPPWN_EXEC')
GOLD_CHECK=$(read_json 'GOLD_CHECK')
DIR=$(read_json 'install_dir')
LOG_FILE=$(read_json 'log_file')
# Construct file paths and command
STAGE1_FILE="$DIR/stage1/${FW_VERSION}/stage1.bin"
STAGE2_FILE="$DIR/stage2/${FW_VERSION}/stage2.bin"
CMD="$DIR/$PPPWN_EXEC --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"
# Utility functions
reset_eth() { ifconfig eth0 down; sleep 1; ifconfig eth0 up; sleep 1; }
pppoe_up() { pppoe-server -I eth0 -T 60 -N 1 -C isp -S isp -L 10.1.1.1 -R 10.1.1.2 & }
killall nginx
killall php-fpm
killall pppoe-server
>$LOG_FILE
reseteth
$CMD >>$LOG_FILE 2>&1
if grep -q "\[+\] Done!" $LOG_FILE; then
echo "PPPwned"
[ "$HALT_CHOICE" = "true" ] && { ifconfig eth0 down; sleep 1; halt; } || {
reset_eth; pppoe_up
/etc/init.d/S50nginx start
/etc/init.d/S49php-fpm start
}
fi