Donc je modifie de la façon suivante mon script. Par contre dès que j'exécute, DStation met tout en arrêt et ne reprend jamais, alors que mon VPN est bien ON :
-------------------------------------------------------------------------------------------------------------------------------------
#!/bin/ash
# script for managing firewall, VPN connection and Download station scheduler #
#
# iptables binary path
iptables="/sbin/iptables"
# DLStation
DLStation="/var/packages/DownloadStation/scripts/start-stop-status"
#VPN interface
interface_vpn="ppp0"
# Log file
logfile="/root/vpn.log"
# TCP port authorized / Tu inscris tes ports TCP pour tes downloads
vpn_tcp_port=12344
# UDP port authorized /Tu inscris tes ports UDP pour tes downloads
vpn_udp_port=12344
# OpenVPN configuration / Tu rentre le nom de ta connection ainsi que son ID
openvpn_confid=p1480965151
openvpn_configname= HMA
############### START SCRIPT ###################
# Is there a VPN connection ?
if [ -z "$(ifconfig | grep "$interface_vpn")" ]; then
echo $(date) ": VPN not started" >> $logfile
#No VPN, No Download station
$DLStation stop
if [ -n "$(ps | grep -v "grep" | grep "/sbin/scheduler")" ] ; then
echo $(date) ": ERROR, DownloadStation is always on :/" >> $logfile
else
echo $(date) ": DownloadStation is stopped" >> $logfile
fi
# Trying to start VPN connection
echo $(date) ": Trying to start VPN connection..." >> $logfile
echo conf_id=$openvpn_confid > /usr/syno/etc/synovpnclient/vpnc_connecting
echo conf_name=$openvpn_configname >> /usr/syno/etc/synovpnclient/vpnc_connecting
echo proto=openvpn >> /usr/syno/etc/synovpnclient/vpnc_connecting
synovpnc reconnect --protocol=openvpn --name=$openvpn_configname --retry=4 --interval=10 >> $logfile
fi
# Is there a VPN connection and can we ping google ?
if [ -z "$(ping -c 4 www.google.fr | grep "64 bytes")" ] && [ -n "$(ifconfig | grep "$interface_vpn")" ] ; then
echo $(date) ": Ping failed to www.google.fr..." >> $logfile
#VPN is going to be stopped, stop Download station
$DLStation stop
if [ -n "$(ps | grep -v "grep" | grep "/sbin/scheduler")" ]; then
echo $(date) ": ERROR, DownloadStation is always on :/" >> $logfile
else
echo $(date) ": DownloadStation is stopped" >> $logfile
fi
# kill the failed VPN connection
synovpnc kill_client >> $logfile
echo $(date) ": VPN connection closed" >> $logfile
wait 10000
# Trying to start VPN connection
echo $(date) ": Trying to start VPN connection..." >> $logfile
echo conf_id=$openvpn_confid > /usr/syno/etc/synovpnclient/vpnc_connecting
echo conf_name=$openvpn_configname >> /usr/syno/etc/synovpnclient/vpnc_connecting
echo proto=openvpn >> /usr/syno/etc/synovpnclient/vpnc_connecting
synovpnc reconnect --protocol=openvpn --name=$openvpn_configname --retry=4 --interval=10 >> $logfile
else
# Firewall is up ?
if [ -n "$(ifconfig | grep "$interface_vpn")" ] && [ -z "$($iptables -L -v | grep "$interface_vpn")" ]; then
echo $(date) ": Interface " $interface_vpn " found but firewall is not configured..." >> $logfile
#Incoming tcp vpn connections ACCEPT
if [ -n "$vpn_tcp_port" ]; then
$iptables -A INPUT -i $interface_vpn -p tcp -m multiport --dports $vpn_tcp_port -j ACCEPT
fi
#Incoming udp vpn connections ACCEPT
if [ -n "$vpn_udp_port" ]; then
$iptables -A INPUT -i $interface_vpn -p udp -m multiport --dports $vpn_udp_port -j ACCEPT
fi
#if none of the rules were matched DROP #
$iptables -A INPUT -i $interface_vpn -p tcp -j DROP
$iptables -A INPUT -i $interface_vpn -p udp -j DROP
$iptables -A INPUT -i $interface_vpn -p icmp -j DROP
echo $(date) ": Firewall configured successfully" >> $logfile
#VPN Connection and firewall are Ok, starting Download station
$DLStation start
if [ -n "$(ps | grep -v "grep" | grep "/sbin/scheduler")" ] ; then
echo $(date) ": DownloadStation is started" >> $logfile
else
echo $(date) ": ERROR, DownloadStation is stopped" >> $logfile
fi
else
# Update 08/10/2014
if [ -n "$(ifconfig | grep "$interface_vpn")" ] && [ -n "$($iptables -L -v | grep "$interface_vpn")" ]; then
#VPN Connection and firewall are Ok,
if [ -n "$(ps | grep -v "grep" | grep "/sbin/scheduler")" ] ; then
#VPN Connection, firewall and Download station are Ok
echo $(date) ": All network configuration is OK"
else
#VPN Connection and firewall are Ok but not Download station
#try to start it
echo $(date) ": ERROR, DownloadStation is stopped" >> $logfile
$DLStation start
if [ -n "$(ps | grep -v "grep" | grep "/sbin/scheduler")" ] ; then
echo $(date) ": DownloadStation is started" >> $logfile
else
echo $(date) ": ERROR, DownloadStation is stopped" >> $logfile
fi
fi
fi
fi
fi
exit 0;