-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathinit
executable file
·132 lines (121 loc) · 2.58 KB
/
init
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
#!/bin/sh
CURDIR=$(cd $(dirname $0) && pwd)
CONFIDR="$CURDIR/conf"
PACKAGEID="com.modouwifi.vpnss"
TODNSMASQCONF="/data/conf/dns/ss-vpn-dnsmasq.conf"
# to tp
TO_TP_TITLE="SS-VPN"
TO_TP_CONF_DIR="/data/conf/launcher/conf.d"
TO_TP_CONF_FILE="$TO_TP_CONF_DIR/ss.conf"
TO_TP_ICON="$CURDIR/res/icon.png"
TO_TP_PRESSED_ICON="$CURDIR/res/picon.png"
usage()
{
echo "ERROR: action missing"
echo "syntax: $0 <start|stop|restart|status|config|install|uninstall>"
echo "example: $0 start"
}
install()
{
# to tp
if [ ! -d $TO_TP_CONF_DIR ]; then
mkdir -p $TO_TP_CONF_DIR
fi
echo "{" > "$TO_TP_CONF_FILE"
echo "\"name\" : \"$TO_TP_TITLE\"," >> "$TO_TP_CONF_FILE"
echo "\"icon\" : \"$TO_TP_ICON\"," >> "$TO_TP_CONF_FILE"
echo "\"iconPressed\" : \"$TO_TP_PRESSED_ICON\"," >> "$TO_TP_CONF_FILE"
echo "\"exec\" : \"$CURDIR/sbin/ss.sh tpstart\"," >> "$TO_TP_CONF_FILE"
echo "\"msgNum\" : 4" >> "$TO_TP_CONF_FILE"
echo "}" >> "$TO_TP_CONF_FILE"
/system/sbin/appInfo.sh set_status $PACKAGEID NOTRUNNING
#ln -s $CURDIR/lib/libgcc_s.so.1 /lib/libgcc_s.so.1 2>/dev/null
return 0;
}
uninstall()
{
#rm /lib/libgcc_s.so.1 2>/dev/null
rm $TODNSMASQCONF 2>/dev/null
rm $TO_TP_CONF_FILE
echo "uninstall";
return 0;
}
stop()
{
$CURDIR/sbin/ss.sh stop
/system/sbin/appInfo.sh set_status $PACKAGEID NOTRUNNING
return 0;
}
start()
{
$CURDIR/sbin/ss.sh start
/system/sbin/appInfo.sh set_status $PACKAGEID ISRUNNING
return 0;
}
status()
{
echo "Hello, modou";
return 0;
}
set_config()
{
$CURDIR/sbin/ss.sh syncConfig
$CURDIR/sbin/ss.sh stop
$CURDIR/sbin/ss.sh start
/system/sbin/appInfo.sh set_status $PACKAGEID ISRUNNING
return 0;
}
# main
if [ $# -lt 1 ]; then
usage init
exit 1
fi
case "$1" in
"stop")
stop;
if [ "0" != "$?" ]; then
exit 1;
fi
exit 0;
;;
"start")
start;
if [ "0" != "$?" ]; then
exit 1;
fi
exit 0;
;;
"status")
status;
if [ "0" != "$?" ]; then
exit 1;
fi
exit 0;
;;
"set_config")
set_config;
if [ "0" != "$?" ]; then
exit 1;
fi
exit 0;
;;
"install")
install;
if [ "0" != "$?" ]; then
exit 1;
fi
exit 0;
;;
"uninstall")
stop;
uninstall;
if [ "0" != "$?" ]; then
exit 1;
fi
exit 0;
;;
*)
usage init;
exit 1;
;;
esac