1
0
mirror of https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git synced 2025-12-14 19:02:45 +03:00
tiny-cloud/sbin/assemble-interfaces
Natanael Copa 85108e958b Fix vim modelines and make more readable
Add missing trailing :

Use filetype=sh instead of ft=sh to make it more readable.
2023-05-24 14:50:02 +00:00

45 lines
875 B
Bash
Executable File

#!/bin/sh
# vim:set filetype=sh:
set -e
IFACE_CFG="$ROOT/etc/network/interfaces"
IFACE_DIR="${IFACE_CFG}.d"
cd "$IFACE_DIR"
cat > "$IFACE_CFG.new" <<EOT
# NOTE: $0 rewrites this file. Edit files in
# /etc/network/interfaces.d/ to persist any customizations.
EOT
# existing loopback and eths
for i in $ROOT/sys/class/net/*; do
IFACE="$(basename "$i")"
case $IFACE in
lo|eth*)
[ ! -f "$IFACE" ] && sed -e "s/%%/$IFACE/g" DEFAULT > "$IFACE"
printf "%s\n\n" "$(cat "$IFACE")" >> "$IFACE_CFG.new"
;;
*) continue ;;
esac
done
# all the rest
for i in "$IFACE_DIR"/*; do
IFACE="$(basename "$i")"
case $IFACE in
DEFAULT|lo|eth*)
continue
;;
*)
printf "%s\n\n" "$(cat "$IFACE")" >> "$IFACE_CFG.new"
;;
esac
done
# install new interfaces config
[ -f "$IFACE_CFG" ] && cp -a "$IFACE_CFG" "$IFACE_CFG.bak"
mv "$IFACE_CFG.new" "$IFACE_CFG"