From ac5850d95ed784f7b605a6dd84fb1332b0791e00 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Mon, 25 Apr 2022 01:36:38 +0200 Subject: [PATCH] Add gen_disks.sh script to modify virtual drives We expect the repo root to contain pre-installed Alpine 3.15.4 in raw drive file 'dummydisk.img'. This then gets copied to output//disk.img and the generated files are put into it in order to be used. Beware, this uses hardcoded paths and expects specific disk layout. This relies on how the installation formatted the disk. While the installation procedure is not documented anywhere, it is in essence default setup of Alpine Linux, with minimal tweaks that should not affect behaviour of routing (but still impede reproducibility). The only major difference from default settings is BIRD being pre-installed. Unfortunately, using loop devices and mounting requires root privileges (as far as I know). It should be possible to use some other way, but this is the simplest I know at the moment. --- gen_disks.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 gen_disks.sh diff --git a/gen_disks.sh b/gen_disks.sh new file mode 100755 index 0000000..dafd9cf --- /dev/null +++ b/gen_disks.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +# Run as root. + +set -eux + +mount="$(mktemp --directory)" +trap "rmdir $mount" EXIT + +modprobe loop + +origdir="$(pwd)" + +for dir in output/*/; do + pushd $dir + cp "$origdir/dummydisk.img" "./disk.img" + loop="$(losetup --partscan --show --find ./disk.img)" + mount -t ext4 "${loop}p3" "$mount" + while read what where; do + cp "$what" "$mount$where" + done << END + bird.conf /etc/bird.conf + interfaces /etc/network/interfaces + hosts /etc/hosts + hostname /etc/hostname +END + umount "$mount" + losetup -d "$loop" + popd +done