Browse Source

Use a private network so we can start daemons in the container

tags/nilmbuntu-5
Jim Paris 4 years ago
parent
commit
8b49a30144
2 changed files with 23 additions and 5 deletions
  1. +1
    -1
      README
  2. +22
    -4
      enter.sh

+ 1
- 1
README View File

@@ -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"

+ 22
- 4
enter.sh View File

@@ -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"


Loading…
Cancel
Save