source: MondoRescue/branches/3.3/contrib/pbtest@ 3717

Last change on this file since 3717 was 3717, checked in by Bruno Cornec, 5 years ago

minor pbtest improvements

  • Property svn:executable set to *
File size: 2.5 KB
Line 
1#!/bin/bash
2# Test a remote machine such as Fedora, RHEL, SLES
3#
4
5# On RHEL 7.3+
6# for ssh access edit pam.d files to avoid root login by ssh to fail with uid < 1000
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
12DISTRO=rhel-7-x86_64
13#DISTRO=rhel-5-x86_64
14#DISTRO=fedora-20-x86_64
15
16NAME=`pbdistrocheck $DISTRO | grep -E '^Name:' | awk '{print $2}'`
17VER=`pbdistrocheck $DISTRO | grep -E '^Ver:' | awk '{print $2}'`
18ARCH=`pbdistrocheck $DISTRO | grep -E '^Arch:' | awk '{print $2}'`
19D=$DISTRO
20DEST=/users/mondo/small
21DIR=images
22TEMP=temp
23CACHE=cache
24MNT=/mnt2
25KEY=$HOME/.ssh/pb_rsa
26PORT=`ps auxww | grep qemu | grep -w $D | grep -v grep | perl -p -e 's|.*127.0.0.1:([0-9]+)-:.*|$1|'`
27if [ _"$PORT" == _"" ]; then
28 pb -p mondorescue -r branches/3.3 -m $D launchvm
29fi
30
31pb -p mondorescue -r branches/3.3 -m $D sbx2vm MondoRescue mondo mindi mindi-busybox
32cat > /tmp/test << EOF
33#!/bin/bash
34#
35if [ $NAME = "rhel" ]; then
36 REPODIR="/etc/yum.repos.d"
37 REPOCMD="yum"
38elif [ $NAME = "sles" ]; then
39 REPODIR="/etc/zypp/repos.d"
40 REPOCMD="zypper"
41fi
42\$REPOCMD install -y curl
43cd \$REPODIR
44if [ ! -f \$REPODIR/mondorescue.repo ]; then
45 curl ftp://ftp.mondorescue.org/$NAME/$VER/$ARCH/mondorescue.repo -o mondorescue.repo
46fi
47if [ ! -f \$REPODIR/mondorescue-test.repo ]; then
48 curl ftp://ftp.mondorescue.org/test/$NAME/$VER/$ARCH/mondorescue-test.repo -o mondorescue-test.repo
49fi
50if [ $NAME = "rhel" ]; then
51 \$REPOCMD makecache fast
52elif [ $NAME = "sles" ]; then
53 \$REPOCMD ref
54fi
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
60modprobe nfsv3
61mkdir -p $MNT
62mount -o vers=3 10.0.2.2:$DEST $MNT
63mkdir -p $MNT/$DIR $MNT/$TEMP $MNT/$CACHE
64mondoarchive -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
65umount $MNT/
66EOF
67# Now should be OK
68PORT=`ps auxww | grep qemu | grep -w $D | grep -v grep | perl -p -e 's|.*127.0.0.1:([0-9]+)-:.*|$1|'`
69
70ssh -i $KEY -p $PORT root@localhost "rm -rf ./test"
71scp -i $KEY -P $PORT /tmp/test root@localhost:
72ssh -i $KEY -p $PORT root@localhost "chmod 755 ./test ; sh -x ./test"
73
74sudo chown bruno $DEST/temp
75Q=$DEST/temp/test.qemu
76qemu-img create -f qcow2 $Q 7G
77cmd="qemu-kvm -m 2048 -boot d -cdrom $DEST/$DIR/$D-1.iso $Q"
78echo "Calling restore test: $cmd"
79$cmd
Note: See TracBrowser for help on using the repository browser.