I felt the need to be able to make it easier to add a new network device into my Detect Driven Initialization (DDI) while still keeping the flexibility to write a custom script for any device.
I came up with a solution that has just 10 configuration directive to deal with the most common scenarios without having to write custom scripts: LANs, VLANs, Bridges, WiFi, PPPoE.
Each one can have static or DHCP assigned address and normal LAN also supports aliases
Here's the template cfg file which should be self explanatory.
Code:
#device type: one of ETHER BRIDGE VLAN WIFI
#TYPE=ETHER|BRIDGE|VLAN|WIFI
#for bridges and vlans the list of slave devices used
#space separated list of slave devices for bridges or other devices that are built similarly
#SLAVE_DEVS="NIC0 NIC1 ... NICn"
#EG for bridging eth0 and wlan0
#SLAVE_DEVS="eth0 wlan0"
#EG for creating vlans 5 7 and 20 on eth1
#SLAVE_DEVS="eth1.5 eth1.7 eth1.20"
#similarly the slave devices need to know which is the master device
#MASTER_DEV=NIC
#EG
#MASTER_DEV=br0 #for bridge
#MASTER_DEV=eth1 #for any of the vlan devices on eth1
#for wifi choose whether to start it in managed mode or master mode
#master mode requires also configuring hostapd
#managed requires setting up wpa_supplicant.conf
#adhoc mode not supported
#WIFI_MODE=MASTER|MANAGED
#EG for managed mode
#WIFI_MODE=MANAGED
#show the device should acquire address
#IP/MASK for static address
#DHCP for acquiring ip dynamically
#PPPOE for negotiation connection via pppoe (statid address woulkd go in the peer config)
#IP=IP/MASK|DHCP|PPPOE
#force numbering for the ppp interface, this can tecnically be in the peer config
#but it's handy to have it here
#UNIT=<integer>
#EG for creating ppp0 interface
#UNIT=0
#optional peer for PPPOE
#if you don't set it the peer will need to have the same name as the interface that is set to IP=PPPOE
#PEER=PEER_NAME
#EG
#PEER=comcastxfinity
#optionally if you want any interface to have alias IP configure the ALIAS[n] array with IP/MASH|DHCP
#ALAIS[n]=IP/MASK|DHCP
#EG set eth0:1 with 10.20.30.40/24
#ALIAS[1]=10.20.30.40/24
#optional extra script to command to be executed after taking up NIC
#EG
#UP_EXEC="dnsmasq -C /etc/dnsmasq/${INAME}.conf"
#optional extra script or command to be executed before taking down NIC
#EG
#DOWN_EXEC="kill -9 $(ps -eo pid,cmd |grep dnsmasq | grep -w "${INAME}\.conf" |awk '{print $1}')"
With this reworking also comes better handling of dependencies allowing for bridges (otherwise undetected by udev at boot time) to come up correctly triggered by the slave devices.
Is anybody interested ?
Ooops: I forgot about the default GW ... I'll fix that asap