-
Notifications
You must be signed in to change notification settings - Fork 21
/
eturnal.init
executable file
·125 lines (121 loc) · 2.62 KB
/
eturnal.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
#!/bin/sh
### BEGIN INIT INFO
# Provides: eturnal
# Required-Start: $network $remote_fs
# Required-Stop: $network $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start and stop eturnal
# Description: Control the STUN/TURN service provided by eturnal.
### END INIT INFO
name='eturnal'
eturnalctl='{{eturnal_bin_prefix}}/bin/eturnalctl'
PATH='/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin'
export PATH
if [ $# -ne 1 ]
then
echo >&2 "Usage: $0 {start|stop|restart|try-restart|reload|force-reload|status}"
exit 2
fi
if ! [ -x "$eturnalctl" ]
then
if type 'eturnalctl' >'/dev/null'
then
eturnalctl='eturnalctl'
else
echo >&2 "Cannot execute $eturnalctl"
exit 5
fi
fi
case $1 in
start)
if "$eturnalctl" 'status' >'/dev/null'
then
echo "$name is already running."
else
printf "Starting $name ... "
if "$eturnalctl" 'daemon' >'/dev/null'
then
echo 'done.'
else
echo 'FAILED.'
exit 1
fi
fi
;;
stop)
if ! "$eturnalctl" 'status' >'/dev/null'
then
echo "$name is already stopped."
else
printf "Stopping $name ... "
if "$eturnalctl" 'stop' >'/dev/null'
then
echo 'done.'
else
echo 'FAILED.'
exit 1
fi
fi
;;
restart)
if "$eturnalctl" 'status' >'/dev/null'
then
printf "Restarting $name ... "
if "$eturnalctl" 'restart' >'/dev/null'
then
echo 'done.'
else
echo 'FAILED.'
exit 1
fi
else
exec "$0" 'start'
fi
;;
try-restart)
if "$eturnalctl" 'status' >'/dev/null'
then
printf "Restarting $name ... "
if "$eturnalctl" 'restart' >'/dev/null'
then
echo 'done.'
else
echo 'FAILED.'
exit 1
fi
else
echo "$name is NOT running."
fi
;;
reload|force-reload)
if "$eturnalctl" 'status' >'/dev/null'
then
printf "Reloading $name ... "
if "$eturnalctl" 'reload' >'/dev/null'
then
echo 'done.'
else
echo 'FAILED.'
exit 1
fi
else
echo "$name is NOT running."
exit 7
fi
;;
status)
if "$eturnalctl" 'status' >'/dev/null'
then
echo "$name is running."
else
echo "$name is NOT running."
exit 3
fi
;;
*)
echo >&2 "Usage: $0 {start|stop|restart|try-restart|reload|force-reload|status}"
exit 2
;;
esac
exit 0