[3700] | 1 | #!/bin/bash
|
---|
[3707] | 2 | # Test a remote machine such as Fedora, RHEL, SLES
|
---|
[3700] | 3 | #
|
---|
| 4 |
|
---|
[3707] | 5 | # On RHEL 7.3+
|
---|
| 6 | # for ssh access edit pam.d files to avoid root login by ssh to fail with uid < 1000
|
---|
[3717] | 7 | # Install on it perl perl-Data-Dumper and perl-YAML
|
---|
| 8 | # setup that VM with pb -p pb -m $DISTRO sbx2setupvm
|
---|
| 9 | # setup that VM after with pb -p mondorescue -m $DISTRO prepvm
|
---|
| 10 | #
|
---|
| 11 | #DISTRO=sles-12-x86_64
|
---|
[3700] | 12 | DISTRO=rhel-7-x86_64
|
---|
| 13 | #DISTRO=rhel-5-x86_64
|
---|
| 14 | #DISTRO=fedora-20-x86_64
|
---|
| 15 |
|
---|
| 16 | NAME=`pbdistrocheck $DISTRO | grep -E '^Name:' | awk '{print $2}'`
|
---|
| 17 | VER=`pbdistrocheck $DISTRO | grep -E '^Ver:' | awk '{print $2}'`
|
---|
| 18 | ARCH=`pbdistrocheck $DISTRO | grep -E '^Arch:' | awk '{print $2}'`
|
---|
| 19 | D=$DISTRO
|
---|
| 20 | DEST=/users/mondo/small
|
---|
| 21 | DIR=images
|
---|
| 22 | TEMP=temp
|
---|
| 23 | CACHE=cache
|
---|
[3717] | 24 | MNT=/mnt2
|
---|
[3700] | 25 | KEY=$HOME/.ssh/pb_rsa
|
---|
[3717] | 26 | PORT=`ps auxww | grep qemu | grep -w $D | grep -v grep | perl -p -e 's|.*127.0.0.1:([0-9]+)-:.*|$1|'`
|
---|
| 27 | if [ _"$PORT" == _"" ]; then
|
---|
[3700] | 28 | pb -p mondorescue -r branches/3.3 -m $D launchvm
|
---|
| 29 | fi
|
---|
| 30 |
|
---|
| 31 | pb -p mondorescue -r branches/3.3 -m $D sbx2vm MondoRescue mondo mindi mindi-busybox
|
---|
| 32 | cat > /tmp/test << EOF
|
---|
[3707] | 33 | #!/bin/bash
|
---|
| 34 | #
|
---|
| 35 | if [ $NAME = "rhel" ]; then
|
---|
| 36 | REPODIR="/etc/yum.repos.d"
|
---|
| 37 | REPOCMD="yum"
|
---|
| 38 | elif [ $NAME = "sles" ]; then
|
---|
| 39 | REPODIR="/etc/zypp/repos.d"
|
---|
| 40 | REPOCMD="zypper"
|
---|
| 41 | fi
|
---|
| 42 | \$REPOCMD install -y curl
|
---|
| 43 | cd \$REPODIR
|
---|
| 44 | if [ ! -f \$REPODIR/mondorescue.repo ]; then
|
---|
[3700] | 45 | curl ftp://ftp.mondorescue.org/$NAME/$VER/$ARCH/mondorescue.repo -o mondorescue.repo
|
---|
| 46 | fi
|
---|
[3707] | 47 | if [ ! -f \$REPODIR/mondorescue-test.repo ]; then
|
---|
[3700] | 48 | curl ftp://ftp.mondorescue.org/test/$NAME/$VER/$ARCH/mondorescue-test.repo -o mondorescue-test.repo
|
---|
| 49 | fi
|
---|
[3707] | 50 | if [ $NAME = "rhel" ]; then
|
---|
| 51 | \$REPOCMD makecache fast
|
---|
| 52 | elif [ $NAME = "sles" ]; then
|
---|
| 53 | \$REPOCMD ref
|
---|
| 54 | fi
|
---|
| 55 | \$REPOCMD install -y nfs-utils
|
---|
| 56 | # To take test repo first do it that way
|
---|
| 57 | \$REPOCMD install -y mindi
|
---|
| 58 | \$REPOCMD install -y mondo
|
---|
| 59 | \$REPOCMD update -y mondo mindi perl-MondoRescue mindi-busybox
|
---|
[3718] | 60 | rpm -aq | grep -Ei 'mondo|mindi'
|
---|
[3700] | 61 | modprobe nfsv3
|
---|
[3717] | 62 | mkdir -p $MNT
|
---|
[3700] | 63 | mount -o vers=3 10.0.2.2:$DEST $MNT
|
---|
| 64 | mkdir -p $MNT/$DIR $MNT/$TEMP $MNT/$CACHE
|
---|
[3717] | 65 | mondoarchive -N -G -K 99 -E '/home|/var/log|/usr/share/doc|/usr/src|/usr/share/texmf|/mnt|/mnt2' -s 4480m -n 10.0.2.2:$DEST -d $DIR -p $D -z -O -S $MNT/$CACHE -T $MNT/$TEMP
|
---|
[3700] | 66 | umount $MNT/
|
---|
| 67 | EOF
|
---|
| 68 | # Now should be OK
|
---|
[3717] | 69 | PORT=`ps auxww | grep qemu | grep -w $D | grep -v grep | perl -p -e 's|.*127.0.0.1:([0-9]+)-:.*|$1|'`
|
---|
[3700] | 70 |
|
---|
[3717] | 71 | ssh -i $KEY -p $PORT root@localhost "rm -rf ./test"
|
---|
| 72 | scp -i $KEY -P $PORT /tmp/test root@localhost:
|
---|
| 73 | ssh -i $KEY -p $PORT root@localhost "chmod 755 ./test ; sh -x ./test"
|
---|
[3700] | 74 |
|
---|
| 75 | sudo chown bruno $DEST/temp
|
---|
| 76 | Q=$DEST/temp/test.qemu
|
---|
| 77 | qemu-img create -f qcow2 $Q 7G
|
---|
| 78 | cmd="qemu-kvm -m 2048 -boot d -cdrom $DEST/$DIR/$D-1.iso $Q"
|
---|
| 79 | echo "Calling restore test: $cmd"
|
---|
| 80 | $cmd
|
---|