Annotation of embedaddon/strongswan/testing/scripts/chroot, revision 1.1

1.1     ! misho       1: #!/bin/bash
        !             2: 
        !             3: DIR=$(dirname `readlink -f $0`)
        !             4: . $DIR/../testing.conf
        !             5: . $DIR/function.sh
        !             6: 
        !             7: [ `id -u` -eq 0 ] || die "You must be root to run $0"
        !             8: running_any $STRONGSWANHOSTS && die "Please stop test environment before running $0"
        !             9: 
        !            10: [ -n "$1" ] || die "$0 <image to mount: base|root|<guest>>"
        !            11: 
        !            12: check_commands partprobe qemu-nbd
        !            13: 
        !            14: load_qemu_nbd
        !            15: 
        !            16: mkdir -p $LOOPDIR
        !            17: mkdir -p $IMGDIR
        !            18: mkdir -p $SHAREDDIR
        !            19: 
        !            20: echo "Mounting image"
        !            21: 
        !            22: case "$1" in
        !            23: base)
        !            24:        [ -f "$BASEIMG" ] || die "Base image $BASEIMG not found"
        !            25:        log_action "Connecting base image to NBD device $NBDEV"
        !            26:        execute "qemu-nbd -c $NBDEV $BASEIMG"
        !            27:        affected="root and guest"
        !            28:        ;;
        !            29: root)
        !            30:        [ -f "$ROOTIMG" ] || die "Root image $ROOTIMG not found"
        !            31:        log_action "Connecting root image to NBD device $NBDEV"
        !            32:        execute "qemu-nbd -c $NBDEV $ROOTIMG"
        !            33:        affected="guest"
        !            34:        ;;
        !            35: *)
        !            36:        echo $STRONGSWANHOSTS | grep -q "\b$1\b" || die "Guest $1 not found"
        !            37:        GUESTIMG="$IMGDIR/$1.$IMGEXT"
        !            38:        [ -f "$GUESTIMG" ] || die "Guest image $GUESTIMG not found"
        !            39:        log_action "Connecting guest image to NBD device $NBDEV"
        !            40:        execute "qemu-nbd -c $NBDEV $GUESTIMG"
        !            41:        ;;
        !            42: esac
        !            43: 
        !            44: do_on_exit qemu-nbd -d $NBDEV
        !            45: partprobe $NBDEV
        !            46: 
        !            47: log_action "Mounting $NBDPARTITION to $LOOPDIR"
        !            48: execute "mount $NBDPARTITION $LOOPDIR"
        !            49: do_on_exit umount $LOOPDIR
        !            50: 
        !            51: log_action "Mounting proc filesystem to $LOOPDIR/proc"
        !            52: execute "mount -t proc none $LOOPDIR/proc"
        !            53: do_on_exit umount $LOOPDIR/proc
        !            54: 
        !            55: mkdir -p $LOOPDIR/root/shared
        !            56: log_action "Mounting $SHAREDDIR as /root/shared"
        !            57: execute "mount -o bind $SHAREDDIR $LOOPDIR/root/shared"
        !            58: do_on_exit umount $LOOPDIR/root/shared
        !            59: 
        !            60: if [ -n "$affected" ]; then
        !            61: echo
        !            62: echo "Rebuild the $affected images after making changes to this image!"
        !            63: echo
        !            64: fi
        !            65: 
        !            66: export debian_chroot="$1"
        !            67: chroot $LOOPDIR /bin/bash -i

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>