fix shellcheck errors
Signed-off-by: Michael Grote <michael.grote@posteo.de>
This commit is contained in:
parent
ad68beab3e
commit
cbc3022e31
1 changed files with 7 additions and 6 deletions
13
run.sh
13
run.sh
|
@ -10,15 +10,16 @@ if [[ -z "$VLANS" ]];then
|
|||
exit 1
|
||||
fi
|
||||
# build interface list with parent interface and vlan ids
|
||||
ALLVLANIF=$(echo -n $VLANS | sed -re "s/\b([0-9]+)/${INTERFACE}.\1/g")
|
||||
ALLVLANIF=$(echo -n "$VLANS" | sed -re "s/\b([0-9]+)/${INTERFACE}.\1/g")
|
||||
|
||||
# get MTU of parent interface
|
||||
MTU=$(ip link show $INTERFACE | grep -Ei 'mtu \d+' | cut -d " " -f2)
|
||||
|
||||
# cleanup non used vlan interfaces
|
||||
for VLAN in $(ls -1 /sys/class/net | grep -E "^${INTERFACE}\\." | grep -Ev "$(echo $ALLVLANIF | tr ' ' '|')") ;do
|
||||
# shellcheck disable=SC2010
|
||||
for VLAN in $(ls -1 /sys/class/net | grep -E "^${INTERFACE}\\." | grep -Ev "$(echo "$ALLVLANIF" | tr ' ' '|')") ;do
|
||||
echo "Deleting orphaned interface: $VLAN"
|
||||
ip link delete $VLAN
|
||||
ip link delete "$VLAN"
|
||||
done
|
||||
|
||||
# for each vlan id
|
||||
|
@ -27,7 +28,7 @@ for VLAN in $VLANS; do
|
|||
# create vlan interface
|
||||
[[ ! -d "/sys/class/net/${VLANIF}" ]] && {
|
||||
echo "Creating interface ${VLANIF}"
|
||||
ip link add link $INTERFACE name "$VLANIF" mtu $MTU type vlan id $VLAN
|
||||
ip link add link $INTERFACE name "$VLANIF" mtu "$MTU" type vlan id "$VLAN"
|
||||
}
|
||||
echo "Bring up $VLANIF interface"
|
||||
ip link set "$VLANIF" up
|
||||
|
@ -38,9 +39,9 @@ for VLAN in $VLANS; do
|
|||
rm "/var/run/udhcpc.${VLANIF}.pid"
|
||||
}
|
||||
echo "Starting dhcp client on ${VLANIF}"
|
||||
udhcpc -b -i $VLANIF -x hostname:"$HOSTNAME" -p "/var/run/udhcpc.${VLANIF}.pid"
|
||||
udhcpc -b -i "$VLANIF" -x hostname:"$HOSTNAME" -p "/var/run/udhcpc.${VLANIF}.pid"
|
||||
done
|
||||
|
||||
echo "Starting mDNS repeater process ... "
|
||||
# run repeater on vlan interfaces
|
||||
exec /bin/mdns-repeater -f $ALLVLANIF
|
||||
exec /bin/mdns-repeater -f "$ALLVLANIF"
|
||||
|
|
Reference in a new issue