From 91f114456a70d850a594f82c926cef1e91bafea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Floure?= Date: Sun, 26 Jan 2020 17:52:19 +0100 Subject: [PATCH] Debian image: fix boot, add haveged and uncloud-init --- debian-uncloud-image.sh | 60 +++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 17 deletions(-) diff --git a/debian-uncloud-image.sh b/debian-uncloud-image.sh index a691920..beaf87e 100755 --- a/debian-uncloud-image.sh +++ b/debian-uncloud-image.sh @@ -108,26 +108,12 @@ deb-src http://security.debian.org/debian-security $RELEASE/updates main EOF run_root apt-get update -# Install RDNSSD for DNS discovery from router advertisement. The service is enabled by default. -run_root apt-get install -y rdnssd - # Initialize base services. run_root systemd-machine-id-setup run_root ln -sf /usr/share/zoneinfo/UTC /etc/localtime run_root systemctl enable systemd-timesyncd.service -# Install kernel and bootloader. Do not autoconfigure grub. -run_root echo "grub-pc grub-pc/install_devices_empty boolean true" | debconf-set-selections -run_root DEBIAN_FRONTEND=noninteractive apt-get -y install locales linux-base linux-image-generic grub-pc - -# Configure grub. -run_root grub-install --target=i386-pc "${NBD_DEVICE}" -run_root grub-mkconfig -o /boot/grub/grub.cfg - -# Install en configure SSH daemon. The service is enabled by default. -run_root apt-get -y install openssh-server - # Generate fstab file. boot_uuid=$(blkid --match-tag UUID --output value "${NBD_DEVICE}p1") root_uuid=$(blkid --match-tag UUID --output value "${NBD_DEVICE}p2") @@ -136,17 +122,57 @@ UUID=$boot_uuid /boot ext4 rw,relatime,data=ordered 0 2 UUID=$root_uuid / ext4 rw,relatime,data=ordered 0 1 EOF +# Install kernel and bootloader. Do not autoconfigure grub. +run_root echo "grub-pc grub-pc/install_devices_empty boolean true" | debconf-set-selections +run_root DEBIAN_FRONTEND=noninteractive apt-get -y install locales linux-base linux-image-$ARCH grub-pc + +# Configure grub. +run_root grub-install --target=i386-pc "${NBD_DEVICE}" +sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT=\"quiet\"/GRUB_CMDLINE_LINUX_DEFAULT=\"\"/" /mnt/etc/default/grub +sed -i "s/GRUB_CMDLINE_LINUX=\"\"/GRUB_CMDLINE_LINUX=\"root=UUID=$root_uuid\"/" /mnt/etc/default/grub +run_root grub-mkconfig -o /boot/grub/grub.cfg + +# Install en configure SSH daemon. The service is enabled by default. +run_root apt-get -y install openssh-server + +# Use haveged as entropy source. +run_root apt-get -y install haveged + +# Manually install uncloud-init. +uncloud_init_dir=/tmp/uncloud-init +run_root apt-get install -y git curl grep make + +mkdir -p "$uncloud_init_dir" +run_root git clone https://code.ungleich.ch/uncloud/uncloud-init.git "$uncloud_init_dir" +run_root make -C "$uncloud_init_dir" install +run_root rm -r "$uncloud_init_dir" + +run_root systemctl enable uncloud-init + # Reset systemd's environment. run_root rm -f /etc/machine-id run_root touch /etc/machine-id rm -f /var/lib/systemd/random-seed +# Manually install uncloud-init. +uncloud_init_dir=/tmp/uncloud-init +run_root apt-get install -y git curl grep make + +mkdir -p "$uncloud_init_dir" +run_root git clone https://code.ungleich.ch/uncloud/uncloud-init.git "$uncloud_init_dir" +run_root make -C "$uncloud_init_dir" install +run_root rm -r "$uncloud_init_dir" + +run_root systemctl enable uncloud-init + +# Install RDNSSD for DNS discovery from router advertisement. The service is enabled by default. +run_root apt-get install -y rdnssd + # Remove temporary files and reclaim freed disk space. run_root apt-get clean -# FIXME: add fnux's SSH key for testing purposes. -mkdir -p /mnt/root/.ssh -curl https://key.wf/fnux > /mnt/root/.ssh/authorized_keys +# Remove resolv.conf, as it is handled by uncloud-init. +run_root rm /etc/resolv.conf # Make sure everything is written to disk before exiting. sync