1 | #!/bin/bash |
---|
2 | |
---|
3 | # install debathena into a blank vm, and run tests confirming the install |
---|
4 | # |
---|
5 | # |
---|
6 | # This was developed and tested using VMWare Workstation 9, |
---|
7 | # and mkisofs(2.01)/genisoimage 1.1.11 |
---|
8 | # |
---|
9 | # example usage: |
---|
10 | # -s precise |
---|
11 | # -a i386 |
---|
12 | # -h <vmware host> |
---|
13 | # -i (this was tested using a static IP taken from vmnet8) |
---|
14 | # -p http://<your preseed> |
---|
15 | |
---|
16 | BASEDIR=. |
---|
17 | |
---|
18 | SUITE= |
---|
19 | ARCH= |
---|
20 | IP= |
---|
21 | HOSTNAME= |
---|
22 | PRESEED= |
---|
23 | |
---|
24 | LOGDIR=$BASEDIR/log |
---|
25 | NOW=$(date +"%d-%m-%y") |
---|
26 | LOG=$LOGDIR/"install-test-"$NOW".log" |
---|
27 | |
---|
28 | function usage() { |
---|
29 | cat<< EO |
---|
30 | Usage: -s <suite> -a <architecture> -h <hostname> -i <ip> -p <preseed> |
---|
31 | EO |
---|
32 | } |
---|
33 | |
---|
34 | |
---|
35 | while getopts "s:a:h:i:p:" OPTION |
---|
36 | |
---|
37 | do |
---|
38 | case $OPTION in |
---|
39 | s) |
---|
40 | SUITE=$OPTARG |
---|
41 | ;; |
---|
42 | a) |
---|
43 | ARCH=$OPTARG |
---|
44 | ;; |
---|
45 | h) |
---|
46 | HOSTNAME=$OPTARG |
---|
47 | ;; |
---|
48 | i) |
---|
49 | IP=$OPTARG |
---|
50 | ;; |
---|
51 | p) |
---|
52 | PRESEED=$OPTARG |
---|
53 | ;; |
---|
54 | ?) |
---|
55 | usage |
---|
56 | exit 1 |
---|
57 | ;; |
---|
58 | esac |
---|
59 | done |
---|
60 | |
---|
61 | if [[ -z $HOSTNAME || -z $ARCH || -z $PRESEED || -z $IP ]] ; then |
---|
62 | echo "Empty option. HOSTNAME: $HOSTNAME, ARCH: $ARCH, PRESEED: $PRESEED, IP: $IP" | tee -a $LOG |
---|
63 | usage |
---|
64 | exit 1 |
---|
65 | fi |
---|
66 | |
---|
67 | if [ -d tmp ] ; then |
---|
68 | rm -rf tmp |
---|
69 | fi |
---|
70 | |
---|
71 | mkdir $BASEDIR/tmp |
---|
72 | mkdir $BASEDIR/tmp/isolinux |
---|
73 | TMPDIR=$BASEDIR/tmp |
---|
74 | |
---|
75 | |
---|
76 | echo "creating build files..." | tee -a $LOG |
---|
77 | |
---|
78 | ISOLINUXBIN=/usr/lib/syslinux/isolinux.bin |
---|
79 | |
---|
80 | if [ ! -f $ISOLINUXBIN ] ; then |
---|
81 | echo "isolinux.bin not found at: $ISOLINUXBIN exiting..." | tee -a $LOG |
---|
82 | exit 1 |
---|
83 | fi |
---|
84 | |
---|
85 | cp $ISOLINUXBIN $TMPDIR/isolinux |
---|
86 | |
---|
87 | if [ ! -f $BASEDIR/isolinux/isolinux.cfg ] ; then |
---|
88 | echo "isolinux.cfg not found. exiting..." | tee -a $LOG |
---|
89 | exit 1 |
---|
90 | fi |
---|
91 | |
---|
92 | cp -R $BASEDIR/isolinux $TMPDIR |
---|
93 | |
---|
94 | ISOLINUXCFG=$TMPDIR/isolinux/isolinux.cfg |
---|
95 | |
---|
96 | echo "seeding isolinux.cfg..." | tee -a $LOG |
---|
97 | |
---|
98 | sed -i "s|%HOSTNAME%|$HOSTNAME|g" $ISOLINUXCFG |
---|
99 | sed -i "s|%IP%|$IP|g" $ISOLINUXCFG |
---|
100 | sed -i "s|%PRESEED%|$PRESEED|g" $ISOLINUXCFG |
---|
101 | |
---|
102 | echo "fetching kernel and initrd..." | tee -a $LOG |
---|
103 | wget -q http://mirrors.mit.edu/ubuntu/dists/$SUITE/main/installer-$ARCH/current/images/netboot/ubuntu-installer/$ARCH/linux -O $TMPDIR/linux |
---|
104 | wget -q http://mirrors.mit.edu/ubuntu/dists/$SUITE/main/installer-$ARCH/current/images/netboot/ubuntu-installer/$ARCH/initrd.gz -O $TMPDIR/initrd.gz |
---|
105 | |
---|
106 | echo "creating iso image..." | tee -a $LOG |
---|
107 | |
---|
108 | IMAGENAME=$SUITE-$ARCH-netboot.iso |
---|
109 | |
---|
110 | mkisofs -r -V "Debathena Boot" \ |
---|
111 | -cache-inodes \ |
---|
112 | -J -l -b isolinux/isolinux.bin \ |
---|
113 | -c isolinux/boot.cat -no-emul-boot \ |
---|
114 | -boot-load-size 4 -boot-info-table \ |
---|
115 | -o $IMAGENAME $TMPDIR 2>&1 | tee -a $LOG |
---|
116 | |
---|
117 | if [ ! -f $BASEDIR/$IMAGENAME ] ; then |
---|
118 | echo "iso creation failed. exiting..." | tee -a $LOG |
---|
119 | else |
---|
120 | echo "iso creation success..." | tee -a $LOG |
---|
121 | fi |
---|
122 | |
---|
123 | echo "installing iso into VM image..." | tee -a $LOG |
---|
124 | |
---|
125 | VMWARE_CONFIG=$BASEDIR/vmware_config |
---|
126 | |
---|
127 | #make vmwware boot out virtual disk / iso |
---|
128 | mkdir $TMPDIR/vm |
---|
129 | cp -R $VMWARE_CONFIG/* $TMPDIR/vm |
---|
130 | mv $BASEDIR/$IMAGENAME $TMPDIR/vm |
---|
131 | |
---|
132 | sed -i "s|%ISO%|$IMAGENAME|g" $TMPDIR/vm/default.vmx |
---|
133 | |
---|
134 | vmrun start $TMPDIR/vm/default.vmx 2>&1 | tee -a $LOG |
---|
135 | |
---|
136 | echo "sleeping for 4 hours before launching tests..." | tee -a $LOG |
---|
137 | |
---|
138 | sleep 240m |
---|
139 | |
---|
140 | ATHINFO_VERSION_PASS=`athinfo $HOSTNAME version | grep -c debathena-cluster` |
---|
141 | |
---|
142 | #TODO: get more useful reporting here. The last messages weren't quite working as expected |
---|
143 | if [[ $ATHINFO_VERSION_PASS -ne 1 ]] ; then |
---|
144 | echo "Test Failed." | tee -a $LOG |
---|
145 | else |
---|
146 | echo "Test Passed." | tee -a $LOG |
---|
147 | fi |
---|
148 | |
---|
149 | vmrun stop $TMPDIR/vm/default.vmx 2>&1 | tee -a $LOG |
---|
150 | |
---|
151 | echo "done." |
---|
152 | |
---|
153 | exit 0 |
---|