#! /bin/sh

### BEGIN INIT INFO
# Provides:		sshpiperd	
# Required-Start:	$remote_fs $syslog
# Required-Stop:	$remote_fs $syslog
# Default-Start:	2 3 4 5
# Default-Stop:		0 1 6
# Short-Description:	Username based SSH Reverse Proxy
### END INIT INFO

. /lib/lsb/init-functions

SSHPIPERD_BIN=/usr/local/bin/sshpiperd
SSHPIPERD_PID=/var/run/sshpiperd.pid

touch $SSHPIPERD_PID

case "$1" in
	start)
		log_begin_msg "Starting SSHPiperd"
		start-stop-daemon --start --background \
			--exec "$SSHPIPERD_BIN" \
			--pidfile "$SSHPIPERD_PID" --make-pidfile
		log_end_msg $?
		;;

	stop)
		log_begin_msg "Stopping SSHPiperd"
		start-stop-daemon --stop --pidfile "$SSHPIPERD_PID"
		log_end_msg $?
		;;

	restart)
		$0 stop
		$0 start
		;;

	status)
		status_of_proc -p "$SSHPIPERD_PID" "$SSHPIPERD_BIN" "SSHPiperd"
		;;

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