module-sshd/files/autossh.init.d

101 lines
2.2 KiB
D
Raw Normal View History

2015-06-18 21:58:51 +02:00
#! /bin/sh
### BEGIN INIT INFO
# Provides: autossh
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop:
2015-06-18 21:59:16 +02:00
# Short-Description: AutoSSH daemon
2015-06-18 21:58:51 +02:00
### END INIT INFO
set -e
umask 022
2015-06-18 21:59:16 +02:00
PIDFILE=/var/run/autossh.pid
2015-06-18 21:58:51 +02:00
if test -f /etc/default/isuma-autossh; then
. /etc/default/isuma-autossh
fi
. /lib/lsb/init-functions
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
case "$1" in
start)
2015-06-18 21:59:16 +02:00
log_daemon_msg "Starting AutoSSH daemon" "autossh"
if start-stop-daemon --quiet --start --background --pidfile $PIDFILE --make-pidfile --exec /usr/bin/autossh -- $DAEMON_OPTS; then
2015-06-18 21:58:51 +02:00
log_end_msg 0
else
log_end_msg 1
fi
;;
stop)
2015-06-18 21:59:16 +02:00
log_daemon_msg "Stopping AutoSSH daemon" "autossh"
if start-stop-daemon --stop --quiet --pidfile $PIDFILE ; then
2015-06-18 21:58:51 +02:00
log_end_msg 0
else
log_end_msg 1
fi
;;
reload|force-reload)
2015-06-18 21:59:16 +02:00
log_daemon_msg "Reloading AutoSSH daemon" "autossh"
if start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile $PIDFILE; then
2015-06-18 21:58:51 +02:00
log_end_msg 0
else
log_end_msg 1
fi
;;
restart)
log_daemon_msg "Restarting Autossh for isuma" "autossh"
2015-06-18 21:59:16 +02:00
start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $PIDFILE
if start-stop-daemon --start --quiet -b --make-pidfile --pidfile $PIDFILE --exec /usr/bin/autossh -- $AUTOSSH_ISUMA_OPTS; then
2015-06-18 21:58:51 +02:00
log_end_msg 0
else
log_end_msg 1
fi
;;
try-restart)
log_daemon_msg "Restarting Autossh for isuma" "autossh"
set +e
2015-06-18 21:59:16 +02:00
start-stop-daemon --stop --quiet --retry 30 --pidfile $PIDFILE
2015-06-18 21:58:51 +02:00
RET="$?"
set -e
case $RET in
0)
# old daemon stopped
2015-06-18 21:59:16 +02:00
if start-stop-daemon --start --quiet --oknodo -b --pidfile $PIDFILE --make-pidfile --exec /usr/bin/autossh -- $AUTOSSH_ISUMA_OPTS; then
2015-06-18 21:58:51 +02:00
log_end_msg 0
else
log_end_msg 1
fi
;;
1)
# daemon not running
log_progress_msg "(not running)"
log_end_msg 0
;;
*)
# failed to stop
log_progress_msg "(failed to stop)"
log_end_msg 1
;;
esac
;;
status)
2015-06-18 21:59:16 +02:00
status_of_proc -p $PIDFILE /usr/sbin/autossh autossh && exit 0 || exit $?
2015-06-18 21:58:51 +02:00
;;
*)
log_action_msg "Usage: /etc/init.d/isuma-autossh {start|stop|reload|force-reload|restart|try-restart|status}"
exit 1
esac
exit 0