Created
July 7, 2023 14:06
-
-
Save tfluehmann/36bf4ea77df65ae6d4ae11fe923a098f to your computer and use it in GitHub Desktop.
post-install.sh Hetzner (dropbear initramfs)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
add_rfc3442_hook() { | |
cat << EOF > /etc/initramfs-tools/hooks/add-rfc3442-dhclient-hook | |
#!/bin/sh | |
PREREQ="" | |
prereqs() | |
{ | |
echo "\$PREREQ" | |
} | |
case \$1 in | |
prereqs) | |
prereqs | |
exit 0 | |
;; | |
esac | |
if [ ! -x /sbin/dhclient ]; then | |
exit 0 | |
fi | |
. /usr/share/initramfs-tools/scripts/functions | |
. /usr/share/initramfs-tools/hook-functions | |
mkdir -p \$DESTDIR/etc/dhcp/dhclient-exit-hooks.d/ | |
cp -a /etc/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes \$DESTDIR/etc/dhcp/dhclient-exit-hooks.d/ | |
EOF | |
chmod +x /etc/initramfs-tools/hooks/add-rfc3442-dhclient-hook | |
} | |
# Install hook | |
add_rfc3442_hook | |
# Copy SSH keys for dropbear | |
mkdir -p /etc/dropbear/initramfs | |
cp -a /root/.ssh/authorized_keys /etc/dropbear/initramfs/authorized_keys | |
# Update system | |
apt-get update >/dev/null | |
apt-get -y install cryptsetup-initramfs dropbear-initramfs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment