summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'net-scripts/net.modules.d/tuntap.sh')
-rw-r--r--net-scripts/net.modules.d/tuntap.sh36
1 files changed, 14 insertions, 22 deletions
diff --git a/net-scripts/net.modules.d/tuntap.sh b/net-scripts/net.modules.d/tuntap.sh
index e0d1865..dc40523 100644
--- a/net-scripts/net.modules.d/tuntap.sh
+++ b/net-scripts/net.modules.d/tuntap.sh
@@ -1,5 +1,7 @@
-# Copyright (c) 2004-2006 Gentoo Foundation
+#!/bin/bash
+# Copyright (c) 2004-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+
# Contributed by Roy Marples (uberlord@gentoo.org)
# Fix any potential localisation problems
@@ -17,12 +19,6 @@ tunctl() {
tuntap_depend() {
before interface macchanger
functions interface_exists interface_type
-}
-
-# void tuntap_expose(void)
-#
-# Expose variables that can be configured
-tuntap_expose() {
variables tunctl
}
@@ -52,34 +48,28 @@ tuntap_check_kernel() {
#
# Returns 0 if the tun/tap interface exists, otherwise 1
tuntap_exists() {
- local itype="$(interface_type "$1")"
- [[ ${itype} != "tun" && ${itype} != "tap" ]] && return 1
- interface_exists "$1"
+ [[ -n $(get_options tuntap "net.$1") ]]
}
# bool tuntap_pre_start(char *iface)
#
# Create the device, give it the right perms
tuntap_pre_start() {
- local iface="$1" itype="$(interface_type "$1")"
-
- # Check that we are a valid tun/tap interface
- # NOTE - the name can be anything as we define it
- # but for simplicity in the config we require either
- # tun or tap
- [[ ${itype} != "tun" && ${itype} != "tap" ]] && return 0
+ local iface="$1" ifvar="$(bash_variable "$1")"
+ local tuntap="tuntap_${ifvar}"
+ [[ -z ${!tuntap} ]] && return 0
tuntap_check_kernel || return 1
ebegin "Creating Tun/Tap interface ${iface}"
if [[ -x /usr/sbin/openvpn ]] ; then
- openvpn --mktun --dev "${iface}" >/dev/null
+ openvpn --mktun --dev-type "${!tuntap}" --dev "${iface}" \
+ > /dev/null
else
- local ifvar="$(bash_variable "${iface}")"
local opts="tunctl_${ifvar}"
tunctl ${!opts} -t "${iface}" >/dev/null
fi
- eend $?
+ eend $? && save_options tuntap "${!tuntap}"
}
# bool tuntap_stop(char *iface)
@@ -93,11 +83,13 @@ tuntap_stop() {
ebegin "Destroying Tun/Tap interface ${iface}"
if [[ -x /usr/sbin/openvpn ]] ; then
- openvpn --rmtun --dev "${iface}" >/dev/null
+ openvpn --rmtun \
+ --dev-type "$(get_options tuntap)" \
+ --dev "${iface}" > /dev/null
else
tunctl -d "${fiace}" >/dev/null
fi
eend $?
}
-# vim: set ft=sh ts=4 :
+# vim:ts=4