install_invidious.sh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. function error {
  3. echo -e "\\e[91m$1\\e[39m"
  4. exit 1
  5. }
  6. function check_internet() {
  7. printf "Checking if you are online..."
  8. wget -q --spider http://github.com
  9. if [ $? -eq 0 ]; then
  10. echo "Online. Continuing."
  11. else
  12. error "Offline. Go connect to the internet then run the script again."
  13. fi
  14. }
  15. check_internet
  16. BASE_DIR='/portainer/Files/AppData/Config/invidious'
  17. echo "Creating directories..."
  18. sudo mkdir -p "${BASE_DIR}/config-sql" || error "Failed to create config directory"
  19. sudo mkdir -p "${BASE_DIR}/dbdata" || error "Failed to create data directory for Invidious!"
  20. echo "Downloading Invidious SQL config files"
  21. GH_INVIDIOUS_RAW='https://raw.githubusercontent.com/iv-org/invidious/master'
  22. f='annotations.sql' ; sudo wget -O "${BASE_DIR}/config-sql/$f" "${GH_INVIDIOUS_RAW}/config/sql/$f" || error "Failed to download $f file!"
  23. f='channel_videos.sql' ; sudo wget -O "${BASE_DIR}/config-sql/$f" "${GH_INVIDIOUS_RAW}/config/sql/$f" || error "Failed to download $f file!"
  24. f='channels.sql' ; sudo wget -O "${BASE_DIR}/config-sql/$f" "${GH_INVIDIOUS_RAW}/config/sql/$f" || error "Failed to download $f file!"
  25. f='nonces.sql' ; sudo wget -O "${BASE_DIR}/config-sql/$f" "${GH_INVIDIOUS_RAW}/config/sql/$f" || error "Failed to download $f file!"
  26. f='playlist_videos.sql' ; sudo wget -O "${BASE_DIR}/config-sql/$f" "${GH_INVIDIOUS_RAW}/config/sql/$f" || error "Failed to download $f file!"
  27. f='playlists.sql' ; sudo wget -O "${BASE_DIR}/config-sql/$f" "${GH_INVIDIOUS_RAW}/config/sql/$f" || error "Failed to download $f file!"
  28. f='session_ids.sql' ; sudo wget -O "${BASE_DIR}/config-sql/$f" "${GH_INVIDIOUS_RAW}/config/sql/$f" || error "Failed to download $f file!"
  29. f='users.sql' ; sudo wget -O "${BASE_DIR}/config-sql/$f" "${GH_INVIDIOUS_RAW}/config/sql/$f" || error "Failed to download $f file!"
  30. f='videos.sql' ; sudo wget -O "${BASE_DIR}/config-sql/$f" "${GH_INVIDIOUS_RAW}/config/sql/$f" || error "Failed to download $f file!"
  31. echo "Downloading Invidious init script"
  32. f='init-invidious-db.sh' ; sudo wget -O "${BASE_DIR}/$f" "${GH_INVIDIOUS_RAW}/docker/$f" || error "Failed to download $f file!"
  33. sudo chmod +x "${BASE_DIR}/$f"
  34. echo "Preparation completed, proceed installation in portainer"
  35. echo -e "Suggestion for \\e[1mDB_PASSWORD\\e[39m: \\e[33m$(openssl rand -base64 24)\\e[39m"
  36. echo -e "Suggestion for \\e[1mHMAC_KEY\\e[39m: \\e[33m$(openssl rand -hex 20)\\e[39m"