Update qbittorrent-exporter installation script

This commit is contained in:
Tobias 2025-11-19 14:39:20 +01:00 committed by GitHub
parent 09fe5a940a
commit d4efc508b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,11 +6,11 @@
APP="qbittorrent-exporter" APP="qbittorrent-exporter"
INSTALL_PATH="/usr/local/bin/filebrowser" INSTALL_PATH="/opt/qbittorrent-exporter/src/qbittorrent-exporter"
CONFIG_PATH="/usr/local/community-scripts/fq-config.yaml" CONFIG_PATH="/opt/qbittorrent-exporter.env"
DEFAULT_PORT=8080 DEFAULT_PORT=8080
SRC_DIR="/" SRC_DIR="/"
TMP_BIN="/tmp/filebrowser.$$" TMP_BIN="/tmp/qbittorrent-exporter.$$"
# Get primary IP # Get primary IP
IFACE=$(ip -4 route | awk '/default/ {print $5; exit}') IFACE=$(ip -4 route | awk '/default/ {print $5; exit}')
@ -21,11 +21,11 @@ IP=$(ip -4 addr show "$IFACE" | awk '/inet / {print $2}' | cut -d/ -f1 | head -n
# OS Detection # OS Detection
if [[ -f "/etc/alpine-release" ]]; then if [[ -f "/etc/alpine-release" ]]; then
OS="Alpine" OS="Alpine"
SERVICE_PATH="/etc/init.d/filebrowser" SERVICE_PATH="/etc/init.d/qbittorrent-exporter"
PKG_MANAGER="apk add --no-cache" PKG_MANAGER="apk add --no-cache"
elif [[ -f "/etc/debian_version" ]]; then elif [[ -f "/etc/debian_version" ]]; then
OS="Debian" OS="Debian"
SERVICE_PATH="/etc/systemd/system/filebrowser.service" SERVICE_PATH="/etc/systemd/system/qbittorrent-exporter.service"
PKG_MANAGER="apt-get install -y" PKG_MANAGER="apt-get install -y"
else else
echo -e "${CROSS} Unsupported OS detected. Exiting." echo -e "${CROSS} Unsupported OS detected. Exiting."
@ -33,38 +33,8 @@ else
fi fi
header_info header_info
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/core.func)
function msg_info() { echo -e "${INFO} ${YW}$1...${CL}"; } source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/tools.func)
function msg_ok() { echo -e "${CM} ${GN}$1${CL}"; }
function msg_error() { echo -e "${CROSS} ${RD}$1${CL}"; }
# Detect legacy FileBrowser installation
LEGACY_DB="/usr/local/community-scripts/filebrowser.db"
LEGACY_BIN="/usr/local/bin/filebrowser"
LEGACY_SERVICE_DEB="/etc/systemd/system/filebrowser.service"
LEGACY_SERVICE_ALP="/etc/init.d/filebrowser"
if [[ -f "$LEGACY_DB" || -f "$LEGACY_BIN" && ! -f "$CONFIG_PATH" ]]; then
echo -e "${YW}⚠️ Detected legacy FileBrowser installation.${CL}"
echo -n "Uninstall legacy FileBrowser and continue with Quantum install? (y/n): "
read -r remove_legacy
if [[ "${remove_legacy,,}" =~ ^(y|yes)$ ]]; then
msg_info "Uninstalling legacy FileBrowser"
if [[ -f "$LEGACY_SERVICE_DEB" ]]; then
systemctl disable --now filebrowser.service &>/dev/null
rm -f "$LEGACY_SERVICE_DEB"
elif [[ -f "$LEGACY_SERVICE_ALP" ]]; then
rc-service filebrowser stop &>/dev/null
rc-update del filebrowser &>/dev/null
rm -f "$LEGACY_SERVICE_ALP"
fi
rm -f "$LEGACY_BIN" "$LEGACY_DB"
msg_ok "Legacy FileBrowser removed"
else
echo -e "${YW}❌ Installation aborted by user.${CL}"
exit 0
fi
fi
# Existing installation # Existing installation
if [[ -f "$INSTALL_PATH" ]]; then if [[ -f "$INSTALL_PATH" ]]; then
@ -74,11 +44,11 @@ if [[ -f "$INSTALL_PATH" ]]; then
if [[ "${uninstall_prompt,,}" =~ ^(y|yes)$ ]]; then if [[ "${uninstall_prompt,,}" =~ ^(y|yes)$ ]]; then
msg_info "Uninstalling ${APP}" msg_info "Uninstalling ${APP}"
if [[ "$OS" == "Debian" ]]; then if [[ "$OS" == "Debian" ]]; then
systemctl disable --now filebrowser.service &>/dev/null systemctl disable --now qbittorrent-exporter.service &>/dev/null
rm -f "$SERVICE_PATH" rm -f "$SERVICE_PATH"
else else
rc-service filebrowser stop &>/dev/null rc-service qbittorrent-exporter stop &>/dev/null
rc-update del filebrowser &>/dev/null rc-update del qbittorrent-exporter &>/dev/null
rm -f "$SERVICE_PATH" rm -f "$SERVICE_PATH"
fi fi
rm -f "$INSTALL_PATH" "$CONFIG_PATH" rm -f "$INSTALL_PATH" "$CONFIG_PATH"
@ -90,9 +60,12 @@ if [[ -f "$INSTALL_PATH" ]]; then
read -r update_prompt read -r update_prompt
if [[ "${update_prompt,,}" =~ ^(y|yes)$ ]]; then if [[ "${update_prompt,,}" =~ ^(y|yes)$ ]]; then
msg_info "Updating ${APP}" msg_info "Updating ${APP}"
curl -fsSL https://github.com/gtsteffaniak/filebrowser/releases/latest/download/linux-amd64-filebrowser -o "$TMP_BIN" fetch_and_deploy_gh_release "qbittorrent-exporter" "martabal/qbittorrent-exporter"
chmod +x "$TMP_BIN" setup_go
mv -f "$TMP_BIN" /usr/local/bin/filebrowser cd /opt/qbittorrent-exporter
go get -d -v
cd src
go build -o ./qbittorrent-exporter
msg_ok "Updated ${APP}" msg_ok "Updated ${APP}"
exit 0 exit 0
else else
@ -102,9 +75,16 @@ if [[ -f "$INSTALL_PATH" ]]; then
fi fi
echo -e "${YW}⚠️ ${APP} is not installed.${CL}" echo -e "${YW}⚠️ ${APP} is not installed.${CL}"
echo -n "Enter port number (Default: ${DEFAULT_PORT}): " echo -n "Enter URL of qbittorrent example: (http://192.168.1.10:8080): "
read -r PORT read -r QBITTORRENT_BASE_URL
PORT=${PORT:-$DEFAULT_PORT}
echo -e "${YW}⚠️ ${APP} is not installed.${CL}"
echo -n "Enter qbittorrent username: "
read -r QBITTORRENT_USERNAME
echo -e "${YW}⚠️ ${APP} is not installed.${CL}"
echo -n "Enter qbittorrent password: "
read -r QBITTORRENT_PASSWORD
echo -n "Install ${APP}? (y/n): " echo -n "Install ${APP}? (y/n): "
read -r install_prompt read -r install_prompt
@ -114,107 +94,58 @@ if ! [[ "${install_prompt,,}" =~ ^(y|yes)$ ]]; then
fi fi
msg_info "Installing ${APP} on ${OS}" msg_info "Installing ${APP} on ${OS}"
$PKG_MANAGER curl ffmpeg &>/dev/null fetch_and_deploy_gh_release "qbittorrent-exporter" "martabal/qbittorrent-exporter"
curl -fsSL https://github.com/gtsteffaniak/filebrowser/releases/latest/download/linux-amd64-filebrowser -o "$TMP_BIN" setup_go
chmod +x "$TMP_BIN" cd /opt/qbittorrent-exporter
mv -f "$TMP_BIN" /usr/local/bin/filebrowser go get -d -v
cd src
go build -o ./qbittorrent-exporter
msg_ok "Installed ${APP}" msg_ok "Installed ${APP}"
msg_info "Preparing configuration directory" msg_info "Creating configuration"
mkdir -p /usr/local/community-scripts
chown root:root /usr/local/community-scripts
chmod 755 /usr/local/community-scripts
msg_ok "Directory prepared"
echo -n "Use No Authentication? (y/N): "
read -r noauth_prompt
# === YAML CONFIG GENERATION ===
if [[ "${noauth_prompt,,}" =~ ^(y|yes)$ ]]; then
cat <<EOF >"$CONFIG_PATH" cat <<EOF >"$CONFIG_PATH"
server: QBITTORRENT_BASE_URL=${QBITTORRENT_BASE_URL}
port: $PORT QBITTORRENT_USERNAME=${QBITTORRENT_USERNAME}
sources: QBITTORRENT_PASSWORD=${QBITTORRENT_PASSWORD}
- path: "$SRC_DIR"
name: "RootFS"
config:
denyByDefault: false
disableIndexing: false
indexingIntervalMinutes: 240
conditionals:
rules:
- neverWatchPath: "/proc"
- neverWatchPath: "/sys"
- neverWatchPath: "/dev"
- neverWatchPath: "/run"
- neverWatchPath: "/tmp"
- neverWatchPath: "/lost+found"
auth:
methods:
noauth: true
EOF EOF
msg_ok "Configured with no authentication" msg_ok "Created configuration"
else
cat <<EOF >"$CONFIG_PATH"
server:
port: $PORT
sources:
- path: "$SRC_DIR"
name: "RootFS"
config:
denyByDefault: false
disableIndexing: false
indexingIntervalMinutes: 240
conditionals:
rules:
- neverWatchPath: "/proc"
- neverWatchPath: "/sys"
- neverWatchPath: "/dev"
- neverWatchPath: "/run"
- neverWatchPath: "/tmp"
- neverWatchPath: "/lost+found"
auth:
adminUsername: admin
adminPassword: helper-scripts.com
EOF
msg_ok "Configured with default admin (admin / helper-scripts.com)"
fi
msg_info "Creating service" msg_info "Creating service"
if [[ "$OS" == "Debian" ]]; then if [[ "$OS" == "Debian" ]]; then
cat <<EOF >"$SERVICE_PATH" cat <<EOF >"$SERVICE_PATH"
[Unit] [Unit]
Description=FileBrowser Quantum Description=qbittorrent-exporter
After=network.target After=network.target
[Service] [Service]
User=root User=root
WorkingDirectory=/usr/local/community-scripts WorkingDirectory=/opt/qbittorrent-exporter/src
ExecStart=/usr/local/bin/filebrowser -c $CONFIG_PATH EnvironmentFile="$CONFIG_PATH"
ExecStart=/opt/qbittorrent-exporter/src/qbittorrent-exporter
Restart=always Restart=always
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
EOF EOF
systemctl enable --now filebrowser &>/dev/null systemctl enable --now qbittorrent-exporter &>/dev/null
else else
cat <<EOF >"$SERVICE_PATH" cat <<EOF >"$SERVICE_PATH"
#!/sbin/openrc-run #!/sbin/openrc-run
command="/usr/local/bin/filebrowser" command="$INSTALL_PATH"
command_args="-c $CONFIG_PATH" command_args=""
command_background=true command_background=true
directory="/usr/local/community-scripts" directory="/opt/qbittorrent-exporter/src"
pidfile="/usr/local/community-scripts/pidfile" pidfile="/opt/qbittorrent-exporter/src/pidfile"
depend() { depend() {
need net need net
} }
EOF EOF
chmod +x "$SERVICE_PATH" chmod +x "$SERVICE_PATH"
rc-update add filebrowser default &>/dev/null rc-update add qbittorrent-exporter default &>/dev/null
rc-service filebrowser start &>/dev/null rc-service qbittorrent-exporter start &>/dev/null
fi fi
msg_ok "Service created successfully" msg_ok "Service created successfully"
echo -e "${CM} ${GN}${APP} is reachable at: ${BL}http://$IP:$PORT${CL}" echo -e "${CM} ${GN}${APP} is reachable at: ${BL}http://$IP:8090${CL}"