diff options
author | Robby Workman <rworkman@slackware.com> | 2017-07-13 19:16:24 -0500 |
---|---|---|
committer | Robby Workman <rworkman@slackware.com> | 2017-07-13 19:16:24 -0500 |
commit | c66636bb8a7ad7c18483f7eff1cb10ac722af895 (patch) | |
tree | 10bc5d49506412e5d855eeef21372d03f788195a /rc.inet1 | |
parent | 9342d196f5ff5ad7a4753ae4402338f4adae788c (diff) | |
parent | 6281b5d47da57004b1d00f1a9946f5af6cca38a0 (diff) | |
download | slacknetsetup-c66636bb8a7ad7c18483f7eff1cb10ac722af895.tar.xz |
Merge branch 'virtual-ifs'
Diffstat (limited to 'rc.inet1')
-rw-r--r-- | rc.inet1 | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -73,6 +73,31 @@ lo_down() { # INTERFACE FUNCTIONS # ####################### +# Function to determine if virtual interfaces are defined +virtif_determine() { + if [ ! -z ${VIRTIFNAME} ]; then + virtifcount=$(($(echo ${VIRTIFNAME[@]} | wc -w) - 1)) + else + return 1 + fi +} + +# Function to create virtual interfaces +virtif_create() { + # argument is 'i' - the position of this interface in the IFNAME array. + for i in $(seq 0 ${virtifcount}); do + /sbin/ip tuntap add dev ${VIRTIFNAME[$i]} mode ${VIRTIFTYPE[$i]} user ${VIRTIFUSER[$i]} group ${VIRTIFGROUP[$i]} + done +} + +# Function to destory virtual interfaces +virtif_destroy() { + # argument is 'i' - the position of this interface in the IFNAME array. + for i in $(seq 0 ${virtifcount}); do + /sbin/ip tuntap del dev ${VIRTIFNAME[$i]} mode ${VIRTIFTYPE[$i]} + done +} + # Function to assemble a bridge interface. br_open() { # argument is 'i' - the position of this interface in the IFNAME array. @@ -256,6 +281,7 @@ gateway_down() { # Function to start the network: start() { lo_up + virtif_determine && virtif_create for i in ${IFNAME[@]} ; do if_up $i done @@ -268,6 +294,7 @@ stop() { for i in ${IFNAME[@]} ; do if_down $i done + virtif_determine && virtif_destroy lo_down } |