Last active
February 21, 2025 05:52
-
-
Save ericswpark/bc53e93fbd8529655ba54dce454d5962 to your computer and use it in GitHub Desktop.
Updates VueTorrent automatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
VUETORRENT_REPO_NAME="VueTorrent/VueTorrent" | |
GITHUB_API_URL="https://api.github.com/repos" | |
GITHUB_URL="https://github.com" | |
GITHUB_VUETORRENT_API_URL="$GITHUB_API_URL/$VUETORRENT_REPO_NAME" | |
GITHUB_VUETORRENT_URL="$GITHUB_URL/$VUETORRENT_REPO_NAME" | |
# Check latest version on GitHub | |
export LATEST_VUETORRENT_VERSION=$(curl -s $GITHUB_VUETORRENT_API_URL/releases/latest | jq --raw-output '.name') | |
echo "The latest release of VueTorrent on GitHub is $LATEST_VUETORRENT_VERSION." | |
# Initialize directories | |
CURR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
WORK_DIR=`mktemp -d` | |
if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then | |
echo "Could not create temporary directory to work in!" | |
exit 1 | |
fi | |
function cleanup { | |
rm -rf "$WORK_DIR" | |
echo "Deleted temporary working directory $WORK_DIR" | |
} | |
trap cleanup EXIT | |
# Switch to work directory | |
pushd $WORK_DIR | |
echo "Downloading VueTorrent release $LATEST_VUETORRENT_VERSION..." | |
wget "$GITHUB_VUETORRENT_URL/releases/download/$LATEST_VUETORRENT_VERSION/vuetorrent.zip" | |
echo "Download complete." | |
echo "Unzipping release to temporary folder..." | |
unzip vuetorrent.zip | |
echo "Unzip done." | |
echo "Moving release to qbittorrent folder..." | |
mv vuetorrent $CURR_DIR/vuetorrent-$LATEST_VUETORRENT_VERSION | |
echo "Files moved." | |
popd | |
# Set up symlink | |
echo "Setting up symlinks..." | |
echo "Removing the previous symlink..." | |
rm vuetorrent | |
echo "Setting up the symlink for version $LATEST_VUETORRENT_VERSION..." | |
ln -s vuetorrent-$LATEST_VUETORRENT_VERSION vuetorrent | |
echo "Symlink has been set up." | |
echo "Setting correct permissions..." | |
chown -R nobody:users vuetorrent vuetorrent-$LATEST_VUETORRENT_VERSION | |
echo "Correct permissions set." | |
echo "Restarting the qbittorrent container..." | |
docker restart qbittorrent | |
echo "Container qbittorrent has been restarted." | |
echo "Done! VueTorrent has been updated to $LATEST_VUETORRENT_VERSION." |
Updated to use jq
instead of python3
. This should help on UnRAID where NerdTools has been deprecated (but it ships with jq
by default)!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to use variables to quickly change repository names. (The organization name changed from the individual GitHub account @WDaan to VueTorrent.)