Debian image: fix boot, add haveged and uncloud-init
This commit is contained in:
parent
a55fc96714
commit
91f114456a
1 changed files with 43 additions and 17 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue