#!/bin/sh
# Startup script for sshlink daemon

NAME="sshlink"
DAEMON="/usr/bin/$NAME"
PIDFILE="/var/run/$NAME.pid"
CONFFILE="/etc/$NAME.conf"
OPTIONS="--configuration-file $CONFFILE --pidfile $PIDFILE --background"
	
case "$1" in
	start)
		echo -n "Starting $NAME: "
		if $DAEMON $OPTIONS; then
			echo "done"
		else echo "failed"; fi
		;;
	
	stop)
		echo -n "Stopping $NAME: "
		if cat $PIDFILE 2>/dev/null | xargs -r kill; then
			echo "done"
		else echo "failed"; fi
		rm -f $PIDFILE
		;;	
	
	restart|force-restart)
		$0 stop
		$0 start
		;;
	
	*)
		echo "Usage: $NAME.sh {start|stop|restart|force-restart}"
		exit 1
esac

exit 0
