first-boot-script 756 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. # Licence : GPL v3
  3. # Author: Laurent HUBERT
  4. #
  5. # Executes each script from scripts dir if they are executable
  6. FIRST_BOOT_BASE_DIR=/etc/first-boot
  7. FIRST_BOOT_SCRIPTS_DIR=$FIRST_BOOT_BASE_DIR/scripts
  8. if [ ! -r /etc/first-boot/.mustrun ]
  9. then
  10. exit 0
  11. fi
  12. if [[ $EUID -ne 0 ]]; then
  13. echo "This script cannot work if not super-user. Please run as root" 1>&2
  14. exit 1
  15. fi
  16. for f in $(ls $FIRST_BOOT_SCRIPTS_DIR/*)
  17. do
  18. if [ -x $f ] ; then
  19. echo Executing $f $FIRST_BOOT_BASE_DIR
  20. $f $FIRST_BOOT_BASE_DIR
  21. status=$?
  22. if [ 0 -ne "$status" ] ; then
  23. echo "#ERROR# : script $f did not finish with success status !"
  24. exit $status
  25. fi
  26. fi
  27. done
  28. rm $FIRST_BOOT_BASE_DIR/.mustrun
  29. systemctl disable first-boot-init.service
  30. exit 0