Skip to content
Permalink
Browse files

Handle network interface repair during firstboot

It's easier to fix the ens2/ens3 mismatch in the interfaces file from
the firstboot script than from the virt-builder command.

Also drop SSH and other unnecessary packages during firstboot.
  • Loading branch information...
lovett committed Sep 8, 2019
1 parent 8f58ad8 commit be44678d8c8ef40766594d95ae15276b54549233
Showing with 23 additions and 3 deletions.
  1. +4 −3 Makefile
  2. +19 −0 resources/qemu/toils-firstboot.sh
@@ -155,7 +155,6 @@ toils-os.qcow2:
--root-password password:toils \
--append-line /etc/fstab:'LABEL=toils-app /mnt/toils-app ext4 defaults,noatime,noexec 0 0' \
--append-line /etc/fstab:'LABEL=toils-storage /mnt/toils-storage ext4 defaults,noatime,noexec 0 0' \
--run-command 'sed -i "s/ens2/ens3/" /etc/network/interfaces' \
--run-command 'mkdir -p /etc/nginx/sites-enabled' \
--run-command 'mkdir -p /etc/php/7.3/fpm/pool.d' \
--run-command 'mkdir /mnt/toils-app' \
@@ -164,7 +163,7 @@ toils-os.qcow2:
--copy-in resources/qemu/toils-pool.conf:/etc/php/7.3/fpm/pool.d \
--copy-in resources/qemu/toils-setup.sh:/usr/local/sbin \
--copy-in resources/qemu/toils-setup.service:/etc/systemd/system \
--uninstall man-db,git,python2,geoip-database,iso-codes \
--uninstall man-db \
--run-command 'apt autoremove -y' \
--firstboot resources/qemu/toils-firstboot.sh

@@ -191,11 +190,13 @@ toils-storage.qcow2:
testrun:
qemu-system-x86_64 -m 256M \
-accel kvm \
-nic user,hostfwd=tcp::$(LOCAL_PORT)-:80,hostfwd=tcp::2222-:22 \
-nic user,hostfwd=tcp::$(LOCAL_PORT)-:80 \
-nographic \
-drive file=toils-os.qcow2,index=0,media=disk,format=qcow2 \
-drive file=toils-app.img,index=1,media=disk,format=raw \
-drive file=toils-storage.qcow2,index=2,media=disk,format=qcow2

shrink:
qemu-img convert -O qcow2 toils-storage.qcow2 toils-storage-shrunk.qcow2
mv toils-storage-shrunk.qcow2 toils-storage.qcow2

@@ -18,6 +18,11 @@
sed -i 's/GRUB_TIMEOUT=5/GRUB_TIMEOUT=0/' /etc/default/grub
update-grub

# Fix a disparity with the network device name.
NETWORK_INTERFACE=$(find /sys/class/net -name ens* -exec basename {} \;)
sed -i "s/ens2/$NETWORK_INTERFACE/" /etc/network/interfaces
ifup $NETWORK_INTERFACE

# Package installation
apt-get install -y \
composer \
@@ -43,3 +48,17 @@ systemctl restart php7.3-fpm nginx

systemctl enable toils-setup.service
systemctl start toils-setup.service

apt purge -y \
apt-listchanges \
debian-faq \
doc-debian \
geoip-database \
git \
iso-codes \
krb5-locales \
openssh-client \
openssh-server \
python2

apt autoremove -y

0 comments on commit be44678

Please sign in to comment.
You can’t perform that action at this time.