forked from L4nz/ocelot
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathocelotctl
48 lines (44 loc) · 1.57 KB
/
ocelotctl
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
#
# Ocelot control script. Pretty simple.
#
PID=`pgrep ocelot`;
if [ "$(id -u)" != "0" ]; then
echo "Usage: ocelotctl [start|stop|restart|status]";
echo " Used to control the Ocelot tracker.";
echo " This script must be run as root or with sudo" 1>&2;
exit 1
fi
case $1 in
"start") if [ "$(pgrep ocelot)" ]
then
echo "Ocelot is allready running with PID: "$PID;
else
/home/tracker/ocelot/ocelot >> /home/tracker/ocelot.log &
echo "Ocelot started."
fi;;
"stop") if [ "$(pgrep ocelot)" ]
then
kill $PID;
echo "Ocelot stopped.";
else
echo "Ocelot is not running.";
fi;;
"restart") echo "Restarting Ocelot.";
kill $PID;
while pgrep ocelot
do
echo "Waiting for process to stop."
sleep 1;
done
/home/tracker/ocelot/ocelot >> /home/tracker/ocelot.log &
echo "Restarted Ocelot";;
"status") if [ "$(pgrep ocelot)" ]
then
echo "Ocelot is running. ("$PID")";
else
echo "Ocelot is not running.";
fi;;
*) echo "Usage: ocelotctl [start|stop|restart|status]";
echo " Used to control the Ocelot tracker.";;
esac
exit 0