From: Ralph Ronnquist Date: Sat, 26 Mar 2022 09:18:42 +0000 (+1100) Subject: revise installation of e/n/i file X-Git-Tag: deb_0.1~11 X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=7c240a57cac965924a90d04a24473a0387c36089;p=rrq%2Foverlay-boot.git revise installation of e/n/i file --- diff --git a/functions b/functions index 0b01df8..8c1b45c 100644 --- a/functions +++ b/functions @@ -15,18 +15,22 @@ config() { eval echo "$1=\$$1" } -# Unless the subhost already has a private /etc/network/interfaces, -# install an "empty" one +# Install a default $1/etc/network/interfaces on the subhost root $1 setup_networking() { - [ -r $UPPER/etc/network/interfaces ] && return 0 - [ "$UPPER/etc/network" = "/etc/network" ] && exit 1 - mkdir -p $UPPER/etc/network - cat < $UPPER/etc/network/interfaces + [ -r $1/etc/network/interfaces ] && return 0 + mkdir -p $1/etc/network + cat <> $1/etc/network/interfaces # Generated for $NAME subhost auto lo iface lo inet loopback EOF - return 1 + for IF in $(ip netns exec $NAME ip link show | grep "^eth") ; do + cat <> $1/etc/network/interfaces + +auto eth$i +iface eth$i inet manual +EOF + done } # Setup the network namespace for the given $CABLES @@ -36,19 +40,12 @@ setup_veth_cables() { NETNS="$1" shift 1 i=0 - ADD=false - setup_networking || ADD=true for C in "$@" ; do IF=$NETNS$i MAC="${C#*=}" [ -z "$MAC" ] || MAC="address $MAC" ip link add $IF type veth peer name eth$i $MAC netns $NETNS ip link set $IF up - $ADD && cat <> $UPPER/etc/network/interfaces - -auto eth$i -iface eth$i inet manual -EOF BR="${C%=*}" if [ -z "$BR" ] ; then ip link set $IF @@ -118,10 +115,11 @@ setup_overlay() { mkdir "$UPPER/dev/pts" chmod 1777 "$UPPER/dev/shm" + # all good so far ; now avoid using the host's networking setup + setup_networking "$UPPER" + OLY="-olowerdir=$3,upperdir=$UPPER,workdir=$5" - if mount -t overlay "$OLY" $1 $2 ; then - : # all good - else + if ! mount -t overlay "$OLY" $1 $2 ; then umount -R "$UPPER/dev" umount "$UPPER/run" die "Cannot set up the overlay mount $2" diff --git a/overlay-boot b/overlay-boot index 5e6bef9..75939fe 100755 --- a/overlay-boot +++ b/overlay-boot @@ -44,10 +44,11 @@ config CABLES "" config START "networking ssh" config SUBSHELL /bin/sh -# Setup virtual cabling and subhost's /etc/network/interfaces +# Setup virtual cabling setup_veth_cables $NAME $CABLES # Set up the mount for this subhost, including a new tmpfs on its /run +# and a default $UPPER/etc/network/interfaces if needed echo setup_overlay "$NAME" "$LIVE" "$LOWER" "$UPPER" "$WORK" setup_overlay "$NAME" "$LIVE" "$LOWER" "$UPPER" "$WORK"