fix shellcheck errors
All checks were successful
ci/woodpecker/push/lint Pipeline was successful
ci/woodpecker/push/build Pipeline was successful

Signed-off-by: Michael Grote <michael.grote@posteo.de>
This commit is contained in:
Michael Grote 2024-06-05 21:10:07 +02:00
parent ad68beab3e
commit cbc3022e31

13
run.sh
View file

@ -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"