diff --git a/ct/qbittorrent.sh b/ct/qbittorrent.sh index 833e1eda7..1cc3c8c2f 100644 --- a/ct/qbittorrent.sh +++ b/ct/qbittorrent.sh @@ -27,32 +27,24 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi - if [[ ! -f /opt/${APP}_version.txt ]]; then - touch /opt/${APP}_version.txt - mkdir -p $HOME/.config/qBittorrent/ - mkdir -p /opt/qbittorrent/ - [ -d "/.config/qBittorrent" ] && mv /.config/qBittorrent "$HOME/.config/" - $STD apt-get remove --purge -y qbittorrent-nox - sed -i 's@ExecStart=/usr/bin/qbittorrent-nox@ExecStart=/opt/qbittorrent/qbittorrent-nox@g' /etc/systemd/system/qbittorrent-nox.service - systemctl daemon-reload + if [[ ! -f ~/.qbittorrent ]]; then + msg_error "Please create new qBittorrent LXC. Updating from v4.x to v5.x is not supported!" + exit fi - FULLRELEASE=$(curl -fsSL https://api.github.com/repos/userdocs/qbittorrent-nox-static/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') - RELEASE=$(echo $FULLRELEASE | cut -c 9-13) - if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then + + RELEASE=$(curl -fsSL https://api.github.com/repos/userdocs/qbittorrent-nox-static/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') + if [[ ! -f ~/.qbittorrent ]] || [[ "${RELEASE}" != "$(cat ~/.qbittorrent 2>/dev/null)" ]]; then msg_info "Stopping Service" systemctl stop qbittorrent-nox msg_ok "Stopped Service" - msg_info "Updating ${APP} to v${RELEASE}" - rm -f /opt/qbittorrent/qbittorrent-nox - curl -fsSL "https://github.com/userdocs/qbittorrent-nox-static/releases/download/${FULLRELEASE}/x86_64-qbittorrent-nox" -o /opt/qbittorrent/qbittorrent-nox - chmod +x /opt/qbittorrent/qbittorrent-nox - echo "${RELEASE}" >/opt/${APP}_version.txt - msg_ok "Updated $APP to v${RELEASE}" + fetch_and_deploy_gh_release "qbittorrent" "userdocs/qbittorrent-nox-static" "singlefile" "latest" "/opt/qbittorrent" "x86_64-qbittorrent-nox" + mv /opt/qbittorrent/x86_64-qbittorrent-nox /opt/qbittorrent/qbittorrent-nox msg_info "Starting Service" systemctl start qbittorrent-nox msg_ok "Started Service" + msg_ok "Updated Successfully" else msg_ok "No update required. ${APP} is already at v${RELEASE}" diff --git a/install/qbittorrent-install.sh b/install/qbittorrent-install.sh index f1e68aba0..f9af3e926 100644 --- a/install/qbittorrent-install.sh +++ b/install/qbittorrent-install.sh @@ -13,14 +13,12 @@ setting_up_container network_check update_os +fetch_and_deploy_gh_release "qbittorrent" "userdocs/qbittorrent-nox-static" "singlefile" "latest" "/opt/qbittorrent" "x86_64-qbittorrent-nox" + msg_info "Setup qBittorrent-nox" -FULLRELEASE=$(curl -fsSL https://api.github.com/repos/userdocs/qbittorrent-nox-static/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') -RELEASE=$(echo $FULLRELEASE | cut -c 9-13) -mkdir -p /opt/qbittorrent -curl -fsSL "https://github.com/userdocs/qbittorrent-nox-static/releases/download/${FULLRELEASE}/x86_64-qbittorrent-nox" -o /opt/qbittorrent/qbittorrent-nox -chmod +x /opt/qbittorrent/qbittorrent-nox -mkdir -p $HOME/.config/qBittorrent/ -cat <$HOME/.config/qBittorrent/qBittorrent.conf +mv /opt/qbittorrent/x86_64-qbittorrent-nox /opt/qbittorrent/qbittorrent-nox +mkdir -p ~/.config/qBittorrent/ +cat <~/.config/qBittorrent/qBittorrent.conf [LegalNotice] Accepted=true @@ -30,7 +28,6 @@ WebUI\Port=8090 WebUI\UseUPnP=false WebUI\Username=admin EOF -echo "${RELEASE}" >/opt/${APPLICATION}_version.txt msg_ok "Setup qBittorrent-nox" msg_info "Creating Service"