forked from lotaku/Python-GoogleDrive-VideoStream
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vs-server.sh
executable file
·59 lines (53 loc) · 1.04 KB
/
vs-server.sh
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
#!/bin/sh
NAME=Python-GDrive-Videostream
PIDFILE=$PWD/$NAME.pid
LOGFILE=$PWD/logs/$NAME.log
COMMAND="/usr/bin/python2 ${PWD}/default.py"
start() {
if [ -e $PIDFILE ]; then
printf "\n${NAME} already running with PID $(cat $PIDFILE).\n"
exit
fi
if [ ! -d $PWD/logs ]
then mkdir $PWD/logs
fi
if [ -e $LOGFILE ]; then
if [ -e $LOGFILE.bck ]
then rm $LOGFILE.bck
fi
mv $LOGFILE $LOGFILE.bck
fi
exec $COMMAND > $LOGFILE 2> $LOGFILE.error & echo $! > $PIDFILE
}
stop() {
if [ -e $PIDFILE ]; then
PID=$(cat $PIDFILE)
printf "\n$PID\n"
kill $PID
rm $PIDFILE
else
printf "\nNo running Instance for ${NAME} found.\n"
exit
fi
}
case $1 in
start)
printf "Starting: $NAME\n"
start
;;
stop)
printf "Stopping: $NAME\n"
stop
;;
restart)
printf "Restarting: $NAME\n"
stop
sleep 1
start
;;
*)
echo "usage: $NAME.sh {start|stop|restart}"
exit 1
;;
esac
exit 0