1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
#!/bin/bash
#Network tests
# All NICs are on the same network segment, to flag cabling, switch, or configuration errors (??)
#Correct Ubuntu version installed (could be tricky to determine, so maybe too much effort -- or maybe just display the Ubuntu version and, if the script is interactive, ask the user to verify that it’s what was intended)
# Display version of canonical-certification-server package installed
# Secure ID is set in /etc/xdg/canonical-certification.conf (?)
# A USB2 flash drive is available and is properly prepared with a readable filesystem
# A USB3 flash drive is available and is properly prepared with a readable filesystem, if the machine has USB3 support
# An optical disc is available and has readable files (not a music CD), if the machine has an optical drive
#Hard disks
# All disks have at least one mounted filesystem
# No software RAID
# If over 2^32 sectors on the disk, it should use GPT (HOWEVER, MAAS might no longer be provisioning in this way on BIOS-based systems, so maybe this isn’t a useful test)
# Check kernel version to ensure it hasn’t been updated (?? -- maybe better handled as a Checkbox test?)
# Check local availability of KVM image & possibly download from MAAS server if it’s available there, rather than have Checkbox pull from Internet, which tends to be slow
#Remind user to run screen (or run it automatically?)
#echo $STY
# As final step, could launch c-c-s
logfile=~/install.log
currentuser=$(logname)
debinst="sudo debconf-apt-progress -- aptitude -y install"
#exec > $logfile
pass(){
eval pass${i}=1
}
fail(){
eval pass${i}=0
}
warn(){
eval pass${i}=2
}
info(){
eval pass${i}=3
}
steps="Installed_Ram Virtualization_Support EFI_Mode NICs_enabled IPERF"
yes=1
while getopts "i" opt; do
case $opt in
i) individual="1";;
esac
done
echoname(){
echo -e "\n\e[1;33m============\e[m \e[1;34m$name\e[m \e[1;33m============\e[m"
}
# iperf and iperf3 are available on server specified in /etc/xdg/canonical-certification.conf (NOTE: iperf (2) will eventually become irrelevant)
IPERF(){
name="Iperf"
echoname
if [[ ! -f /etc/xdg/canonical-certification.conf ]]; then
echo -e "canonical-certification-server might not be installed.\nWould you like to install it now? [Y/n]"
read -s -N1 a
if [[ $a == "Y" || $a == "y" || -z $a ]]; then
echo "Installing canonical-certification-server..."
#sudo apt-add-repository -y ppa:hardware-certification/public 1>/dev/null
#sudo apt-get -q update 1>/dev/null
#sudo apt-get -q install -y maas-cert-server 1>/dev/null
sudo touch /etc/xdg/canonical-certification.conf
IPERF
elif [[ $a == "N" || $a == "n" ]]; then
echo
fail
continue
fi
echo "press [ENTER] to continue";read
fi
if [ $(grep ^TEST_TARGET_IPERF /etc/xdg/canonical-certification.conf|wc -l) = 1 ];then
echo "IPERF is configured"
pass
elif [ $(grep ^TEST_TARGET_IPERF /etc/xdg/canonical-certification.conf|wc -l) = 0 ];then
echo -e "TEST_TARGET_IPERF is not configured.\nWould you like to configure it now? [Y/n]"
read -s -N1 a
if [[ $a == "Y" || $a == "y" || -z $a ]]; then
read -e -p "Type the IP Address of the Iperf server: " ip
sudo sed -i "s/#TEST_TARGET_IPERF = your-iperf-server.example.com/TEST_TARGET_IPERF = $ip/g" canonical-certification.conf
IPERF
elif [[ $a == "N" || $a == "n" ]]; then
fail
fi
fi
}
# All NICs are enabled
NICs_enabled(){
name="All NICs enabled"
echoname
for nic in `cat /proc/net/dev|grep ":"|awk -F: '{print $1}'|grep -v lo`
do
state=$(cat /sys/class/net/$nic/operstate)
if [ $state = "up" ]; then
echo "Interface $nic is $state"
pass
elif [ $state = "down" ]; then
echo "Interface $nic is $state"
nicfail=1
fi
done
if [ $nicfail = 1 ]; then
fail
fi
}
#### Installed RAM (STG says 4GiB minimum) ###
Installed_Ram(){
name="Check Installed Ram"
echoname
mem=$(cat /proc/meminfo |grep MemTotal|awk '{print $2}')
if [ $mem -lt 40000000 ] ; then
echo "$mem is less than 4G"
warn
else
echo "$mem is greater than 4G"
pass
fi
}
#CPU virtualization support (VMX/SVM)
Virtualization_Support(){
name="Virtualization Support"
echoname
cat /proc/cpuinfo |egrep "vmx|svm" >/dev/null
if [ $? = 0 ]; then
echo "System has virtualization support"
pass
else
echo "System does not have virtualization support"
fail
fi
}
#EFI-mode installation (redundant with Checkbox test for same, but maybe good to warn about this issue before running Checkbox)
EFI_Mode(){
name="EFI-mode installation"
echoname
if [ -d /sys/firmware/efi ]; then
echo "This is an EFI Mode installation"
info
elif [ ! -d /sys/firmware/efi ]; then
echo "This is not an EFI Mode installation"
info
fi
}
ask() {
for i in $steps
do
printf "Do you want to check "
printf "\e[1;34m$i\e[m"
printf "? [Y/n] "
read -s -N1 a
if [[ $a == "Y" || $a == "y" ]]; then
eval "check""$i"="y"
echo -e "\033[1;32mYES\033[m"
elif [[ $a == "N" || $a == "n" ]]; then
eval "check""$i"="n"
echo -e "\033[1;31mNO\033[m"
else
eval "check""$i"="y"
echo -e "\033[1;32mYES\033[m"
fi
done
}
runchoices() {
echo
for i in $steps
do
eval "status=\$check${i}"
if [[ $status == "y" ]] || [[ "$yes" == "1" ]]; then
#echo -e "\n\e[1;33m============\e[m \e[1;34m$i\e[m \e[1;33m============\e[m"
#"setup""$i"
"$i"
echo
# read -p "Press any key to continue"
# echo
else
echo -e "\e[1;31mskipping\e[m \e[1;34m$i\e[m"
fi
done
}
report() {
#echo -e "\nReport:\n"
echo -e "\n\e[1;33m============\e[m \e[1;34mReport\e[m \e[1;33m============\e[m\n"
for i in $steps
do
eval "status=\$pass${i}"
# echo "status = $status"
if [ $status = "1" ];then
printf "%30s" "$i "
printf "%0.1s" "-"{1..20}
printf "\e[1;32m Passed\e[m\n"
elif [ $status = "0" ];then
printf "%30s" "$i "
printf "%0.1s" "-"{1..20}
printf "\e[1;31m Failed\e[m\n"
elif [ $status = "2" ];then
printf "%30s" "$i "
printf "%0.1s" "-"{1..20}
printf "\e[1;33m Warning\e[m\n"
elif [ $status = "3" ];then
printf "%30s" "$i "
printf "%0.1s" "-"{1..20}
printf "\e[1;37m Informational\e[m\n"
fi
done
# echo -e "\nIs this correct? [Y/n]"
# read -s -N1 a
# if [[ $a == "Y" || $a == "y" ]]; then
# echo
# runchoices
# else
# clear
# ask
# summary
# fi
}
if [ "$individual" = "1" ]; then
# echo -e "\n============= Running everything ==============\n\n"
echo ""
ask
summary
else
runchoices
fi
report
|