#!/bin/bash source bin/utils/functions.sh if [ -f bin/install.cfg ]; then echo "File install.cfg already exists" else attempts=0 max_attempts=3 while [ $attempts -lt $max_attempts ]; do echo_error "File install.cfg does not exist." read -p "Do you want to create it? (y/n) [default: y]: " answer if [[ "$answer" == "y" || "$answer" == "Y" ]]; then cp bin/install.cfg.example bin/install.cfg echo_success "File install.cfg was successfully created" echo_warning "Restart install.sh script after editing install.cfg" exit 0 elif [[ "$answer" == "n" || "$answer" == "N" ]]; then echo_error "Error: You need to create the file manually and then continue." echo "cp /bin/install.cfg.example to /bin/install.cfg with your settings." exit 1 else attempts=$((attempts + 1)) echo_error "Invalid input. Please enter 'y' or 'n'. Attempt $attempts of $max_attempts." fi done echo_error "Exceeded maximum attempts. Exiting." exit 1 fi source bin/install.cfg # Update repositories update_repository "$TICKETS" "tickets" "$TICKETS_BRANCH" update_repository "$BACKEND" "dbsynce" "$BACKEND_BRANCH" update_repository "$CONFIG" "conf" "$CONFIG_BRANCH" update_repository "$DESIGN_TEMPLATE" "design_template" "$DESIGN_TEMPLATE_BRANCH" update_repository "$WEBSERVICE_RUNNING" "webservice_running" "$WEBSERVICE_RUNNING_BRANCH" update_repository "$LANDING" "landing" "$LANDING_BRANCH" update_repository "$USER_MODEL" "user" "$USER_MODEL_BRANCH" git pull # Create a Python virtual environment and activate it python3 -m venv venv source venv/bin/activate # Upgrade pip and install requirements pip install --upgrade pip pip install -r requirements.txt # Checking for .env if [ -f .env ]; then echo "File .env already exists" else cp .env.example .env echo_success "File .env was successfully created" echo_warning "Write the connection settings for the PostgreSQL database." echo_warning "Restart install.sh script after editing." exit fi # Run Django migrations and other commands python manage.py makemigrations dbsynce tickets webservice_running landing user python manage.py migrate python manage.py collectstatic -l --no-input # Seeding data python manage.py create_metaservice_default_data if (($GENERATE_TEST_USERS)); then python manage.py create_metaservice_test_users fi # Checking for webservice_running/handlers/.env if [ -f webservice_running/handlers/.env ]; then echo "env file for handlers already exists. " else echo_warning "Creating env file for handlers." cp webservice_running/handlers/.env.example webservice_running/handlers/.env echo_success "Created env file for handlers." fi