#!/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 --preserve=mode,ownership "$origdir/dummydisk.img" "./disk.img" loop="$(losetup --partscan --show --find ./disk.img)" mount -t ext4 "${loop}p2" "$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