upgrade.sh 1.3 KB

123456789101112131415161718192021222324252627282930
  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. KOFI_INTEGRATION=$(grep "^KOFI_INTEGRATION" instance/config.py | cut -d'=' -f2 | cut -d'#' -f1 | tr -d '[:space:]') # Get the value of KOFI_INTEGRATION
  13. sed -i "s/}/, \'token\': ${KOFI_TOKEN}, \'integration\': ${KOFI_INTEGRATION}}/" instance/kofi.py # Append those values to kofi.py
  14. sed -i "/^KOFI_TOKEN/d" instance/config.py # Delete KOFI_TOKEN line from config.py
  15. sed -i "/^KOFI_INTEGRATION/d" instance/config.py # Delete KOFI_INTEGRATION line from config.py
  16. cp ownchatbot/defaults/givebutter.py instance/ # Copy the default givebutter config file into instance/
  17. }
  18. # activate_venv
  19. # update_modules
  20. # deactivate
  21. update_config
  22. echo -e "\nYour OwnchatBot configuration has been upgraded. Look for GiveButter integration settings in the OCB Management Panel.\nHappy streaming!"