Debian image: fix boot, add haveged and uncloud-init

This commit is contained in:
fnux 2020-01-26 17:52:19 +01:00
parent a55fc96714
commit 91f114456a

View file

@ -108,26 +108,12 @@ deb-src http://security.debian.org/debian-security $RELEASE/updates main
EOF EOF
run_root apt-get update 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. # Initialize base services.
run_root systemd-machine-id-setup run_root systemd-machine-id-setup
run_root ln -sf /usr/share/zoneinfo/UTC /etc/localtime run_root ln -sf /usr/share/zoneinfo/UTC /etc/localtime
run_root systemctl enable systemd-timesyncd.service 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. # Generate fstab file.
boot_uuid=$(blkid --match-tag UUID --output value "${NBD_DEVICE}p1") boot_uuid=$(blkid --match-tag UUID --output value "${NBD_DEVICE}p1")
root_uuid=$(blkid --match-tag UUID --output value "${NBD_DEVICE}p2") 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 UUID=$root_uuid / ext4 rw,relatime,data=ordered 0 1
EOF 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. # Reset systemd's environment.
run_root rm -f /etc/machine-id run_root rm -f /etc/machine-id
run_root touch /etc/machine-id run_root touch /etc/machine-id
rm -f /var/lib/systemd/random-seed 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. # Remove temporary files and reclaim freed disk space.
run_root apt-get clean run_root apt-get clean
# FIXME: add fnux's SSH key for testing purposes. # Remove resolv.conf, as it is handled by uncloud-init.
mkdir -p /mnt/root/.ssh run_root rm /etc/resolv.conf
curl https://key.wf/fnux > /mnt/root/.ssh/authorized_keys
# Make sure everything is written to disk before exiting. # Make sure everything is written to disk before exiting.
sync sync