forked from scriptsboy/telegram-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
proxy-sysv
executable file
·68 lines (46 loc) · 1.3 KB
/
proxy-sysv
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
#!/bin/bash
### BEGIN INIT INFO
# Provides: proxy
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the proxy
# Description: starts proxy using start-stop-daemon
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
#Loading configuration variables
. /etc/proxy/proxy.conf || exit 1
#Init script
start_proxy() {
#Starting Proxy
STDE=`which start-stop-daemon`
if [ ! -z "$STDE" ]; then
start-stop-daemon --start --quiet --chuid proxy --exec /usr/bin/proxy sps -- --daemon -t tcp -p ":$SPORT" -A "$SUSER:$SPASS"
else
su -s /bin/sh -c 'exec "$0" "$@"' proxy -- /usr/bin/proxy sps -- --daemon -t tcp -p ":$SPORT" -A "$SUSER:$SPASS"
fi
}
stop_proxy() {
PROXY_PID=`pgrep -f proxy.*socks`
if [ ! -z $PROXY_PID ]; then
kill -9 $PROXY_PID;
fi
sleep 3
}
case "$1" in
start)
start_proxy
;;
stop)
stop_proxy
;;
restart)
stop_proxy
start_proxy
;;
*)
echo "Usage: /etc/init.d/proxy {start|stop|restart}" >&2
exit 3
;;
esac