-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest.sh
executable file
·84 lines (68 loc) · 2.06 KB
/
test.sh
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
#!/bin/sh
set -e
# Make sure a 2nd copy doesn't start via run-parts /etc/cron.daily
mv /etc/crontab /etc/crontab.disabled
echo "APT::Periodic::RandomSleep 1;" > /etc/apt/apt.conf.d/short_sleep
echo "APT::Periodic::Verbose 2;" > /etc/apt/apt.conf.d/verbose
# Update every time; don't wait a day
echo "APT::Periodic::Update-Package-Lists -1;" > /etc/apt/apt.conf.d/update_interval
# For 14.04 VM, root mail doesn't go to vagrant by default
if ! grep '^root:' /etc/aliases; then
echo 'root: vagrant' >> /etc/aliases
newaliases
fi
# These are specified as 1 in the default config, but need to be -1 to rerun
#echo "APT::Periodic::Download-Upgradeable-Packages -1;" > /etc/apt/apt.conf.d/download_upgradable_interval # download every time
#echo "APT::Periodic::Unattended-Upgrade -1;" > /etc/apt/apt.conf.d/55upgrade_interval # upgrade every time
# This could be adjusted to be root in /etc/aliases to work on Travis...
inbox=/var/mail/vagrant
if [ -s "$inbox" ]; then
cat /dev/null > /var/mail/vagrant
fi
#rm /var/lib/apt/periodic/*
/etc/cron.daily/apt
echo -n "Waiting for mail in $inbox "
for i in `seq 1 10`; do
if [ -s "$inbox" ]; then
echo -n " received."
break
fi
echo -n .
sleep 1
done
echo
check_presence () {
flags="$1"
descr="$2"
shift 2
status=0
echo "$descr"
for expr in "$@"; do
if grep -qE $flags "$expr" $inbox; then
echo " Ok: $expr"
else
echo " Er: $expr"
status=1
fi
done
return $status
}
check_presence "" "Important parts of email" \
"Subject: unattended-upgrades result for '(lucid64|precise64|ubuntu-14)'" \
"Unattended upgrade returned: True" \
"Packages that (were|are) upgraded:" \
"Package installation log:" \
"All upgrades installed" \
check_presence "" "Ensure at least *something* was installed" \
"Preconfiguring packages" \
"Unpacking (replacement |.+ over )" \
"Setting up" \
# Only included with verbose level 3
#check_presence "" "Counts" \
# "InstCount=" \
# "BrokenCout=0" \
#
#check_presence "-v" "Non-zero installed" \
# "InstCount=0" \
echo
echo "Tests Passed."