forked from nmilford/rpm-etcd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
etcd.initd
80 lines (69 loc) · 1.66 KB
/
etcd.initd
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
#!/bin/bash
# Copyright 2013, Nathan Milford
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# /etc/init.d/etcd
#
# Startup script for etcd
#
# chkconfig: 2345 20 80
# description: Starts and stops etcd
. /etc/init.d/functions
prog="etcd"
prog_bin="/usr/sbin/$prog"
desc="etcd shared configuration and service discovery daemon"
if ! [ -f $prog_bin ]; then
echo "$prog binary not found."
exit 5
fi
if [ -f /etc/sysconfig/$prog ]; then
. /etc/sysconfig/$prog
else
echo "No sysconfig file found in /etc/sysconfig/$prog... exiting."
exit 5
fi
start() {
echo "Starting $desc ($prog): "
su $ETCD_USER -c "nohup $prog_bin $ETCD_OPTS -v >>$ETCD_OUT_FILE 2>&1 &"
RETVAL=$?
return $RETVAL
}
stop() {
echo "Shutting down $desc ($prog): "
pkill -f $prog_bin
}
restart() {
stop
start
}
status() {
if [ -z $pid ]; then
pid=$(pgrep -f $prog_bin)
fi
if [ -z $pid ]; then
echo "$prog is NOT running."
return 1
else
echo "$prog is running (pid is $pid)."
fi
}
case "$1" in
start) start;;
stop) stop;;
restart) restart;;
status) status;;
*) echo "Usage: $0 {start|stop|restart|status}"
RETVAL=2;;
esac
exit $RETVAL