configure.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env bash
  2. set -e # Exit immediately if a command exits with a non-zero status.
  3. ROOT_FOLDER="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/..)"
  4. echo
  5. echo "======================================"
  6. if [[ -f "${ROOT_FOLDER}/state/configured" ]]; then
  7. echo "=========== RECONFIGURING ============"
  8. else
  9. echo "============ CONFIGURING ============="
  10. fi
  11. echo "=============== TIPI ================="
  12. echo "======================================"
  13. echo
  14. # Install ansible if not installed
  15. if ! command -v ansible-playbook > /dev/null; then
  16. echo "Installing Ansible..."
  17. sudo apt-get update
  18. sudo apt-get install python3 python3-pip -y
  19. sudo pip3 install ansible
  20. fi
  21. # Create seed file with cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
  22. if [[ ! -f "${ROOT_FOLDER}/state/seed" ]]; then
  23. echo "Generating seed..."
  24. cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 > "${ROOT_FOLDER}/state/seed"
  25. fi
  26. ansible-playbook ansible/setup.yml -i ansible/hosts -K
  27. # echo "Configuring permissions..."
  28. # echo
  29. # find "$ROOT_FOLDER" -path "$ROOT_FOLDER/app-data" -prune -o -exec chown 1000:1000 {} + || true
  30. # Create configured status
  31. touch "${ROOT_FOLDER}/state/configured"