#!/bin/bash set -e # Exit immediately if any command exits with a non-zero status activate_venv() { source env/bin/activate || { echo "Failed to activate virtual environment"; exit 1; } } update_modules() { pip install --upgrade pip || { echo "Failed to upgrade pip"; exit 1; } # Upgrade pip pip install -e . || { echo "Failed to install/upgrade module"; exit 1; } # Install/upgrade modules } update_config() { local bak_file="instance/config.py.bak" read -p "Enter the external URL your OwnchatBot uses, with \"https://\": " OCB_URL if [[ -n "$OCB_URL" ]]; then # Check if OCB_URL is not empty echo "" >> instance/config.py # Append an empty line so it formats correctly echo "OCB_URL = '$OCB_URL'" >> instance/config.py # Append the new line echo "Set OCB_URL successfully." cp instance/config.py "$bak_file" rm "$bak_file" # Remove the .bak file if the update was successful else echo "Failed to set OCB_URL. Please provide a valid URL." exit 1 # Exit the script with a non-zero status fi } # activate_venv # update_modules update_config # deactivate echo -e "Your OwnchatBot configuration has been upgraded. Happy streaming!"