-
Notifications
You must be signed in to change notification settings - Fork 0
/
urt-service
executable file
·60 lines (55 loc) · 1.02 KB
/
urt-service
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
#!/bin/sh
if [ ! "$SCRIPT" ]; then
exit 1;
fi
PIDFILE=/tmp/$SCRIPT.pid
SCREEN=$SCRIPT
start() {
if [ -f $PIDFILE ]; then
echo "Service $NAME already running"
else
echo -n "Starting $NAME... "
su "$USER" -s /bin/bash -c "
cd \"$DIR\" && \
screen -S $SCREEN -X echo Race || \
screen -T linux -h 10000 -UOa -dmS $SCREEN \"$DIR/$SCRIPT\" && \
screen -S $SCREEN -X termcapinfo xterm* ti@:te@ && \
screen -S $SCREEN -X multiuser on && \
screen -S $SCREEN -X acladd root
" && echo "OK"
fi
}
stop() {
if [ -f $PIDFILE ]; then
echo -n "Stopping $NAME... "
PID=$(cat $PIDFILE)
rm $PIDFILE
kill $PID
wait $PID
echo "OK"
else
echo "Service $NAME already stopped"
fi
}
restart() {
stop
sleep 4
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
status)
[ -f $PIDFILE ] && echo "$NAME is running." || echo "$NAME is stopped."
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
esac
exit $?