[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 | #
|
---|
[3735] | 11 | #DISTRO=sles-15-x86_64
|
---|
| 12 | DISTRO=sles-12-x86_64
|
---|
| 13 | #DISTRO=rhel-8-x86_64
|
---|
| 14 | #DISTRO=rhel-7-x86_64
|
---|
[3700] | 15 | #DISTRO=rhel-5-x86_64
|
---|
| 16 | #DISTRO=fedora-20-x86_64
|
---|
| 17 |
|
---|
| 18 | NAME=`pbdistrocheck $DISTRO | grep -E '^Name:' | awk '{print $2}'`
|
---|
| 19 | VER=`pbdistrocheck $DISTRO | grep -E '^Ver:' | awk '{print $2}'`
|
---|
| 20 | ARCH=`pbdistrocheck $DISTRO | grep -E '^Arch:' | awk '{print $2}'`
|
---|
| 21 | D=$DISTRO
|
---|
| 22 | DEST=/users/mondo/small
|
---|
| 23 | DIR=images
|
---|
| 24 | TEMP=temp
|
---|
| 25 | CACHE=cache
|
---|
[3717] | 26 | MNT=/mnt2
|
---|
[3700] | 27 | KEY=$HOME/.ssh/pb_rsa
|
---|
[3717] | 28 | PORT=`ps auxww | grep qemu | grep -w $D | grep -v grep | perl -p -e 's|.*127.0.0.1:([0-9]+)-:.*|$1|'`
|
---|
| 29 | if [ _"$PORT" == _"" ]; then
|
---|
[3700] | 30 | pb -p mondorescue -r branches/3.3 -m $D launchvm
|
---|
| 31 | fi
|
---|
| 32 |
|
---|
| 33 | pb -p mondorescue -r branches/3.3 -m $D sbx2vm MondoRescue mondo mindi mindi-busybox
|
---|
| 34 | cat > /tmp/test << EOF
|
---|
[3707] | 35 | #!/bin/bash
|
---|
| 36 | #
|
---|
| 37 | if [ $NAME = "rhel" ]; then
|
---|
| 38 | REPODIR="/etc/yum.repos.d"
|
---|
| 39 | REPOCMD="yum"
|
---|
| 40 | elif [ $NAME = "sles" ]; then
|
---|
| 41 | REPODIR="/etc/zypp/repos.d"
|
---|
[3735] | 42 | REPOCMD="zypper --gpg-auto-import-keys --non-interactive"
|
---|
[3707] | 43 | fi
|
---|
| 44 | \$REPOCMD install -y curl
|
---|
| 45 | cd \$REPODIR
|
---|
| 46 | if [ ! -f \$REPODIR/mondorescue.repo ]; then
|
---|
[3700] | 47 | curl ftp://ftp.mondorescue.org/$NAME/$VER/$ARCH/mondorescue.repo -o mondorescue.repo
|
---|
| 48 | fi
|
---|
[3707] | 49 | if [ ! -f \$REPODIR/mondorescue-test.repo ]; then
|
---|
[3700] | 50 | curl ftp://ftp.mondorescue.org/test/$NAME/$VER/$ARCH/mondorescue-test.repo -o mondorescue-test.repo
|
---|
| 51 | fi
|
---|
[3707] | 52 | if [ $NAME = "rhel" ]; then
|
---|
[3735] | 53 | rpm -q epel-release
|
---|
| 54 | if [ \$? -ne 0 ]; then
|
---|
| 55 | dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-$VER.noarch.rpm
|
---|
| 56 | fi
|
---|
| 57 | \$REPOCMD makecache
|
---|
[3707] | 58 | elif [ $NAME = "sles" ]; then
|
---|
| 59 | \$REPOCMD ref
|
---|
| 60 | fi
|
---|
| 61 | \$REPOCMD install -y nfs-utils
|
---|
| 62 | # To take test repo first do it that way
|
---|
| 63 | \$REPOCMD install -y mindi
|
---|
| 64 | \$REPOCMD install -y mondo
|
---|
| 65 | \$REPOCMD update -y mondo mindi perl-MondoRescue mindi-busybox
|
---|
[3718] | 66 | rpm -aq | grep -Ei 'mondo|mindi'
|
---|
[3700] | 67 | modprobe nfsv3
|
---|
[3717] | 68 | mkdir -p $MNT
|
---|
[3700] | 69 | mount -o vers=3 10.0.2.2:$DEST $MNT
|
---|
| 70 | mkdir -p $MNT/$DIR $MNT/$TEMP $MNT/$CACHE
|
---|
[3717] | 71 | 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] | 72 | umount $MNT/
|
---|
| 73 | EOF
|
---|
| 74 | # Now should be OK
|
---|
[3717] | 75 | PORT=`ps auxww | grep qemu | grep -w $D | grep -v grep | perl -p -e 's|.*127.0.0.1:([0-9]+)-:.*|$1|'`
|
---|
[3700] | 76 |
|
---|
[3717] | 77 | ssh -i $KEY -p $PORT root@localhost "rm -rf ./test"
|
---|
| 78 | scp -i $KEY -P $PORT /tmp/test root@localhost:
|
---|
| 79 | ssh -i $KEY -p $PORT root@localhost "chmod 755 ./test ; sh -x ./test"
|
---|
[3700] | 80 |
|
---|
| 81 | sudo chown bruno $DEST/temp
|
---|
| 82 | Q=$DEST/temp/test.qemu
|
---|
| 83 | qemu-img create -f qcow2 $Q 7G
|
---|
| 84 | cmd="qemu-kvm -m 2048 -boot d -cdrom $DEST/$DIR/$D-1.iso $Q"
|
---|
| 85 | echo "Calling restore test: $cmd"
|
---|
| 86 | $cmd
|
---|