*** /etc/init.d/openvpn 2005-07-17 13:07:02.000000000 +0200 --- /etc/init.d/openvpnNEW 2005-07-17 12:59:01.000000000 +0200 *************** *** 1,6 **** --- 1,8 ---- #!/sbin/runscript VPNDIR="/etc/openvpn" + PINGTRIES=5 + PINGSATRIE=3 depend() { need net *************** *** 34,42 **** --- 36,67 ---- --startas /usr/sbin/openvpn -- --config ${VPN}/local.conf \ --writepid /var/run/openvpn-${VPN}.pid \ --daemon --cd ${VPN} + COMPLETELYUP=1 #not tested so not completly up eend $? else einfo "Connection ${VPN} already online. Skipping..." + COMPLETELYUP=0 #already up and tested + fi + + CONNECTIONTESTS=0 #this var contains the number of times the connection has been tested + while [[ ${COMPLETELYUP} -gt 0 ]] && [[ ${CONNECTIONTESTS} -lt ${PINGTRIES} ]]; do # after 5 tests I give up + if [ -f ${VPN}/onlinecheck ]; then + ping -c ${PINGSATRIE} `head -n 1 ${VPN}/onlinecheck` >& /dev/null + sleep 1 + COMPLETELYUP=$? + CONNECTIONTESTS=`expr ${CONNECTIONTESTS} + 1` + else + einfo "${VPNDIR}/${VPN}/onlinecheck does not exist" + einfo "If you create this file and place the hostname or IP of a system in it that is" + einfo "only reachable when the vpn is up then this initscript will ping that system to" + einfo "test the connection. This will be tried with ${PINGTRIES} times ${PINGSATRIE} pings" + einfo "with 1 second between each of the ${PINGTRIES} times ${PINGSATRIE} pings." + COMPLETELYUP=`true` + fi + done + if [[ ${COMPLETELYUP} -gt 0 ]]; then + ewarn "Openvpn started without problems but the host in" + ewarn "${VPNDIR}/${VPN}/onlinecheck is unavailable." fi else ewarn "Expected ${VPNDIR}/${VPN} to be a directory containing a local.conf."