Accepting request 161418 from security
Adds support for starting multiple autossh instances from the init service. (forwarded request 161409 from tokoyami) OBS-URL: https://build.opensuse.org/request/show/161418 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/autossh?expand=0&rev=5
This commit is contained in:
commit
1e85fb6840
@ -1,3 +1,29 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Mar 27 12:17:11 UTC 2013 - multyrealm@gmail.com
|
||||
|
||||
- support a custom count of instances
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Mar 27 09:28:30 UTC 2013 - multyrealm@gmail.com
|
||||
|
||||
- add functions to init script for controling autossh instances
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 22 13:34:38 UTC 2013 - multyrealm@gmail.com
|
||||
|
||||
- change first autossh channel configuration key to
|
||||
the old one to make package update seemless
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Mar 19 12:27:56 UTC 2013 - multyrealm@gmail.com
|
||||
|
||||
- support upto 10 autossh instances
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Mar 18 16:16:42 UTC 2013 - multyrealm@gmail.com
|
||||
|
||||
- updated copyright year
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Apr 18 15:45:10 UTC 2012 - multyrealm@gmail.com
|
||||
|
||||
|
@ -31,8 +31,16 @@ AUTOSSH_POLL="600"
|
||||
# monitoring off, and autossh will only restart ssh on ssh exit.
|
||||
AUTOSSH_PORT="0"
|
||||
|
||||
## Type: integer
|
||||
## Default: 1
|
||||
#
|
||||
# Number of autossh instances to spawn on start.
|
||||
AUTOSSH_SPAWNS="1"
|
||||
|
||||
## Type: string
|
||||
## Default: user@example.com -p 22 -ynNT -R 30000:localhost:22 -o ExitOnForwardFailure=yes -o ServerAliveInterval=60 -o ServerAliveCountMax=3
|
||||
#
|
||||
# Options to be passed to ssh
|
||||
# All options except for the first must end with "_<number>". Only the
|
||||
# options upto "_$(($AUTOSSH_SPAWNS-1))" will be started.
|
||||
AUTOSSH_OPTIONS="user@example.com -p 22 -ynNT -R 30000:localhost:22 -o ExitOnForwardFailure=yes -o ServerAliveInterval=60 -o ServerAliveCountMax=3"
|
||||
|
59
autossh.init
59
autossh.init
@ -34,26 +34,63 @@ test -r $AUTOSSH_CONFIG || { echo "$AUTOSSH_CONFIG not existing";
|
||||
|
||||
. /etc/rc.status
|
||||
|
||||
function start_instance() {
|
||||
id=$1
|
||||
pidfile=$2
|
||||
options=$3
|
||||
if [ -n "$options" ]; then
|
||||
echo -n "$id: Starting autossh "
|
||||
export AUTOSSH_PIDFILE="$pidfile"
|
||||
/sbin/startproc -p "$pidfile" $AUTOSSH_BIN -f $options
|
||||
rc_status -v
|
||||
fi
|
||||
}
|
||||
|
||||
function stop_instance() {
|
||||
id=$1
|
||||
pidfile=$2
|
||||
options=$3
|
||||
if [ -n "$options" ]; then
|
||||
echo -n "$id: Shutting down autossh "
|
||||
/sbin/killproc -p "$pidfile" $AUTOSSH_BIN
|
||||
rc_status -v
|
||||
fi
|
||||
}
|
||||
|
||||
function status_instance() {
|
||||
id=$1
|
||||
pidfile=$2
|
||||
options=$3
|
||||
if [ -n "$options" ]; then
|
||||
echo -n "$id: Checking for service autossh "
|
||||
/sbin/checkproc -p "$pidfile" $AUTOSSH_BIN
|
||||
rc_status -v
|
||||
fi
|
||||
}
|
||||
|
||||
rc_reset
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
export AUTOSSH_PIDFILE="/var/run/autossh.pid"
|
||||
export AUTOSSH_FIRST_POLL
|
||||
export AUTOSSH_LOGLEVEL
|
||||
export AUTOSSH_POLL
|
||||
export AUTOSSH_PORT
|
||||
|
||||
echo -n "Starting autossh "
|
||||
/sbin/startproc $AUTOSSH_BIN -f $AUTOSSH_OPTIONS
|
||||
start_instance "0" "/var/run/autossh.pid" "$AUTOSSH_OPTIONS"
|
||||
|
||||
for i in `seq 1 $(($AUTOSSH_SPAWNS-1))`; do
|
||||
eval start_instance \"$i\" \"/var/run/autossh$i.pid\" \"\$AUTOSSH_OPTIONS_$i\"
|
||||
done
|
||||
|
||||
rc_status -v
|
||||
;;
|
||||
stop)
|
||||
echo -n "Shutting down autossh "
|
||||
/sbin/killproc $AUTOSSH_BIN
|
||||
stop_instance "0" "/var/run/autossh.pid" "$AUTOSSH_OPTIONS"
|
||||
|
||||
for i in `seq 1 $(($AUTOSSH_SPAWNS-1))`; do
|
||||
eval stop_instance \"$i\" \"/var/run/autossh$i.pid\" \"\$AUTOSSH_OPTIONS_$i\"
|
||||
done
|
||||
|
||||
rc_status -v
|
||||
;;
|
||||
try-restart|condrestart)
|
||||
if test "$1" = "condrestart"; then
|
||||
@ -81,10 +118,12 @@ case "$1" in
|
||||
rc_status
|
||||
;;
|
||||
status)
|
||||
echo -n "Checking for service autossh "
|
||||
/sbin/checkproc $AUTOSSH_BIN
|
||||
status_instance "0" "/var/run/autossh.pid" "$AUTOSSH_OPTIONS"
|
||||
|
||||
for i in `seq 1 $(($AUTOSSH_SPAWNS-1))`; do
|
||||
eval status_instance \"$i\" \"/var/run/autossh$i.pid\" \"\$AUTOSSH_OPTIONS_$i\"
|
||||
done
|
||||
|
||||
rc_status -v
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload}"
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package autossh
|
||||
#
|
||||
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
|
Loading…
x
Reference in New Issue
Block a user