deploy 1.0 KB

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. # Licence : GPL v3
  3. # Author: Laurent HUBERT
  4. #
  5. # Deploys the first boot initialization scripts on a system
  6. if [[ $EUID -ne 0 ]]; then
  7. echo "This script cannot work if not super-user. Please run as root" 1>&2
  8. exit 1
  9. fi
  10. SYSTEMD_DIR=/etc/systemd/system
  11. FIRST_BOOT_BASE_DIR=/etc/first-boot
  12. FIRST_BOOT_SCRIPTS_DIR=$FIRST_BOOT_BASE_DIR/scripts
  13. cp first-boot-init.service ${SYSTEMD_DIR}
  14. mkdir -p $FIRST_BOOT_SCRIPTS_DIR
  15. rm $FIRST_BOOT_SCRIPTS_DIR/*
  16. cp first-boot-script $FIRST_BOOT_BASE_DIR/
  17. cp scripts/* $FIRST_BOOT_SCRIPTS_DIR
  18. # Resets the flag file
  19. touch $FIRST_BOOT_BASE_DIR/.mustrun
  20. # Deploys
  21. #https://unix.stackexchange.com/questions/265014/how-to-start-a-script-on-tty-instead-of-asking-for-login-in-systemd
  22. #https://stackoverflow.com/questions/14152026/how-can-i-automatically-login-on-a-tty-and-execute-a-script
  23. #https://unix.stackexchange.com/questions/401759/automatically-login-on-debian-9-2-1-command-line
  24. systemctl enable first-boot-init.service
  25. echo "You can now run rm -r on this directory"
  26. echo "e.g. :"
  27. echo "\$ cd .."
  28. echo "\$ rm -r $(pwd)"