upgrade.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. set -e # Exit immediately if any command exits with a non-zero status
  3. activate_venv() {
  4. source env/bin/activate || { echo "Failed to activate virtual environment"; exit 1; }
  5. }
  6. update_modules() {
  7. pip install --upgrade pip || { echo "Failed to upgrade pip"; exit 1; } # Upgrade pip
  8. pip install -e . || { echo "Failed to install/upgrade module"; exit 1; } # Install/upgrade modules
  9. }
  10. update_config() {
  11. KOFI_TOKEN=$(grep "^KOFI_TOKEN" instance/config.py | cut -d'=' -f2 | cut -d'#' -f1 | tr -d '[:space:]') # Get the value of KOFI_TOKEN
  12. if [ "$KOFI_TOKEN" = "False" ]; then # So bash doesn't blank the variable in kofi.py if it's False
  13. KOFI_TOKEN="False"
  14. fi
  15. if [ -z "$KOFI_INTEGRATION" ]; then # So bash doesn't blank the variable in kofi.py if it's empty.
  16. KOFI_INTEGRATION="''"
  17. fi
  18. KOFI_INTEGRATION=$(grep "^KOFI_INTEGRATION" instance/config.py | cut -d'=' -f2 | cut -d'#' -f1 | tr -d '[:space:]') # Get the value of KOFI_INTEGRATION
  19. sed -i "s/}/, \'token\': ${KOFI_TOKEN}, \'integration\': ${KOFI_INTEGRATION}}/" instance/kofi.py # Append those values to kofi.py
  20. sed -i "/^KOFI_TOKEN/d" instance/config.py # Delete KOFI_TOKEN line from config.py
  21. sed -i "/^KOFI_INTEGRATION/d" instance/config.py # Delete KOFI_INTEGRATION line from config.py
  22. cp ownchatbot/defaults/givebutter.py instance/ # Copy the default givebutter config file into instance/
  23. }
  24. activate_venv
  25. update_modules
  26. deactivate
  27. update_config
  28. echo -e "\nYour OwnchatBot configuration has been upgraded. Look for GiveButter integration settings in the OCB Management Panel.\nHappy streaming!"