update.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/bash
  2. set -e # Exit immediately if any command exits with a non-zero status
  3. update_config() {
  4. CONFIG_FILE="instance/config.py"
  5. NEW_VARIABLES="\
  6. INDIEAUTH_CLIENT_ID = '' # Create a new access token at Owncast Admin panel -> Integrations -> Access Tokens, this variable is the name you associate with that token
  7. INDIEAUTH_CLIENT_SECRET = '' # The access token you created for INDIEAUTH_CLIENT_ID
  8. FOLLOW_POINTS = '50' # How many points to award viewers for following
  9. "
  10. TEMP_FILE=$(mktemp) # Create a temporary file
  11. if [[ ! -f "$CONFIG_FILE" ]]; then # Check if CONFIG_FILE exists
  12. echo "Error: Configuration file '$CONFIG_FILE' does not exist."
  13. exit 1
  14. fi
  15. while IFS= read -r line; do # Read through the original config file and output to the temp file
  16. echo "$line" >> "$TEMP_FILE" || { echo "Error writing to temp file"; exit 1; }
  17. done < "$CONFIG_FILE"
  18. echo "$NEW_VARIABLES" >> "$TEMP_FILE" || { echo "Error writing new variables to temp file"; exit 1; } # Append new variables to the temp file
  19. mv "$TEMP_FILE" "$CONFIG_FILE" || { echo "Error replacing the original config file"; exit 1; } # Move the temp file to the config file
  20. echo "Config file updated successfully."
  21. }
  22. activate_venv() {
  23. source env/bin/activate || { echo "Failed to activate virtual environment"; exit 1; }
  24. }
  25. update_db() { # Create the database. This also populates it with some goals and votes from the default rewards.py
  26. export FLASK_APP=ownchatbot
  27. if python -m flask update-db; then
  28. echo "Database updated successfully."
  29. else
  30. echo "Failed to update the database. Please check for errors."
  31. exit 1 # Exit the script with a non-zero status
  32. fi
  33. }
  34. update_config
  35. activate_venv
  36. update_db
  37. deactivate
  38. echo -e "***IMPORTANT***\n"
  39. echo -e "Look for new \"Authentication\" and \"New Follower\" options in the Settings menu of your OwnchatBot managemment panel.\n"
  40. echo "The way you access your OwnchatBot management panel has changed. Authentication is now handled using your Owncast server as an IndieAuth server. You log in using the same credentials you use to log in to your Owncast Admin page."