Lines 44-71
Link Here
|
44 |
# Set the base metric to 1000 |
44 |
# Set the base metric to 1000 |
45 |
metric=1000 |
45 |
metric=1000 |
46 |
|
46 |
|
47 |
local o_opts= t_opts= do_openvpn=false do_tunctl=false |
47 |
local i_opts= o_opts= t_opts= do_iproute2=false do_openvpn=false do_tunctl=false use_iproute2=true |
|
|
48 |
eval i_opts=\$iproute2_${IFVAR} |
48 |
eval o_opts=\$openvpn_${IFVAR} |
49 |
eval o_opts=\$openvpn_${IFVAR} |
49 |
eval t_opts=\$tunctl_${IFVAR} |
50 |
eval t_opts=\$tunctl_${IFVAR} |
50 |
|
51 |
|
51 |
if [ -n "${o_opts}" ] && type openvpn >/dev/null 2>&1; then |
52 |
case " ${MODULES} " in |
|
|
53 |
"* ifconfig *") |
54 |
use_iproute2=false |
55 |
esac |
56 |
|
57 |
if [ -n "${i_opts}"-a "${use_iproute2}"="true" ] && type ip >/dev/null 2>&1; then |
58 |
do_iproute2=true |
59 |
elif [ -n "${o_opts}" ] && type openvpn >/dev/null 2>&1; then |
52 |
do_openvpn=true |
60 |
do_openvpn=true |
53 |
elif [ -n "${t_opts}" ] && type tunctl >/dev/null 2>&1; then |
61 |
elif [ -n "${t_opts}" ] && type tunctl >/dev/null 2>&1; then |
54 |
do_tunctl=true |
62 |
do_tunctl=true |
|
|
63 |
elif type ip >/dev/null 2>&1 && [ use_iproute=true ]; then |
64 |
do_iproute2=true |
55 |
elif type openvpn >/dev/null 2>&1; then |
65 |
elif type openvpn >/dev/null 2>&1; then |
56 |
do_openvpn=true |
66 |
do_openvpn=true |
57 |
elif type tunctl >/dev/null 2>&1; then |
67 |
elif type tunctl >/dev/null 2>&1; then |
58 |
do_tunctl=true |
68 |
do_tunctl=true |
59 |
fi |
69 |
fi |
60 |
|
70 |
|
61 |
if ${do_openvpn}; then |
71 |
if ${do_iproute2}; then |
|
|
72 |
ip tuntap add dev "${IFACE}" mode "${tuntap}" ${i_opts} |
73 |
elif ${do_openvpn}; then |
62 |
openvpn --mktun --dev-type "${tuntap}" --dev "${IFACE}" \ |
74 |
openvpn --mktun --dev-type "${tuntap}" --dev "${IFACE}" \ |
63 |
${o_opts} >/dev/null |
75 |
${o_opts} >/dev/null |
64 |
elif ${do_tunctl}; then |
76 |
elif ${do_tunctl}; then |
65 |
tunctl ${t_opts} -t "${IFACE}" >/dev/null |
77 |
tunctl ${t_opts} -t "${IFACE}" >/dev/null |
66 |
else |
78 |
else |
67 |
eerror "Neither openvpn nor tunctl has been found, please install" |
79 |
eerror "Neither iproute2, openvpn nor tunctl has been found, please install" |
68 |
eerror "either \"openvpn\" or \"usermode-utilities\"." |
80 |
eerror "either \"iproute2\" \"openvpn\" or \"usermode-utilities\"." |
69 |
fi |
81 |
fi |
70 |
eend $? && _up && service_set_value tuntap "${tuntap}" |
82 |
eend $? && _up && service_set_value tuntap "${tuntap}" |
71 |
} |
83 |
} |
Lines 75-81
Link Here
|
75 |
_is_tuntap || return 0 |
87 |
_is_tuntap || return 0 |
76 |
|
88 |
|
77 |
ebegin "Destroying Tun/Tap interface ${IFACE}" |
89 |
ebegin "Destroying Tun/Tap interface ${IFACE}" |
78 |
if type tunctl >/dev/null 2>&1; then |
90 |
if type iproute2 > /dev/null 2>&1; then |
|
|
91 |
_ip tuntap del dev ${IFACE} mode ${service_get_value tuntap} |
92 |
elif type tunctl >/dev/null 2>&1; then |
79 |
tunctl -d "${IFACE}" >/dev/null |
93 |
tunctl -d "${IFACE}" >/dev/null |
80 |
else |
94 |
else |
81 |
openvpn --rmtun \ |
95 |
openvpn --rmtun \ |