diff --git a/network b/network index d23b3a9..6124343 100755 --- a/network +++ b/network @@ -11,6 +11,8 @@ [ -f /etc/conf.d/bridges ] && . /etc/conf.d/bridges # dhcpcd settings [ -f /etc/conf.d/dhcpcd ] && . /etc/conf.d/dhcpcd +# tun/tap settings +[ -f /etc/conf.d/tuntap ] && . /etc/conf.d/tuntap ifup() { @@ -194,6 +196,38 @@ bridge_down() done } +tap_up() +{ + for tapif in ${TAP_INTERFACES[@]}; do + for field in user group; do + eval tap_tmp="\$tap_${tapif}_${field}" + if [ ! -z "${tap_tmp}" ]; then + case "${field}" in + user) + tunctl_cmd+=" -u ${tap_tmp} " + ;; + group) + tunctl_cmd+=" -g ${tap_tmp} " + ;; + esac + fi + done + if [ -z "${tunctl_cmd}" ]; then + /usr/bin/tunctl -t ${tapif} -g tap > /dev/null || error=1 + else + /usr/bin/tunctl -t ${tapif} ${tunctl_cmd} > /dev/null || error=1 + unset tunctl_cmd + fi + done +} + +tap_down() +{ + for tapif in ${TAP_INTERFACES[@]}; do + /usr/bin/tunctl -d ${tapif} > /dev/null || error=1 + done +} + case "$1" in start) @@ -204,6 +238,8 @@ case "$1" in stat_busy "Starting Network" error=0 + # bring up tap interfaces + tap_up # bring up bridge interfaces bridge_up # bring up ethernet interfaces @@ -250,6 +286,8 @@ case "$1" in done # bring down bridge interfaces bridge_down + # bring down tap interfaces + tap_down if [ $error -eq 0 ]; then stat_done else