diff --git a/README b/README index 9c89d27..eaa9419 100644 --- a/README +++ b/README @@ -28,6 +28,6 @@ cleanup.sh SHORT VERSION: - sudo apt-get install squashfs-tools xorriso syslinux + sudo apt-get install squashfs-tools xorriso syslinux systemd-container time sudo sh -c "env BUILD_CONFIG=12.10 ./full-rebuild.sh" time sudo sh -c "env BUILD_CONFIG=13.04 ./full-rebuild.sh" diff --git a/enter.sh b/enter.sh index 924e81f..c8b24a9 100755 --- a/enter.sh +++ b/enter.sh @@ -16,6 +16,22 @@ fi UNIT=nilmbuntu-run-$VERSION MACH=nilmbuntu-$VERSION +setup_networking() { + # We use a virtual ethernet adapter -- this requires that + # systemd-networkd is installed and running on the host. + if ! systemctl is-active systemd-networkd ; then + echo "Starting systemd-networkd" + systemctl start systemd-networkd + fi + + # However, the current systemd-networkd from Debian is broken and + # won't enable masquerading -- so do it manually + IFACE=$(ip -4 route list default | awk '{print $5}') + echo 1 > /proc/sys/net/ipv4/ip_forward + iptables -t nat -D POSTROUTING -o $IFACE -j MASQUERADE >/dev/null || true + iptables -t nat -A POSTROUTING -o $IFACE -j MASQUERADE +} + kill_container() { # Kill any running container if systemctl --quiet is-active $UNIT ; then @@ -41,13 +57,13 @@ kill_container() { } start_container() { - # Start the container kill_container echo "Starting container..." systemd-run --unit=$UNIT systemd-nspawn \ --quiet \ --keep-unit \ --boot \ + --network-veth \ --directory $(realpath $FS) \ --machine $MACH echo "Waiting..." @@ -87,6 +103,7 @@ start_container run "resolvconf --disable-updates" run "echo 'nameserver 8.8.8.8' > /run/resolvconf/resolv.conf" +run "hostnamectl --transient set-hostname nilmbuntu" #run "dbus-uuidgen > /var/lib/dbus/machine-id" #run "dpkg-divert --local --rename --add /sbin/initctl" @@ -103,10 +120,11 @@ fi echo "Cleaning up..." -# Manually clean up some unnecessary things that show up after booting -# an image and installing packages. This doesn't get everything, but -# what's left should be fine. +# Manually clean up some things that show up after booting an image +# and installing packages. This doesn't get everything, but what's +# left should be fine. run "apt-get clean" +run "> /etc/machine-id" run "rm -f /core /boot/grub/grubenv" run "rm -f /var/lib/systemd/random-seed" run "rm -f /var/lib/ubuntu-drivers-common/last_gfx_boot"