Last active
July 28, 2016 20:15
-
-
Save mzsanford/27d28d71750edb95f485 to your computer and use it in GitHub Desktop.
Init script and defaults file for etcd on Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set the pper listening address | |
# export ETCD_PEER_ADDR=127.0.0.1:7001 | |
# Set other command line options like the name and discovery url | |
# from https://discovery.etcd.io/new | |
# export ETCD_OPTS="-name=name_here -discovery=https://discovery.etcd.io/token_here" | |
export ETCD_OPTS="" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: etcd | |
# Required-Start: $network $remote_fs $syslog | |
# Required-Stop: $network $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 1 | |
# Short-Description: Start etcd daemon | |
### END INIT INFO | |
PATH=/sbin:/bin:/usr/sbin:/usr/bin | |
. /lib/lsb/init-functions | |
prog="etcd" | |
prog_bin="/usr/local/bin/$prog" | |
pidfile=/var/run/$prog.pid | |
desc="etcd shared configuration and service discovery daemon" | |
if ! [ -f $prog_bin ]; then | |
echo "$prog binary not found." | |
exit 5 | |
fi | |
if [ -r /etc/default/$prog ]; then | |
. /etc/default/$prog | |
fi | |
start() { | |
log_daemon_msg "Starting etcd server" "$prog" | |
start-stop-daemon --start --quiet --oknodo --background --pidfile $pidfile --make-pidfile --exec $prog_bin -- $ETCD_OPTS | |
status=$? | |
log_end_msg $status | |
} | |
stop() { | |
log_begin_msg "Stopping etcd server" | |
start-stop-daemon --stop --pidfile "$pidfile" | |
status=$? | |
if [ -f $pidfile ]; then | |
rm $pidfile | |
fi | |
log_end_msg $status | |
} | |
restart() { | |
stop | |
start | |
} | |
status() { | |
status_of_proc -p "$pidfile" "$prog_bin" etcd | |
} | |
case "$1" in | |
start) start;; | |
stop) stop;; | |
restart) restart;; | |
status) status;; | |
*) echo "Usage: $0 {start|stop|restart|status}" | |
RETVAL=2;; | |
esac | |
exit $RETVAL |
The first line of "defaults" has a typo: pper
-> peer
Shouldn't status=$?
be RETVAL=$?
?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks for the code snippet