This repository was archived by the owner on May 29, 2024. It is now read-only.
forked from Z446C/ESC-Z
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesfshell
More file actions
89 lines (79 loc) · 2.48 KB
/
esfshell
File metadata and controls
89 lines (79 loc) · 2.48 KB
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
#!/bin/sh /etc/rc.common
NAME=EsurfingShell
DESCRIPTION="EsurfingShell Daemon."
USE_PROCD=1
START=99
config_esfshell_start() {
config_get_bool enabled $1 enabled 0
config_get username $1 username
config_get password $1 password
[ "$enabled" = "1" ] || { return 1; }
[ -n "$username" ] || { return 1; }
[ -n "$password" ] || { return 1; }
config_get interface $1 interface
config_get_bool verbose $1 verbose 0
if [ "$verbose" = 1 ]; then
verbose="true"
elif [ "$verbose" = 0 ]; then
verbose="false"
fi
config_get env $1 env
if [ "$(echo "$interface" | cut -c1)" = "@" ]; then
device=$(uci get "network.$(echo "$interface" | cut -c2-).device")
ifalias=$(echo "$interface" | cut -c2-)
else
device=$interface
ifalias=""
fi
procd_open_instance "esfshell_${1}"
procd_set_param respawn
procd_set_param env _ES_ACC_USERNAME="$username" _ES_ACC_PASSWD="$password" _ES_GLOBAL_DEVICE="$device" _ES_OPENWRT_DEVICE_ALIAS="$ifalias" _ES_HOMEPATH="/etc/esfshell/$interface" _ES_VERBOSE="$verbose" $env
procd_set_param command /usr/bin/esfshell -D
procd_set_param stdout 1
procd_close_instance
}
config_esfshell_stop() {
config_get_bool enabled $1 enabled 0
config_get username $1 username
config_get password $1 password
[ "$enabled" = "1" ] || { return 1; }
[ -n "$username" ] || { return 1; }
[ -n "$password" ] || { return 1; }
config_get interface $1 interface
config_get_bool verbose $1 verbose 0
if [ "$verbose" = 1 ]; then
verbose="true"
elif [ "$verbose" = 0 ]; then
verbose="false"
fi
config_get env $1 env
if [ "$(echo "$interface" | cut -c1)" = "@" ]; then
device=$(uci get "network.$(echo "$interface" | cut -c2-).device")
ifalias=$(echo "$interface" | cut -c2-)
else
device=$interface
ifalias=""
fi
export _ES_ACC_USERNAME="$username"
export _ES_ACC_PASSWD="$password"
export _ES_GLOBAL_DEVICE="$device"
export _ES_OPENWRT_DEVICE_ALIAS="$ifalias"
export _ES_HOMEPATH="/etc/esfshell/$interface"
export _ES_FORCE=true
export _ES_VERBOSE="$verbose"
for ex_env in $env; do
export $ex_env
done
/usr/bin/esfshell -O
}
start_service() {
config_load esfshell
config_foreach config_esfshell_start
}
service_stopped() {
config_load esfshell
config_foreach config_esfshell_stop
}
service_triggers() {
procd_add_reload_trigger "esfshell"
}