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
|
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.
|
# monitoring off, and autossh will only restart ssh on ssh exit.
|
||||||
AUTOSSH_PORT="0"
|
AUTOSSH_PORT="0"
|
||||||
|
|
||||||
|
## Type: integer
|
||||||
|
## Default: 1
|
||||||
|
#
|
||||||
|
# Number of autossh instances to spawn on start.
|
||||||
|
AUTOSSH_SPAWNS="1"
|
||||||
|
|
||||||
## Type: string
|
## Type: string
|
||||||
## Default: user@example.com -p 22 -ynNT -R 30000:localhost:22 -o ExitOnForwardFailure=yes -o ServerAliveInterval=60 -o ServerAliveCountMax=3
|
## 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
|
# 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"
|
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
|
. /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
|
rc_reset
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
export AUTOSSH_PIDFILE="/var/run/autossh.pid"
|
|
||||||
export AUTOSSH_FIRST_POLL
|
export AUTOSSH_FIRST_POLL
|
||||||
export AUTOSSH_LOGLEVEL
|
export AUTOSSH_LOGLEVEL
|
||||||
export AUTOSSH_POLL
|
export AUTOSSH_POLL
|
||||||
export AUTOSSH_PORT
|
export AUTOSSH_PORT
|
||||||
|
|
||||||
echo -n "Starting autossh "
|
start_instance "0" "/var/run/autossh.pid" "$AUTOSSH_OPTIONS"
|
||||||
/sbin/startproc $AUTOSSH_BIN -f $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)
|
stop)
|
||||||
echo -n "Shutting down autossh "
|
stop_instance "0" "/var/run/autossh.pid" "$AUTOSSH_OPTIONS"
|
||||||
/sbin/killproc $AUTOSSH_BIN
|
|
||||||
|
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)
|
try-restart|condrestart)
|
||||||
if test "$1" = "condrestart"; then
|
if test "$1" = "condrestart"; then
|
||||||
@ -81,10 +118,12 @@ case "$1" in
|
|||||||
rc_status
|
rc_status
|
||||||
;;
|
;;
|
||||||
status)
|
status)
|
||||||
echo -n "Checking for service autossh "
|
status_instance "0" "/var/run/autossh.pid" "$AUTOSSH_OPTIONS"
|
||||||
/sbin/checkproc $AUTOSSH_BIN
|
|
||||||
|
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}"
|
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload}"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package autossh
|
# 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
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user