Package: autossh
Severity: wishlist
Tags: patch
The maintainers of the autossh package received the attached mail.
Forwarding it to the BTS to better be able to track this.
Regards, Axel
--
,''`. | Axel Beckert <a...@debian.org>, http://people.debian.org/~abe/
: :' : | Debian Developer, ftp.ch.debian.org Admin
`. `' | 1024D: F067 EA27 26B9 C3FC 1486 202E C09E 1D89 9593 0EDE
`- | 4096R: 2517 B724 C5F6 CA99 5329 6E61 2FF9 CD59 6126 16B5
--- Begin Message ---
Hello,
I've written an init.d script for autossh, I think it may be useful for other
users using autossh, feel free to include on Debian package if appropriate
kind regards,
LluĂs Gili
diff --git a/debian/autossh.default b/debian/autossh.default
new file mode 100644
index 0000000..ef30b2b
--- /dev/null
+++ b/debian/autossh.default
@@ -0,0 +1,83 @@
+# /etc/default/autossh
+
+# set to 1 to enable
+START="0"
+
+# -f is already included on init.d script
+DAEMON_ARGS=""
+
+# host to connect to
+REMOTE_HOST=""
+
+# username to login with
+REMOTE_USER=""
+
+# ExitOnForwardFailure with AUTOSSH_GATETIME=0 makes autossh reconnect if
+# port forwarding fails, trying to ensure connectivity to forwarded ports
+SSH_OPTIONS="-N -o \"ExitOnForwardFailure yes\" -R 0:localhost:22"
+
+# autossh uses environment variables to control features:
+
+# If this variable is set, the logging level is set to to LOG_DEBUG, and if
+# the operating system supports it, syslog is set to duplicate log entries to
+# stderr.
+#
+#export AUTOSSH_DEBUG=true
+
+# Specifies the time to wait before the first connection test. Thereafter the
+# general poll time is used (see AUTOSSH_POLL below).
+#
+#export AUTOSSH_FIRST_POLL=
+
+# Specifies how long ssh must be up before we consider it a successful
+# connection. The default is 30 seconds. Note that if AUTOSSH_GATETIME is set
+# to 0, then not only is the gatetime behaviour turned off, but autossh also
+# ignores the first run failure of ssh. This may be useful when running
+# autossh at boot.
+#
+export AUTOSSH_GATETIME=0
+
+# Specifies the log level, corresponding to the levels used by syslog; so 0-7
+# with 7 being the chattiest.
+#
+#export AUTOSSH_LOGLEVEL=
+
+# Specifies that autossh should use the named log file, rather than syslog.
+#
+#export AUTOSSH_LOGFILE=
+
+# Sets the maximum number of seconds that the program should run. Once the
+# number of seconds has been passed, the ssh child will be killed and the
+# program will exit.
+#
+#export AUTOSSH_MAXLIFETIME=
+
+# Specifies how many times ssh should be started. A negative number means no
+# limit on the number of times ssh is started. The default value is -1.
+#
+#export AUTOSSH_MAXSTART=
+
+# Append message to echo message sent when testing connections.
+#
+#export AUTOSSH_MESSAGE=
+
+# Specifies the path to the ssh executable, in case it is different than the
+# path compiled in.
+#
+#export AUTOSSH_PATH=
+
+# Write autossh pid to specified file.
+#
+export AUTOSSH_PIDFILE=/var/run/autossh.pid
+
+# Specifies the connection poll time in seconds; default is 600 seconds. If
+# the poll time is less than twice the network timeouts (default 15 seconds)
+# the network timeouts will be adjusted downward to 1/2 the poll time.
+#
+#export AUTOSSH_POLL=
+
+# Sets the connection monitoring port. Mostly in case ssh appropriates -M at
+# some time. But because of this possible use, AUTOSSH_PORT overrides the -M
+# flag. A value of 0 turns the monitoring function off.
+#
+#export AUTOSSH_PORT=
diff --git a/debian/autossh.init b/debian/autossh.init
new file mode 100644
index 0000000..c3e1911
--- /dev/null
+++ b/debian/autossh.init
@@ -0,0 +1,140 @@
+#!/bin/sh
+
+### BEGIN INIT INFO
+# Provides: autossh
+# Required-Start: $remote_fs $syslog
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop:
+# Short-Description: autossh daemon
+### END INIT INFO
+
+# Author: Ingent Grup Systems <sup...@ingent.net>
+
+# Do NOT "set -e"
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC="autossh daemon"
+NAME=autossh
+DAEMON=/usr/bin/$NAME
+DAEMON_ARGS=""
+SCRIPTNAME=/etc/init.d/$NAME
+export AUTOSSH_PIDFILE=/var/run/$NAME.pid
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+not_configured () {
+ echo "#### WARNING ####"
+ echo "Autossh won't be started/stopped unless it is configured on /etc/default/$NAME"
+ echo "#################"
+ exit 0
+}
+
+# check if autossh is configured or not
+if [ -r /etc/default/$NAME ]; then
+ . /etc/default/$NAME
+ if [ "$START" != "1" ]; then
+ not_configured
+ fi
+else
+ not_configured
+fi
+
+# check if REMOTE_HOST is configured
+if [ -z "$REMOTE_HOST" ]; then
+ echo "Need to configure REMOTE_HOST on /etc/default/$NAME"
+ exit 0
+fi
+
+# check if REMOTE_USER is configured
+if [ -n "$REMOTE_USER" ]; then
+ DEST="$REMOTE_USER@$REMOTE_HOST"
+else
+ DEST="$REMOTE_HOST"
+fi
+
+# construct full args
+DAEMON_FULL_ARGS="-f $DAEMON_ARGS $DEST $SSH_OPTIONS"
+
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
+# and status_of_proc is working.
+. /lib/lsb/init-functions
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+ # Return
+ # 0 if daemon has been started
+ # 1 if daemon was already running
+ # 2 if daemon could not be started
+ # do not use /usr/bin/autossh on test since it is a wrapper for /usr/lib/autossh/autossh
+ start-stop-daemon --start --quiet --pidfile $AUTOSSH_PIDFILE --exec /usr/lib/autossh/autossh --test > /dev/null \
+ || return 1
+ start-stop-daemon --start --quiet --pidfile $AUTOSSH_PIDFILE --exec $DAEMON -- \
+ $DAEMON_FULL_ARGS \
+ || return 2
+ # Add code here, if necessary, that waits for the process to be ready
+ # to handle requests from services started subsequently which depend
+ # on this one. As a last resort, sleep for some time.
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+ # Return
+ # 0 if daemon has been stopped
+ # 1 if daemon was already stopped
+ # 2 if daemon could not be stopped
+ # other if a failure occurred
+ start-stop-daemon --stop --quiet --retry=TERM/5/KILL/5 --pidfile $AUTOSSH_PIDFILE --name $NAME
+ RETVAL="$?"
+ [ "$RETVAL" = 2 ] && return 2
+ # Wait for children to finish too if this is a daemon that forks
+ # and if the daemon is only ever run from this initscript.
+ # If the above conditions are not satisfied then add some other code
+ # that waits for the process to drop all resources that could be
+ # needed by services started subsequently. A last resort is to
+ # sleep for some time.
+ start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
+ [ "$?" = 2 ] && return 2
+ # Many daemons don't delete their pidfiles when they exit.
+ rm -f $AUTOSSH_PIDFILE
+ return "$RETVAL"
+}
+
+case "$1" in
+ start)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+ do_start
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ stop)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ status)
+ status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+ ;;
+ *)
+ echo "Usage: $SCRIPTNAME {start|stop|status}" >&2
+ exit 3
+ ;;
+esac
+
+:
diff --git a/debian/rules b/debian/rules
index a36ad45..f78883a 100755
--- a/debian/rules
+++ b/debian/rules
@@ -52,6 +52,7 @@ install: build
dh_testroot
dh_prep
dh_installdirs
+ dh_installinit
# Add here commands to install the package into debian/autossh.
dh_install
signature.asc
Description: This is a digitally signed message part.
--- End Message ---