lshd.debian.init 2.43 KB
Newer Older
Niels Möller's avatar
Niels Möller committed
1 2 3 4 5 6 7 8
#! /bin/sh
#
# Debian style init script to start and stop the lshd daemon.
#
# NOTE: This script is for the default installation of lsh as built
# from the "upstream" source. A proper debian package would use
# somewhat different conventions.
#
Niels Möller's avatar
Niels Möller committed
9
# Written by Niels Möller
Niels Möller's avatar
Niels Möller committed
10 11 12 13 14 15 16 17 18

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/sbin/lshd
NAME=lshd
DESC="secure shell service"

PIDFILE=/var/run/$NAME.pid

# Use this port
Niels Möller's avatar
Niels Möller committed
19
# The default for lshd is whatever is listed in /etc/services.
Niels Möller's avatar
Niels Möller committed
20 21 22 23 24 25 26
# When using both lsh and some ssh1 implementation, it might make
# sense to use a different port.
PORT=22

set -e

if [ ! -x $DAEMON \
27 28
     -o ! -f /etc/lshd/host-key  \
     -o ! -f /etc/lshd/host-key.pub \
29
     -o ! -f /var/spool/lsh/yarrow-seed-file ]
Niels Möller's avatar
Niels Möller committed
30 31 32 33 34 35 36 37 38 39
then
	echo "lshd not installed properly" >&2
        exit 1
fi

case "$1" in
  start)
	echo -n "Starting $DESC: "
	start-stop-daemon --start --quiet --pidfile $PIDFILE \
		--exec $DAEMON \
40
		-- --pid-file $PIDFILE --daemonic --port $PORT
Niels Möller's avatar
Niels Möller committed
41 42 43 44
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
45
	start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE \
Niels Möller's avatar
Niels Möller committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
		--exec $DAEMON
	echo "$NAME."
	;;
  #reload)
	#
	#	If the daemon can reload its config files on the fly
	#	for example by sending it SIGHUP, do it here.
	#
	#	If the daemon responds to changes in its config file
	#	directly anyway, make this a do-nothing entry.
	#
	# echo "Reloading $DESC configuration files."
	# start-stop-daemon --stop --signal 1 --quiet --pidfile \
	#	/var/run/$NAME.pid --exec $DAEMON
  #;;
61 62 63 64 65 66 67 68 69 70 71 72
  restart)
	echo -n "Restarting $DESC: "
	# Makes the old lshd stop listening for new connections
	start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE \
		--exec $DAEMON
	sleep 1
	start-stop-daemon --start --quiet --pidfile $PIDFILE \
		--exec $DAEMON \
		-- --pid-file $PIDFILE --daemonic --port $PORT
	echo "$NAME."
	;;
  force-reload)
Niels Möller's avatar
Niels Möller committed
73 74 75 76 77 78 79 80 81 82 83
	#
	#	If the "reload" option is implemented, move the "force-reload"
	#	option to the "reload" entry above. If not, "force-reload" is
	#	just the same as "restart".
	#
	echo -n "Restarting $DESC: "
	start-stop-daemon --stop --quiet --pidfile $PIDFILE \
		--exec $DAEMON
	sleep 1
	start-stop-daemon --start --quiet --pidfile $PIDFILE \
		--exec $DAEMON \
84
		-- --pid-file $PIDFILE --daemonic --port $PORT
Niels Möller's avatar
Niels Möller committed
85 86 87 88 89 90 91 92 93 94 95
	echo "$NAME."
	;;
  *)
	N=/etc/init.d/$NAME
	# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0