3 # autossh ssh sessions manager
7 # description: ssh sessions manager
10 # config: /etc/sysconfig/autossh
14 # Source function library
15 . /etc/rc.d/init.d/functions
18 . /etc/sysconfig/network
21 AUTOSSH_PORT=0 # connection monitoring port. 0 turns the monitoring function off.
24 # Get service config - may override defaults
25 [ -f /etc/sysconfig/autossh ] && . /etc/sysconfig/autossh
27 export AUTOSSH_LOGLEVEL
29 # Check that networking is up.
30 if is_yes "${NETWORKING}"; then
31 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
32 msg_network_down autossh
40 # Check if the service is already running?
41 if [ -f /var/lock/subsys/autossh ]; then
42 msg_already_running autossh
46 # Parse autossh.tab file
47 # /^[^#$]/ - removes comments, i.e. lines begining with '#' and empty lines.
48 for I in $(awk -vFS=';' '/^[^#$]/ {print $1}' /etc/autossh.tab); do
49 msg_starting "autossh $I"
50 AUTOSSH_PIDFILE=/var/run/autossh/$I.pid $(awk -vFS=';' "-vport=$AUTOSSH_PORT" "/^$I;/ "'{printf("daemon autossh -M%s -fN %s\n", port, $2)}' /etc/autossh.tab)
53 # XXX How to detect errors?
54 touch /var/lock/subsys/autossh
58 if [ ! -f /var/lock/subsys/autossh ]; then
59 msg_not_running autossh
64 for I in /var/run/autossh/*.pid; do
65 msg_stopping "autossh session $(basename $I)"
66 killproc --pidfile $I autossh -TERM
68 rm -f /var/lock/subsys/autossh
72 if [ ! -f /var/lock/subsys/autossh ]; then
73 msg_not_running autossh
79 for I in /var/run/autossh/*.pid; do
80 killproc --pidfile $I autossh -USR1
82 # XXX How to detect errors?
88 if [ ! -f /var/lock/subsys/autossh ]; then
89 msg_not_running autossh
99 # See how we were called.
122 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"