﻿#!/bin/bash

# Copyright (c) Verax Systems.  All Rights Reserved.
#
# Script used to add virtual interfaces
# Description:
#     This script is used by Verax SNMP Simulator to turn virtual interfaces up.
#     All interfaces created by Verax SNMP Simulator are stored in temporary file $FILE for further reference.
# Parameters:
#     $1 - The name of the interface (e.g. eth0 for the first Ethernet interface)
#     $2 - The sub ID of interface alias (e.g. 0 for "eth0:0" alias, 1 for "eth0:1", ...)
#     $3 - The IP address and mask assigned for the interface (e.g. 192.168.1.12/24)
#
# NOTE: This script is being invoked internally by Verax SNMP Simulator and cannot be invoked manually.

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

echo "[vlan_up] ifconfig $1:$2 $3 netmask $4 up"
ifconfig $1:$2 $3 netmask $4 up
exec 5>>$DIR/created_interfaces.txt
echo $1:$2>&5
exec 0>&- # close stdin
exec 1>&- # close stdout
exec 2>&- # close stderr
exec 5>&-
