You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

42 lines
719 B

#!/bin/sh
ip_forwarding() {
v=${1:-0}
echo ${v} > /proc/sys/net/ipv4/ip_forward
}
sbin_base=/sbin
if [ -x /var/sbin/openvpn ]; then
sbin_base=/var/sbin
fi
case "$1" in
start)
if [ -e /var/etc/.openvpn ]; then
read mode < /var/etc/.openvpn
mode=${mode:-client}
if [ ! -e /var/etc/openvpn/${mode}.conf ]; then
echo "[OpenVPN] /var/etc/openvpn/${mode}.conf not found."
exit 1
fi
ip_forwarding 1
${sbin_base}/openvpn \
--config /var/etc/openvpn/${mode}.conf \
--log /tmp/openvpn_${mode}.log \
--daemon \
--script-security 2 \
--up /var/etc/openvpn/up.sh
fi
;;
stop)
killall -TERM openvpn
sleep 3
ip_forwarding 0
;;
restart)
$0 stop
$0 start
;;
esac