install.sh 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. git pull
  38. # Create a Python virtual environment and activate it
  39. python3 -m venv venv
  40. source venv/bin/activate
  41. # Upgrade pip and install requirements
  42. pip install --upgrade pip
  43. pip install -r requirements.txt
  44. # Checking for .env
  45. if [ -f .env ]; then
  46. echo "File .env already exists"
  47. else
  48. cp .env.example .env
  49. echo_success "File .env was successfully created"
  50. echo_warning "Write the connection settings for the PostgreSQL database."
  51. echo_warning "Restart install.sh script after editing."
  52. exit
  53. fi
  54. # Run Django migrations and other commands
  55. python manage.py makemigrations dbsynce tickets webservice_running landing user
  56. python manage.py migrate
  57. python manage.py collectstatic -l --no-input
  58. # Seeding data
  59. python manage.py create_metaservice_default_data
  60. if (($GENERATE_TEST_USERS)); then
  61. python manage.py create_metaservice_test_users
  62. fi
  63. # Checking for webservice_running/handlers/.env
  64. if [ -f webservice_running/handlers/.env ]; then
  65. echo "env file for handlers already exists. "
  66. else
  67. echo_warning "Creating env file for handlers."
  68. cp webservice_running/handlers/.env.example webservice_running/handlers/.env
  69. echo_success "Created env file for handlers."
  70. fi