summaryrefslogtreecommitdiff
path: root/init.d/tcp-proxy.sh
diff options
context:
space:
mode:
Diffstat (limited to 'init.d/tcp-proxy.sh')
-rwxr-xr-xinit.d/tcp-proxy.sh52
1 files changed, 52 insertions, 0 deletions
diff --git a/init.d/tcp-proxy.sh b/init.d/tcp-proxy.sh
new file mode 100755
index 0000000..d3326f4
--- /dev/null
+++ b/init.d/tcp-proxy.sh
@@ -0,0 +1,52 @@
+#! /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