Skip to content

Instantly share code, notes, and snippets.

@aputs
Last active November 21, 2017 14:07
Show Gist options
  • Save aputs/1daff678838441b5195d to your computer and use it in GitHub Desktop.
Save aputs/1daff678838441b5195d to your computer and use it in GitHub Desktop.

Revisions

  1. aputs revised this gist May 5, 2014. 1 changed file with 3 additions and 6 deletions.
    9 changes: 3 additions & 6 deletions etcd centos init.d script
    Original file line number Diff line number Diff line change
    @@ -27,14 +27,11 @@ start() {
    [[ $started =~ running ]] && echo $started && return 1

    echo -n $"Starting $prog: "
    daemon --user etcd $ETCD_EXEC 3>&1 2>&1 1>&$ETCD_LOGFILE &
    $ETCD_EXEC 3>&1 2>&1 1>&$ETCD_LOGFILE &
    RETVAL=$?
    echo $! > $ETCD_PIDFILE
    [[ $RETVAL ]] && success || failure
    echo
    [ $RETVAL -eq 0 ] && {
    pidof $ETCD_BIN > $ETCD_PIDFILE
    touch "$ETCD_LOCKFILE"
    }
    [[ $RETVAL ]] && touch "$ETCD_LOCKFILE"
    return $RETVAL
    }

  2. aputs created this gist May 5, 2014.
    76 changes: 76 additions & 0 deletions etcd centos init.d script
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,76 @@
    #!/bin/bash
    # Startup script for etcd
    #
    # chkconfig: 2345 20 80
    # description: Starts and stops etcd

    . /etc/init.d/functions

    prog="etcd"
    ETCD_BIN=$(which etcd 2> /dev/null)
    prog=$(basename "$ETCD_BIN")
    desc="etcd shared configuration and service discovery daemon"

    if [[ ! -e $ETCD_BIN ]]; then
    echo "$prog binary not found."
    exit 5
    fi

    ETCD_LOCKFILE="/var/lock/subsys/$prog"
    ETCD_LOGFILE=/var/log/etcd/etcd.log
    ETCD_PIDFILE=/var/run/etcd.pid
    ETCD_CONFIG=/etc/etcd.conf
    ETCD_EXEC="$ETCD_BIN -config $ETCD_CONFIG"

    start() {
    started=$(status -p "$ETCD_PIDFILE" "$ETCD_BIN")
    [[ $started =~ running ]] && echo $started && return 1

    echo -n $"Starting $prog: "
    daemon --user etcd $ETCD_EXEC 3>&1 2>&1 1>&$ETCD_LOGFILE &
    RETVAL=$?
    [[ $RETVAL ]] && success || failure
    echo
    [ $RETVAL -eq 0 ] && {
    pidof $ETCD_BIN > $ETCD_PIDFILE
    touch "$ETCD_LOCKFILE"
    }
    return $RETVAL
    }

    stop() {
    echo -n $"Stopping $prog: "
    killproc -p "$ETCD_PIDFILE" "$ETCD_BIN"

    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -fr "$ETCD_LOCKFILE"
    return $RETVAL
    }

    case $1 in
    start)
    start
    ;;

    stop)
    stop
    ;;

    restart)
    stop
    start
    ;;

    status)
    status "$ETCD_BIN"
    RETVAL=$?
    ;;

    *)
    echo "Usage: $0 {start|stop|restart|status}"
    RETVAL=1
    ;;
    esac

    exit $RETVAL