Skip to content

Instantly share code, notes, and snippets.

@ryansully
Created March 26, 2025 19:49
Show Gist options
  • Save ryansully/8fddfa725ed6cada52f1554232987c5a to your computer and use it in GitHub Desktop.
Save ryansully/8fddfa725ed6cada52f1554232987c5a to your computer and use it in GitHub Desktop.
install qbittorrent-nox on an existing (wireguard) LXC
#!/usr/bin/env bash
# Copyright (c) 2021-2025 community-scripts ORG
# Author: tteck (tteckster) | Co-Author: Slaviša Arežina (tremor021)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://www.qbittorrent.org/
set -e
APP="qBittorrent"
if [[ -f /.config/qBittorrent/qBittorrent.conf ]]; then
echo "Migrating old config..."
mkdir -p $HOME/.config/qBittorrent/
mv /.config/qBittorrent $HOME/.config/
rm -rf /.config/qBittorrent
echo "Migrated old config"
fi
if [[ ! -f $HOME/.config/qBittorrent/qBittorrent.conf ]]; then
echo "Creating config..."
mkdir -p $HOME/.config/qBittorrent/
cat <<EOF >$HOME/.config/qBittorrent/qBittorrent.conf
[LegalNotice]
Accepted=true
[Preferences]
WebUI\Password_PBKDF2="@ByteArray(amjeuVrF3xRbgzqWQmes5A==:XK3/Ra9jUmqUc4RwzCtrhrkQIcYczBl90DJw2rT8DFVTss4nxpoRhvyxhCf87ahVE3SzD8K9lyPdpyUCfmVsUg==)"
WebUI\Port=8090
WebUI\UseUPnP=false
WebUI\Username=admin
EOF
echo "Created config"
fi
FULLRELEASE=$(curl -s 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
echo "Setting up qBittorrent-nox..."
if [[ -f /etc/systemd/system/qbittorrent-nox.service ]]; then
echo "Stopping Service..."
systemctl stop qbittorrent-nox
echo "Stopped Service"
if [[ -f /usr/bin/qbittorrent-nox ]]; then
echo "Updating Service..."
sed -i 's@ExecStart=/usr/bin/qbittorrent-nox@ExecStart=/opt/qbittorrent/qbittorrent-nox@g' /etc/systemd/system/qbittorrent-nox.service
systemctl daemon-reload
echo "Updated and Reloaded Service"
apt-get remove --purge -y qbittorrent-nox
fi
fi
echo "Updating ${APP} to v${RELEASE}"
mkdir -p /opt/qbittorrent
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
echo "Updated $APP to v${RELEASE}"
echo "Setup qBittorrent-nox"
else
echo "No update required. ${APP} is already at v${RELEASE}"
exit
fi
if [[ -f /etc/systemd/system/qbittorrent-nox.service ]]; then
echo "Starting Service..."
systemctl start qbittorrent-nox
echo "Started Service"
else
echo "Creating Service..."
cat <<EOF >/etc/systemd/system/qbittorrent-nox.service
[Unit]
Description=qBittorrent client
After=network.target
[Service]
Type=simple
User=root
ExecStart=/opt/qbittorrent/qbittorrent-nox
Restart=always
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now qbittorrent-nox
echo "Created Service"
fi
echo "Cleaning up..."
apt-get -y autoremove
apt-get -y autoclean
echo "Cleaned"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment