firstrun 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/bash
  2. ### BEGIN INIT INFO
  3. # Provides: firstrun
  4. # Required-Start: $all
  5. # Required-Stop:
  6. # Should-Start:
  7. # Default-Start: 2 3 4 5
  8. # Default-Stop: 0 1 6
  9. # Short-Description: Script to run when first starting
  10. # Description: Something needs to be done when is
  11. # starting at first time.
  12. # regenerate ssh host key
  13. # expanding root partition
  14. # run depmod
  15. ### END INIT INFO
  16. # script from https://github.com/igorpecovnik/lib
  17. # modified by https://github.com/bleuchtang/sunxi-debian
  18. N=/etc/init.d/firstrun
  19. case "$1" in
  20. start)
  21. echo ""
  22. echo "##########################################"
  23. echo "## FIRSTRUN INIT SCRIPT ##"
  24. echo "## WAIT SOME MINUTES FOR CONFIGURATIONS ##"
  25. echo "##########################################"
  26. echo ""
  27. echo "######################"
  28. echo "# ssh key generation #"
  29. echo "######################"
  30. echo ""
  31. rm -f /etc/ssh/ssh_host*
  32. dpkg-reconfigure openssh-server
  33. echo ""
  34. echo "############################"
  35. echo "# Expanding root partition #"
  36. echo "############################"
  37. echo ""
  38. (echo d; echo n; echo p; echo 1; echo ; echo; echo w) | fdisk /dev/mmcblk0
  39. /sbin/insserv secondrun
  40. echo ""
  41. echo "##################"
  42. echo "# Running depmod #"
  43. echo "##################"
  44. echo ""
  45. /sbin/depmod -a
  46. echo ""
  47. echo "##################"
  48. echo "# Reboot #"
  49. echo "##################"
  50. echo ""
  51. /sbin/insserv -r firstrun
  52. /sbin/insserv secondrun
  53. /sbin/reboot
  54. ;;
  55. *)
  56. echo "Usage: $N {start}" >&2
  57. exit 1
  58. ;;
  59. esac
  60. exit 0