This repository has been archived by the owner on Dec 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
mcprovision.init
executable file
·126 lines (113 loc) · 2.35 KB
/
mcprovision.init
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/sh
#
# mcprovision Server Provisioner for The Marionette Collective
#
# chkconfig: 345 24 76
#
# description: Automated the provisioning of servers
#
### BEGIN INIT INFO
# Provides: mcprovision
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
mcprovision="/usr/sbin/mcprovision"
pidfile="/var/run/mcprovision.pid"
# Lockfile
if [ -d /var/lock/subsys ]; then
# RedHat/CentOS/etc who use subsys
lock="/var/lock/subsys/mcprovision"
else
# The rest of them
lock="/var/lock/mcprovision"
fi
# Source function library.
. /etc/init.d/functions
# Load options, set things like PSK's and SSL keys in here
if [ -f /etc/sysconfig/mcprovision ]; then
. /etc/sysconfig/mcprovision
fi
# Check that binary exists
if ! [ -f $mcprovision ]
then
echo "$mcprovision binary not found"
exit 0
fi
# See how we were called.
case "$1" in
start)
echo -n "Starting mcprovision: "
if [ -f ${lock} ]; then
# we were not shut down correctly
if [ -s ${pidfile} ]; then
kill `cat ${pidfile}` >/dev/null 2>&1
fi
rm -f ${pidfile}
rm -f ${lock}
sleep 2
fi
rm -f ${pidfile}
${mcprovision} /etc/mcollective/mcprovision.yaml
if [ $? = 0 ]; then
success $"mcprovision"
touch $lock
echo
exit 0
else
failure
echo
exit 1
fi
;;
stop)
echo -n "Shutting down mcprovision: "
if [ -s ${pidfile} ]; then
kill `cat ${pidfile}` >/dev/null 2>&1
fi
rm -f ${pidfile}
success $"mcprovision"
rm -f $lock
echo
;;
restart)
$0 stop
sleep 2
$0 start
;;
condrestart)
if [ -f $lock ]; then
$0 stop
# avoid race
sleep 2
$0 start
fi
;;
status)
if [ -f ${lock} ]; then
if [ -s ${pidfile} ]; then
if [ -e /proc/`cat ${pidfile}` ]; then
echo "mcprovision (`cat ${pidfile}`) is running"
exit 0
else
echo "mcprovision (`cat ${pidfile}`) is NOT running"
exit 1
fi
fi
else
echo "mcprovision: service not started"
exit 1
fi
;;
force-reload)
echo "not implemented"
;;
*)
echo "Usage: mcprovision {start|stop|restart|condrestart|status}"
exit 1
;;
esac
exit 0