#!/bin/bash echo "" echo "##########################################" echo "## FIRSTRUN INIT SCRIPT ##" echo "## WAIT SOME MINUTES FOR CONFIGURATIONS ##" echo "##########################################" echo "" echo "##################" echo "# update ssh key #" echo "##################" echo "" rm -f /etc/ssh/ssh_host* /usr/sbin/dpkg-reconfigure openssh-server /bin/systemctl disable firstrun if [ ! -e /etc/crypttab ]; then echo "" echo "############################" echo "# Expanding root partition #" echo "############################" (echo d; echo n; echo p; echo 1; echo ; echo; echo w) | fdisk /dev/mmcblk0 /bin/systemctl enable secondrun echo "" echo "##################" echo "# reboot #" echo "##################" echo "" /sbin/reboot else echo "" echo "############################" echo "# update dropbear ssh keys #" echo "############################" echo "" rm /etc/dropbear/dropbear_* /usr/sbin/dpkg-reconfigure dropbear echo "" echo "####################" echo "# update initramfs #" echo "####################" echo "" rm /etc/initramfs-tools/stunnel.{csr,key,pem} echo > /etc/initramfs-tools/root/.ssh/authorized_keys rm /etc/initramfs-tools/root/.ssh/id_* rm /etc/initramfs-tools/etc/dropbear/dropbear_* /usr/sbin/update-initramfs -u -k all fi exit 0