-
Notifications
You must be signed in to change notification settings - Fork 6
/
margarita
executable file
·95 lines (87 loc) · 1.46 KB
/
margarita
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
#!/bin/bash
#
# Author: Riley Shott (https://github.com/Ginja/Admin_Scripts)
#
# margarita Startup script for the maragita webinterface
#
# chkconfig: 356 90 20
# description: Margarita is a web front-end to reposado
# the Apple Software Update replication and
# catalog management tool. This script has only been tested
# on RHEL 6, and would need modification before use on a Debian
# flavour of Linux.
# Source function library
. /etc/rc.d/init.d/functions
# Variables
PID=$(ps aux | grep "[p]ython /var/www/margarita/margarita.py" | awk '{print $2}')
RETVAL=0
# Methods
start()
{
echo -n "Starting margarita: "
if [ -z $PID ]; then
python /var/www/margarita/margarita.py -b ip_address_here &> /var/log/margarita.log &
RETVAL=$?
if [ $RETVAL -eq 0 ]
then success
else failure
fi
echo
return $RETVAL
else
failure
RETVAL=1
echo "Margarita already running: "
return $RETVAL
fi
}
stop()
{
echo -n "Stopping margarita: "
if [ $PID ]; then
kill $PID
RETVAL=$?
if [ $RETVAL -eq 0 ]
then success
else failure
fi
PID=""
echo
return $RETVAL
else
failure
RETVAL=1
echo "Margarita wasn't running: "
return $RETVAL
fi
}
status()
{
if [ $PID ]; then
echo "Margarita is running"
exit 0
else
echo "Margarita isn't running"
exit 1
fi
}
# Punch it
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac
exit $RETVAL