aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--files/autossh.init.d26
-rw-r--r--manifests/autossh.pp10
2 files changed, 21 insertions, 15 deletions
diff --git a/files/autossh.init.d b/files/autossh.init.d
index fb3c57f..254fcdc 100644
--- a/files/autossh.init.d
+++ b/files/autossh.init.d
@@ -6,13 +6,15 @@
# 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
@@ -23,16 +25,16 @@ export PATH=/sbin:/bin:/usr/sbin:/usr/bin
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
@@ -40,8 +42,8 @@ case "$1" in
;;
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
@@ -50,8 +52,8 @@ case "$1" in
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
@@ -61,13 +63,13 @@ case "$1" in
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
@@ -87,7 +89,7 @@ case "$1" in
;;
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 $?
;;
*)
diff --git a/manifests/autossh.pp b/manifests/autossh.pp
index 80d571b..e94d65b 100644
--- a/manifests/autossh.pp
+++ b/manifests/autossh.pp
@@ -23,12 +23,16 @@ class sshd::autossh($host,
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'],
+ ],
}
}