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.
49 for I in $(awk -vFS=';' '/^[^#$]/ {print $1}' /etc/autossh.tab); do
50 msg_starting "autossh $I"
51 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)
54 # XXX How to detect errors?
55 touch /var/lock/subsys/autossh
59 if [ ! -f /var/lock/subsys/autossh ]; then
60 msg_not_running autossh
65 for I in /var/run/autossh/*.pid; do
66 msg_stopping "autossh session $(basename $I)"
67 killproc --pidfile $I autossh -TERM
69 rm -f /var/lock/subsys/autossh
73 if [ ! -f /var/lock/subsys/autossh ]; then
74 msg_not_running autossh
81 for I in /var/run/autossh/*.pid; do
82 killproc --pidfile $I autossh -USR1
84 # XXX How to detect errors?
90 if [ ! -f /var/lock/subsys/autossh ]; then
91 msg_not_running autossh
101 # See how we were called.
124 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"