-
Notifications
You must be signed in to change notification settings - Fork 14
/
run.sh
31 lines (25 loc) · 785 Bytes
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# Exit on error
set -e
HOSTNAME="mDns"
INTERFACE="eth0"
VLANS="20 100"
MTU=$(ip link show "$INTERFACE" | awk '{print $5}')
for VLAN in $VLANS; do
# INTERFACE PROVISION
IFNAME="${INTERFACE}.${VLAN}"
[ ! -d "/sys/class/net/${IFNAME}" ] && {
echo "create interface ${IFNAME}"
ip link add link "$INTERFACE" name "$IFNAME" mtu "$MTU" type vlan id "$VLAN"
}
echo "bring up ${IFNAME} interface"
ip link set "${IFNAME}" up
# DHCP
[ -f "/var/run/udhcpc.${IFNAME}.pid" ] && {
kill "$(cat "/var/run/udhcpc.$IFNAME.pid")" || true
rm "/var/run/udhcpc.$IFNAME.pid"
}
echo "starting dhcp client on ${IFNAME}"
udhcpc -b -i "$IFNAME" -x hostname:"$HOSTNAME" -p "/var/run/udhcpc.${IFNAME}.pid"
done
exec "$@"