]> git.pld-linux.org Git - packages/autossh.git/blame - autossh.init
- pass path to ssh
[packages/autossh.git] / autossh.init
CommitLineData
8ccce38e 1#!/bin/sh
2#
3# autossh ssh sessions manager
4#
5# chkconfig: 345 82 18
6#
7# description: ssh sessions manager
8#
9# processname: autossh
10# config: /etc/sysconfig/autossh
8ccce38e 11#
12# $Id$
13
14# Source function library
15. /etc/rc.d/init.d/functions
16
17# Get network config
18. /etc/sysconfig/network
19
20# Set defaults
21AUTOSSH_PORT=0 # connection monitoring port. 0 turns the monitoring function off.
22AUTOSSH_LOGLEVEL=7
23
24# Get service config - may override defaults
25[ -f /etc/sysconfig/autossh ] && . /etc/sysconfig/autossh
26
27export AUTOSSH_LOGLEVEL
28
29# Check that networking is up.
30if is_yes "${NETWORKING}"; then
31 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
32 msg_network_down autossh
33 exit 1
34 fi
35else
36 exit 0
37fi
38
39start() {
40 # Check if the service is already running?
41 if [ -f /var/lock/subsys/autossh ]; then
42 msg_already_running autossh
43 return
44 fi
45
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)
51 done
52
53 # XXX How to detect errors?
54 touch /var/lock/subsys/autossh
55}
56
57stop() {
58 if [ ! -f /var/lock/subsys/autossh ]; then
59 msg_not_running autossh
60 return
61 fi
62
63 # Stop daemons.
64 for I in /var/run/autossh/*.pid; do
65 msg_stopping "autossh session $(basename $I)"
66 killproc --pidfile $I autossh -TERM
67 done
68 rm -f /var/lock/subsys/autossh
69}
70
71reload() {
72 if [ ! -f /var/lock/subsys/autossh ]; then
73 msg_not_running autossh
74 RETVAL=7
75 return
76 fi
77
78 msg_reloading autossh
79 for I in /var/run/autossh/*.pid; do
80 killproc --pidfile $I autossh -USR1
81 done
82 # XXX How to detect errors?
83 # RETVAL=$?
84 RETVAL=0
85}
86
87condrestart() {
88 if [ ! -f /var/lock/subsys/autossh ]; then
89 msg_not_running autossh
90 RETVAL=$1
91 return
92 fi
93
94 stop
95 start
96}
97
98RETVAL=0
99# See how we were called.
100case "$1" in
101 start)
102 start
103 ;;
104 stop)
105 stop
106 ;;
107 restart)
108 stop
109 start
110 ;;
111 try-restart)
112 condrestart 0
113 ;;
114 reload|force-reload)
115 reload
116 ;;
117 status)
118 status autossh
119 RETVAL=$?
120 ;;
121 *)
122 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
123 exit 3
124esac
125
126exit $RETVAL
This page took 0.794637 seconds and 4 git commands to generate.