-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathxabber_ws.init.example
executable file
·79 lines (69 loc) · 1.72 KB
/
xabber_ws.init.example
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
#! /bin/bash
### BEGIN INIT INFO
# Provides: xabber_ws
# Required-Start: $remote_fs $network $named $time
# Required-Stop: $remote_fs $network $named $time
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts Xabber WebSocket Server
# Description: Starts Xabber WebSocket Server
### END INIT INFO
set -o errexit
DIR=/opt/xabber_websocket_dir
DAEMON="$DIR"/bin/xabber_ws
USER=xabber_websoket_user
test -x "$DAEMON" || {
echo "ERROR: xabber_ws not found: $DIR"
exit 1
}
getent passwd "$USER" >/dev/null || {
echo "ERROR: System user not found: $USER"
exit 2
}
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
case "$1" in
start)
test -x "$DAEMON" || exit 0
printf "%-50s" "Starting Xabber WebSocket Server..."
su - $USER -c "$DAEMON start > /dev/null 2>&1";
# wait for pid
for (( i=0; i<10; ++i )); do
OUT="$DAEMON pid";
if [ $? == 0 ]; then PID=$OUT; break; fi
sleep 1;
done
if [ -z "$PID" ]; then
printf "%s\n" "Fail"
else
printf "%s\n" "Ok"
fi
;;
stop)
test -x "$DAEMON" || exit 0
printf "%-50s" "Stopping Xabber WebSocket Server..."
su - $USER -c "$DAEMON stop > /dev/null 2>&1";
if [ $? != 0 ]; then
printf "%s\n" "Node is not running!"
else
printf "%s\n" "Ok"
fi
;;
status)
test -x "$DAEMON" || exit 0
printf "%-50s" "Checking Xabber WebSocket Server..."
su - $USER -c "$DAEMON pid > /dev/null 2>&1";
if [ $? != 0 ]; then
printf "%s\n" "Node is not running!"
else
printf "%s\n" "Ok"
fi
;;
reload)
"$0" stop
"$0" start
;;
*)
echo "Usage: $0 {start|stop|reload|status}"
exit 1
esac
exit 0