# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop:
-# Short-Description: Autossh for isuma
+# Short-Description: AutoSSH daemon
### END INIT INFO
set -e
umask 022
+PIDFILE=/var/run/autossh.pid
+
if test -f /etc/default/isuma-autossh; then
. /etc/default/isuma-autossh
fi
case "$1" in
start)
- log_daemon_msg "Starting Autossh for isuma" "autossh"
- if start-stop-daemon --quiet --start --background --pidfile /var/run/autossh-isuma.pid --make-pidfile --exec /usr/bin/autossh -- $AUTOSSH_ISUMA_OPTS; then
+ 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
log_end_msg 0
else
log_end_msg 1
fi
;;
stop)
- log_daemon_msg "Stopping Autossh for isuma" "autossh"
- if start-stop-daemon --stop --quiet --pidfile /var/run/autossh-isuma.pid ; then
+ log_daemon_msg "Stopping AutoSSH daemon" "autossh"
+ if start-stop-daemon --stop --quiet --pidfile $PIDFILE ; then
log_end_msg 0
else
log_end_msg 1
;;
reload|force-reload)
- log_daemon_msg "Reloading Autossh for isuma's configuration" "autossh"
- if start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile /var/run/autossh-isuma.pid; then
+ log_daemon_msg "Reloading AutoSSH daemon" "autossh"
+ if start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile $PIDFILE; then
log_end_msg 0
else
log_end_msg 1
restart)
log_daemon_msg "Restarting Autossh for isuma" "autossh"
- start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile /var/run/autossh-isuma.pid
- if start-stop-daemon --start --quiet -b --make-pidfile --pidfile /var/run/autossh-isuma.pid --exec /usr/bin/autossh -- $AUTOSSH_ISUMA_OPTS; then
+ 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
log_end_msg 0
else
log_end_msg 1
try-restart)
log_daemon_msg "Restarting Autossh for isuma" "autossh"
set +e
- start-stop-daemon --stop --quiet --retry 30 --pidfile /var/run/autossh-isuma.pid
+ start-stop-daemon --stop --quiet --retry 30 --pidfile $PIDFILE
RET="$?"
set -e
case $RET in
0)
# old daemon stopped
- if start-stop-daemon --start --quiet --oknodo -b --pidfile /var/run/autossh-isuma.pid --make-pidfile --exec /usr/bin/autossh -- $AUTOSSH_ISUMA_OPTS; then
+ if start-stop-daemon --start --quiet --oknodo -b --pidfile $PIDFILE --make-pidfile --exec /usr/bin/autossh -- $AUTOSSH_ISUMA_OPTS; then
log_end_msg 0
else
log_end_msg 1
;;
status)
- status_of_proc -p /var/run/autossh-isuma.pid /usr/sbin/autossh autossh && exit 0 || exit $?
+ status_of_proc -p $PIDFILE /usr/sbin/autossh autossh && exit 0 || exit $?
;;
*)
mode => '0444',
content => "DAEMON_OPTS='-o ServerAliveInterval=15 -o ServerAliveCountMax=4 -q -N -R $port_ensure:localhost:22 $user_ensure@$host'\n";
}
+ package { 'autossh':
+ ensure => present,
+ }
service { 'autossh':
ensure => running,
enable => true,
subscribe => [
- File['/etc/init.d/autossh'],
- File['/etc/default/autossh']
- ],
+ File['/etc/init.d/autossh'],
+ File['/etc/default/autossh'],
+ Package['autossh'],
+ ],
}
}