{ # name of bridge to add veth interface to :local BRIDGENAME "bridgeLocal" # name the veth interface will get :local VETHNAME "mDNSTrunk" # set hostname of container :local HOSTNAME "mDNS" # set vlan-ids to reflect traffic between :local VLANS {100;200} # define image filename :local IMAGENAME "mdns_x86.tar" # path to data root for the container :local CONTAINERROOT "docker/container/mdns_repeater" # ------------------------------- # variable holds all vlans seperated by spaces :local ALLVLANS "" # check bridge existance :if ([:len [/interface bridge find name="$BRIDGENAME"]] = 0) do={ :put "Could not find a bridge with name '$BRIDGENAME' !" :quit } # add veth interface :if ([:len [/interface veth find name="$VETHNAME"]] = 0) do={ # add veth interface /interface veth add address=172.19.19.2/24 gateway=172.19.19.1 name=$VETHNAME } # add veth interface to bridge :if ([:len [/interface bridge port find interface=$VETHNAME]] = 0) do={ /interface bridge port add interface=$VETHNAME bridge=$BRIDGENAME } # for each vlan id :foreach id in=$VLANS do={ # find existing vlan entry :local vlanentry [/interface bridge vlan find vlan-ids ~ "(^|;)$id(;|\$)" and bridge=$BRIDGENAME] :if ([:len $vlanentry] = 0) do={ # if entry does not exist add it to vlan list /interface bridge vlan add bridge=$BRIDGENAME tagged="$BRIDGENAME,$VETHNAME" vlan-ids=$id } else={ # if entry exists and veth interface is not a tagged member append veth interface to vlan as tagged interface :if ([:len [/interface bridge vlan find vlan-ids=$id and current-tagged ~ "$VETHNAME"]] = 0) do={ /interface bridge vlan set $vlanentry tagged=([get $vlanentry tagged],"$VETHNAME") } } # build ALLVLAN variable :if ($ALLVLANS != "") do={ :set ALLVLANS ($ALLVLANS . " " . $id) } else={ :set ALLVLANS $id } } # add container environment variable wich defines the vlans used :if ([:len [/container envs find name=mdns key=VLANS]] = 0) do={ /container envs add name=mdns key=VLANS value=$ALLVLANS } # finally add container :if ([:len [/container find root-dir="$CONTAINERROOT"]] = 0) do={ /container add file=$IMAGENAME envlist=mdns logging=yes start-on-boot=yes root-dir="$CONTAINERROOT" interface=$VETHNAME hostname=$HOSTNAME } else={ :put "Container already exists, please delete it beforehand and run again!" } }