first-boot-script 658 B

12345678910111213141516171819202122232425262728
  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 [[ $EUID -ne 0 ]]; then
  9. echo "This script cannot work if not super-user. Please run as root" 1>&2
  10. exit 1
  11. fi
  12. for f in $(ls $FIRST_BOOT_SCRIPTS_DIR/*)
  13. do
  14. if [ -x $f ] ; then
  15. echo Executing $f $FIRST_BOOT_BASE_DIR
  16. $f $FIRST_BOOT_BASE_DIR
  17. status=$?
  18. if [ 0 -ne "$status" ] ; then
  19. echo "#ERROR# : script $f did not finish with success status !"
  20. exit $status
  21. fi
  22. fi
  23. done
  24. rm $FIRST_BOOT_BASE_DIR/.mustrun
  25. exit 0