install.sh 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/bash
  2. source bin/utils/functions.sh
  3. if [ -f bin/install.cfg ]; then
  4. echo "File install.cfg already exists"
  5. else
  6. attempts=0
  7. max_attempts=3
  8. while [ $attempts -lt $max_attempts ]; do
  9. echo_error "File install.cfg does not exist."
  10. read -p "Do you want to create it? (y/n) [default: y]: " answer
  11. if [[ "$answer" == "y" || "$answer" == "Y" ]]; then
  12. cp bin/install.cfg.example bin/install.cfg
  13. echo_success "File install.cfg was successfully created"
  14. echo_warning "Restart install.sh script after editing install.cfg"
  15. exit 0
  16. elif [[ "$answer" == "n" || "$answer" == "N" ]]; then
  17. echo_error "Error: You need to create the file manually and then continue."
  18. echo "cp /bin/install.cfg.example to /bin/install.cfg with your settings."
  19. exit 1
  20. else
  21. attempts=$((attempts + 1))
  22. echo_error "Invalid input. Please enter 'y' or 'n'. Attempt $attempts of $max_attempts."
  23. fi
  24. done
  25. echo_error "Exceeded maximum attempts. Exiting."
  26. exit 1
  27. fi
  28. source bin/install.cfg
  29. # Update repositories
  30. update_repository "$TICKETS" "tickets" "$TICKETS_BRANCH"
  31. update_repository "$BACKEND" "dbsynce" "$BACKEND_BRANCH"
  32. update_repository "$CONFIG" "conf" "$CONFIG_BRANCH"
  33. update_repository "$DESIGN_TEMPLATE" "design_template" "$DESIGN_TEMPLATE_BRANCH"
  34. update_repository "$WEBSERVICE_RUNNING" "webservice_running" "$WEBSERVICE_RUNNING_BRANCH"
  35. update_repository "$LANDING" "landing" "$LANDING_BRANCH"
  36. update_repository "$USER_MODEL" "user" "$USER_MODEL_BRANCH"
  37. # Update webapp-base repository
  38. git checkout "$WEBAPP_BASE_BRANCH"
  39. git pull
  40. # Create a Python virtual environment and activate it
  41. python3 -m venv venv
  42. source venv/bin/activate
  43. # Upgrade pip and install requirements
  44. pip install --upgrade pip
  45. pip install -r requirements.txt
  46. # Checking for .env
  47. if [ -f .env ]; then
  48. echo "File .env already exists"
  49. else
  50. cp .env.example .env
  51. echo_success "File .env was successfully created"
  52. echo_warning "Write the connection settings for the PostgreSQL database."
  53. echo_warning "Restart install.sh script after editing."
  54. exit
  55. fi
  56. # Run Django migrations and other commands
  57. python manage.py makemigrations dbsynce tickets webservice_running landing user
  58. python manage.py migrate
  59. python manage.py collectstatic -l --no-input
  60. # Seeding data
  61. python manage.py create_metaservice_default_data
  62. if (($GENERATE_TEST_USERS)); then
  63. python manage.py create_metaservice_test_users
  64. fi
  65. # Checking for webservice_running/handlers/.env
  66. if [ -f webservice_running/handlers/.env ]; then
  67. echo "env file for handlers already exists. "
  68. else
  69. echo_warning "Creating env file for handlers."
  70. cp webservice_running/handlers/.env.example webservice_running/handlers/.env
  71. echo_success "Created env file for handlers."
  72. fi