X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=pretend-boot;h=746f99aad77c7381c8d8fb24a320634eea79fa89;hb=16dfe22b7e5e487f8483d90c82b861b9c9b215c9;hp=1eaf034c0a440549443ddc9ab115b72b830b7202;hpb=f6aa07e800b8176f62f02916f0c5dbf403261f49;p=rrq%2Fsubhost.git diff --git a/pretend-boot b/pretend-boot index 1eaf034..746f99a 100755 --- a/pretend-boot +++ b/pretend-boot @@ -1,9 +1,8 @@ #!/bin/bash # # Boot up subhost as if a vitual machine. +# Allow CONFIG given as environment # -# There is already an existing network namespace of the right name, -# and there are one or more disks at /opt/subhost/$NAME/disk$i #set -x @@ -11,11 +10,16 @@ : ${NSNAME=$NAME} : ${SUBHOST=/opt/subhost/$NAME} : ${TARGET=$SUBHOST/live} -: ${INITRD=$SUBHOST/initrd.gz} : ${CONFIG=$SUBHOST/config} +# sets DISKS=( ... ) and BRIDGES=( ... ) [ -r "$CONFIG" ] && . $CONFIG +if [ -z "$DISKS" ] ; then + echo "Missing CONFIG" >&2 + exit 1 +fi + # Generate a mac address for given arguments pass through 40-bit b2sum # and with 02: prefix. macaddr() { @@ -87,17 +91,17 @@ setup_console() { ln -s $(tty) $CONSOLE } +#################### +# Pretend boot + setup_cables setup_rootfs -setup_console || exit 1 - -# Install the current subhost-init startup script -cp -p $(realpath $(dirname $0))/subhost-init startup $TARGET/ +setup_console ###################################################################### -# Run the subhost +# Run the subhost init ip netns exec $NSNAME unshare --fork --pid --mount-proc --kill-child \ - --uts --ipc --mount --cgroup chroot $TARGET /startup + --uts --ipc --mount --cgroup chroot $TARGET /sbin/init ###################################################################### # Cleanup on exit