firstrun 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. echo ""
  3. echo "##########################################"
  4. echo "## FIRSTRUN INIT SCRIPT ##"
  5. echo "## WAIT SOME MINUTES FOR CONFIGURATIONS ##"
  6. echo "##########################################"
  7. echo ""
  8. echo "##################"
  9. echo "# update ssh key #"
  10. echo "##################"
  11. echo ""
  12. rm -f /etc/ssh/ssh_host*
  13. /usr/sbin/dpkg-reconfigure openssh-server
  14. /bin/systemctl disable firstrun
  15. if [ ! -e /etc/crypttab ]; then
  16. echo ""
  17. echo "############################"
  18. echo "# Expanding root partition #"
  19. echo "############################"
  20. (echo d; echo n; echo p; echo 1; echo ; echo; echo w) | fdisk /dev/mmcblk0
  21. /bin/systemctl enable secondrun
  22. echo ""
  23. echo "##################"
  24. echo "# reboot #"
  25. echo "##################"
  26. echo ""
  27. /sbin/reboot
  28. else
  29. echo ""
  30. echo "############################"
  31. echo "# update dropbear ssh keys #"
  32. echo "############################"
  33. echo ""
  34. rm /etc/dropbear/dropbear_*
  35. /usr/sbin/dpkg-reconfigure dropbear
  36. echo ""
  37. echo "####################"
  38. echo "# update initramfs #"
  39. echo "####################"
  40. echo ""
  41. rm /etc/initramfs-tools/stunnel.{csr,key,pem}
  42. echo > /etc/initramfs-tools/root/.ssh/authorized_keys
  43. rm /etc/initramfs-tools/root/.ssh/id_*
  44. rm /etc/initramfs-tools/etc/dropbear/dropbear_*
  45. /usr/sbin/update-initramfs -u -k all
  46. fi
  47. exit 0