3 # autossh ssh sessions manager
7 # description: ssh sessions manager
10 # config: /etc/sysconfig/autossh
15 # Source function library
16 . /etc/rc.d/init.d/functions
19 . /etc/sysconfig/network
22 AUTOSSH_PORT=0 # connection monitoring port. 0 turns the monitoring function off.
25 # Get service config - may override defaults
26 [ -f /etc/sysconfig/autossh ] && . /etc/sysconfig/autossh
28 export AUTOSSH_LOGLEVEL
30 # Check that networking is up.
31 if is_yes "${NETWORKING}"; then
32 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
33 msg_network_down autossh
41 # Check if the service is already running?
42 if [ -f /var/lock/subsys/autossh ]; then
43 msg_already_running autossh
47 # Parse autossh.tab file
48 # /^[^#$]/ - 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
80 for I in /var/run/autossh/*.pid; do
81 killproc --pidfile $I autossh -USR1
83 # XXX How to detect errors?
89 if [ ! -f /var/lock/subsys/autossh ]; then
90 msg_not_running autossh
100 # See how we were called.
123 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"