2018-02-28 00:42:47 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -eux
|
|
|
|
IMAGE=$1
|
2018-05-24 22:43:11 +00:00
|
|
|
SCRIPT=$2
|
2018-02-28 00:42:47 +00:00
|
|
|
|
|
|
|
lxd init --auto
|
|
|
|
|
2021-06-07 20:36:37 +00:00
|
|
|
lxc launch $IMAGE tester
|
2018-02-28 00:42:47 +00:00
|
|
|
lxc config device add tester code disk source=`pwd` path=/subiquity
|
2021-06-07 20:36:37 +00:00
|
|
|
# copy is allowed to fail, in case the subiquity directory being tested
|
|
|
|
# includes some uncopyable stuff
|
|
|
|
lxc exec tester -- sh -ec "
|
|
|
|
cd ~
|
|
|
|
sudo cp -a /subiquity . || true
|
|
|
|
[ -d ~/subiquity ]
|
|
|
|
"
|
2018-02-28 00:42:47 +00:00
|
|
|
|
|
|
|
attempts=0
|
|
|
|
while ! lxc file pull tester/etc/resolv.conf - 2> /dev/null | grep -q ^nameserver; do
|
|
|
|
sleep 1
|
|
|
|
attempts=$((attempts+1))
|
|
|
|
if [ $attempts -gt 30 ]; then
|
|
|
|
lxc file pull tester/etc/resolv.conf
|
|
|
|
lxc exec tester -- ps aux
|
|
|
|
echo "Network failed to come up after 30 seconds"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if ! lxc file pull tester/etc/resolv.conf - 2> /dev/null | grep ^nameserver | grep -qv 127.0.0.53
|
|
|
|
then
|
|
|
|
echo "systemd-resolved"
|
|
|
|
while ! lxc file pull tester/run/systemd/resolve/resolv.conf - 2> /dev/null | grep -v fe80 | grep -q ^nameserver; do
|
|
|
|
sleep 1
|
|
|
|
attempts=$((attempts+1))
|
|
|
|
if [ $attempts -gt 30 ]; then
|
|
|
|
echo "Network failed to come up after 30 seconds"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2021-06-07 20:36:37 +00:00
|
|
|
lxc exec tester -- sh -ec "
|
|
|
|
cd ~/subiquity
|
|
|
|
./scripts/installdeps.sh
|
|
|
|
$SCRIPT"
|