#! /bin/sh ### BEGIN INIT INFO # Provides: go-tcp-proxy # Required-Start: $local_fs $network # Required-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Starts proxy to access mariadb from kvm guests. # Description: Starts proxy to access mariadb from kvm guests. ### END INIT INFO NAME="go-tcp-proxy" PIDFILE="/var/run/${NAME}.pid" DAEMON="/usr/local/bin/go-tcp-proxy" START_OPTS="--start --background --make-pidfile --pidfile ${PIDFILE} --chuid nobody --exec $DAEMON -- -l -r" END_OPTS="--stop --pidfile ${PIDFILE}" case "$1" in start) echo "Starting $DAEMON" start-stop-daemon $START_OPTS ;; stop) echo "Stopping $NAME" start-stop-daemon $END_OPTS rm -f "${PIDFILE}" ;; restart) echo "Restarting $NAME" "$0" stop sleep 1 "$0" start ;; status) if cat $PIDFILE 1>/dev/null 2>/dev/null; then echo "$NAME is running." else echo "$NAME does not run." fi ;; *) echo "Usage: /etc/init.d/tcp-proxy.sh {start|stop|restart|status}" exit 1 ;; esac exit 0