#! /bin/sh
#
### BEGIN INIT INFO
# Provides:          sshproxy
# Required-Start:    $network
# Required-Stop:     $network
# Should-Start:      $syslog
# Should-Stop:       $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: ssh gateway to apply ACLs on ssh connections
# Description:       sshproxy is a pure python implementation of an ssh proxy.
#                    It allows users to connect to remote sites without having to remember
#                    the password or key of the remote sites.
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/sshproxyd
NAME=sshproxy
DESC=sshproxy

test -x $DAEMON || exit 0

# Include sshproxy defaults if available
if [ -f /etc/default/sshproxy ] ; then
	. /etc/default/sshproxy
fi

if [ "$SSHPROXYD_ENABLED" = "no" ]; then
	echo 'Please set SSHPROXYD_ENABLED="yes" in /etc/default/sshproxy'
	exit 0
fi

set -e

case "$1" in
  start)
	echo -n "Starting $DESC: "
	start-stop-daemon --start --quiet --pidfile /var/run/sshproxyd.pid \
		--exec $DAEMON -- --daemon --user $SSHPROXYD_USER --config-dir $SSHPROXYD_CONFDIR \
		--pid /var/run/sshproxyd.pid
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --quiet --pidfile /var/run/sshproxyd.pid --oknodo
	echo "$NAME."
	;;
  restart|force-reload)
	$0 stop
	$0 start
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0
