install.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. source bin/install.cfg
  3. # Command line argument handler
  4. while [[ "$#" -gt 0 ]]; do
  5. case $1 in
  6. --test-users)
  7. export TEST_USERS=true
  8. echo "Test users flag set"
  9. shift ;;
  10. *)
  11. echo "Unknown parameter: $1"
  12. shift ;;
  13. esac
  14. done
  15. # Function to check if a repository exists and perform git pull or git clone
  16. update_repository() {
  17. local repo_url="$1"
  18. local repo_dir="$2"
  19. local repo_branch="$3"
  20. if [ -d "$repo_dir" ]; then
  21. # If the directory exists, then do a git pull
  22. echo "Updating $repo_dir..."
  23. cd "$repo_dir" || exit
  24. git pull
  25. cd - || exit
  26. else
  27. # If the directory does not exist, then do a git clone
  28. echo "Cloning $repo_url into $repo_dir..."
  29. git clone -b "$repo_branch" "$repo_url" "$repo_dir"
  30. fi
  31. }
  32. # Update repositories
  33. update_repository "$TICKETS" "tickets" "master"
  34. update_repository "$BACKEND" "dbsynce" "metasynced_module"
  35. update_repository "$CONFIG" "conf" "master"
  36. update_repository "$DESIGN_TEMPLATE" "design_template" "unstable"
  37. update_repository "$WEBSERVICE_RUNNING" "webservice_running" "unstable"
  38. update_repository "$LANDING" "landing" "landing_module"
  39. update_repository "$USER_MODEL" "user" "master"
  40. update_repository "$WEBAPP_BASE" "design_template" "unstable"
  41. git pull
  42. # Create a Python virtual environment and activate it
  43. python3 -m venv venv
  44. source venv/bin/activate
  45. # Upgrade pip and install requirements
  46. pip install --upgrade pip
  47. pip install -r requirements.txt
  48. # Checking for core/settings_vars.py
  49. if [ -f core/settings_vars.py ]; then
  50. echo "File settings_vars.py already exists"
  51. else
  52. cp core/_settings_vars.py core/settings_vars.py
  53. echo "File settings_vars.py was successfully created"
  54. fi
  55. # Run Django migrations and other commands
  56. python manage.py makemigrations dbsynce tickets webservice_running landing user
  57. python manage.py migrate
  58. python manage.py collectstatic -l --no-input
  59. #cp conf/sharix_open.service /etc/systemd/system/