corrections.

- Remplacement du test avec ps qui est trop verbeux quand le fichier
  de pid n'existe pas
- Echapement correct des «!»

darcs-hash:20080106221328-af139-42c198fcead8374604735ea60adf979b911554c1.gz
This commit is contained in:
Jeremie Dimino 2008-01-06 23:13:28 +01:00
parent b3a7d40d7a
commit 34b7f27d34
2 changed files with 11 additions and 9 deletions

View file

@ -1,14 +1,15 @@
#!/bin/sh #!/bin/sh
VPN_NAME=ovh VPN_NAME=ovh
PID_FILE=/var/run/openvpn.${VPN_NAME}.pid
if { ! ps -p $(< /var/run/openvpn.${VPN_NAME}.pid) > /dev/null; } && { ! fping -q ovh.adm.crans.org; }; then if [ ! -f $PID_FILE -o ! -d /proc/$(< $PID_FILE) ] && ! fping -q ovh.adm.crans.org; then
if fping -q ovh.crans.org; then if fping -q ovh.crans.org; then
if /etc/init.d/openvpn start ${VPN_NAME} > /dev/null; then if /etc/init.d/openvpn start ${VPN_NAME} > /dev/null; then
echo "Lancement du tunnel vers OVH reussi !" echo 'Lancement du tunnel vers OVH reussi !'
exit 0 exit 0
else else
echo "Echec du lancement du tunnel vers OVH !" echo 'Echec du lancement du tunnel vers OVH !'
exit 1 exit 1
fi fi
fi fi

View file

@ -1,28 +1,29 @@
#!/bin/sh #!/bin/sh
VPN_NAME=adm VPN_NAME=adm
PID_FILE=/var/run/openvpn.${VPN_NAME}.pid
if { ! ps -p $(< /var/run/openvpn.${VPN_NAME}.pid) > /dev/null; }; then if [ ! -f $PID_FILE -o ! -d /proc/$(< $PID_FILE) ]; then
if fping -q komaz.crans.org; then if fping -q komaz.crans.org; then
ln -sf komaz.conf /etc/openvpn/${VPN_NAME}.conf ln -sf komaz.conf /etc/openvpn/${VPN_NAME}.conf
if /etc/init.d/openvpn start ${VPN_NAME} > /dev/null; then if /etc/init.d/openvpn start ${VPN_NAME} > /dev/null; then
echo "Lancement du tunnel vers komaz reussi !" echo 'Lancement du tunnel vers komaz reussi !'
exit 0 exit 0
else else
echo "Echec du lancement du tunnel vers komaz !" echo 'Echec du lancement du tunnel vers komaz !'
exit 1 exit 1
fi fi
elif fping -q freebox.crans.org; then elif fping -q freebox.crans.org; then
ln -sf freebox.conf /etc/openvpn/${VPN_NAME}.conf ln -sf freebox.conf /etc/openvpn/${VPN_NAME}.conf
if /etc/init.d/openvpn start ${VPN_NAME} > /dev/null; then if /etc/init.d/openvpn start ${VPN_NAME} > /dev/null; then
echo "Lancement du tunnel vers freebox reussi !" echo 'Lancement du tunnel vers freebox reussi !'
exit 0 exit 0
else else
echo "Echec du lancement du tunnel vers freebox !" echo 'Echec du lancement du tunnel vers freebox !'
exit 1 exit 1
fi fi
else else
echo "Impossible de determiner un point d'acces au CRANS !" echo "Impossible de determiner un point d'acces au CRANS "\!
exit 1 exit 1
fi fi
fi fi