New generation

This commit is contained in:
Alexandre
2023-12-09 14:02:01 +01:00
parent 75c63d1293
commit ecd07200e5
18 changed files with 315 additions and 421 deletions

View File

@@ -1,125 +1,174 @@
- BREAKING CHANGE : upstream container switched to trigus42/qbittorrentvpn. All options will be migrated. Please double check all your options as the default behavior might have changed.
- BREAKING CHANGE : default password changed from "adminadmin" to "homeassistant". Please change from webui
- MAJOR CHANGE : switch to the new config logic from homeassistant. Your configuration files will have migrated from /config/hassio_addons/qBittorrent et a folder only accessible from my Filebrowser addon called /addon_configs/something-qBittorrent. This avoids the addon to mess with your homeassistant configuration folder, and allows to backup the options. Migration of data, custom configs, and custom scripts should be automatic. Please be sure to update all your links however ! For more information, see here : https://developers.home-assistant.io/blog/2023/11/06/public-addon-config/
- FEAT : wireguard support, see trigus42/qbittorrentvpn
- FEAT : addition of qbit_manage application through an addon option. Please customize the configuration file in /config/xxx-qBittorrent/qbit_manage/qbit_manage.yml
- Fix : avoid crond messages spaming https://github.com/alexbelgium/hassio-addons/issues/1111
## 4.6.2 (02-12-2023)
- Update to latest version from linuxserver/docker-qbittorrent
### 4.6.1-6 (22-11-2023)
- Minor bugs fixed
### 4.6.1-5 (22-11-2023)
- Minor bugs fixed
- Selecting qbit webui also applies it to ingress. Otherwise, default is vuetorrent
### 4.6.1-3 (22-11-2023)
- Minor bugs fixed
- Restart the addon after setting the default password
### 4.6.1-2 (22-11-2023)
- Minor bugs fixed
- Re-add default username (admin) and password (homeassistant)
## 4.6.1 (21-11-2023)
- Update to latest version from linuxserver/docker-qbittorrent
### 4.6.0-3 (06-11-2023)
- Minor bugs fixed
- Ingress webui update at start
### 4.6.0-2 (30-10-2023)
- Minor bugs fixed
### 4.6.0-WITHOUT_VPN (30-10-2023)
- Minor bugs fixed
## 4.6.0 (28-10-2023)
- Update to latest version from linuxserver/docker-qbittorrent
### 4.5.5-4 (30-09-2023)
- Minor bugs fixed
- Avoid crash when using smbv1
## 4.5.5 (02-09-2023)
- Update to latest version from linuxserver/docker-qbittorrent
### 4.5.4-2 (24-06-2023)
- Minor bugs fixed
- armv7 not supported anymore by linuxserver, it is pinned to latest working version
## 4.5.4 (24-06-2023)
- Update to latest version from linuxserver/docker-qbittorrent
### 4.5.3-r0-2 (12-06-2023)
- Minor bugs fixed
- Evaluate smb v2 before v1
### 4.5.3-r0 (07-06-2023)
- Minor bugs fixed
## 4.5.3 (03-06-2023)
- Update to latest version from linuxserver/docker-qbittorrent
### 4.5.2-3 (22-04-2023)
- Minor bugs fixed
- Fix multi smb mounts
### 4.5.2-2 (19-03-2023)
- Minor bugs fixed
- Align exec code with upstream
## 4.5.2 (18-03-2023)
- Update to latest version from linuxserver/docker-qbittorrent
- Correct downloads folder
### 4.5.2-r0-ls250-2 (13-03-2023)
- Minor bug fixes
- Try solving sed error message #755
### 4.5.2-r0-ls250-2 (11-03-2023)
- Bug updates
- Add lsio branding
- Implement healthcheck
## 4.5.2-r0-ls250 (11-03-2023)
- Update to latest version from linuxserver/docker-qbittorrent
## 4.5.2-r0-ls249 (04-03-2023)
- Update to latest version from linuxserver/docker-qbittorrent
## 4.5.1-r1-ls246 (25-02-2023)
- Update to latest version from linuxserver/docker-qbittorrent
## 4.5.1-r1-ls245 (19-02-2023)
- Update to latest version from linuxserver/docker-qbittorrent
## 4.5.0-r1-ls243 (11-02-2023)
- Update to latest version from linuxserver/docker-qbittorrent
## 4.5.0-r1-ls242 (04-02-2023)
- Update to latest version from linuxserver/docker-qbittorrent
## 4.5.0-r1-ls241 (28-01-2023)
- Update to latest version from linuxserver/docker-qbittorrent
## 4.5.0-r1-ls240 (21-01-2023)
- Update to latest version from linuxserver/docker-qbittorrent
## 4.5.0-r1-ls239 (14-01-2023)
- Update to latest version from linuxserver/docker-qbittorrent
## 4.5.0-r1-ls238 (07-01-2023)
- Update to latest version from linuxserver/docker-qbittorrent
## 4.5.0-r1-ls237 (31-12-2022)
- Update to latest version from linuxserver/docker-qbittorrent
## 4.5.0-r1-ls236 (25-12-2022)
- Update to latest version from linuxserver/docker-qbittorrent
## 4.5.0-r0-ls234 (13-12-2022)
- Update to latest version from linuxserver/docker-qbittorrent
- Fix : using options Savepath for download folder
## 4.5.0-r0-ls233 (06-12-2022)
- Update to latest version from linuxserver/docker-qbittorrent
## 4.5.0-r0-ls232 (01-12-2022)
- Update to latest version from linuxserver/docker-qbittorrent
## 4.5.0-r0-ls231 (29-11-2022)
- Update to latest version from linuxserver/docker-qbittorrent
- WARNING : update to supervisor 2022.11 before installing
@@ -441,7 +490,7 @@
## 14.3.3.99202101191832-7248-da0b276d5ubuntu18.04.1-ls113
- Update to latest version from linuxserver/docker-qbittorrent
- Whitelist option
- LAN_NETWORK option
- Enables PUID/PGID options
- Addition of ssl options
- Addition of possibility to mount local disc or smb

View File

@@ -16,7 +16,6 @@
ARG BUILD_FROM
ARG BUILD_VERSION
ARG BUILD_UPSTREAM="4.6.2"
FROM ${BUILD_FROM}
##################
@@ -28,18 +27,8 @@ ENV S6_CMD_WAIT_FOR_SERVICES=1 \
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
S6_SERVICES_GRACETIME=0
# Environment variables
ENV \
DEBIAN_FRONTEND="noninteractive"\
LANG="C.UTF-8" \
PS1="$(whoami)@$(hostname):$(pwd)$ " \
S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \
S6_CMD_WAIT_FOR_SERVICES=1 \
TERM="xterm-256color" \
HOME="/config/addons_config" \
XDG_CONFIG_HOME="/config/addons_config" \
XDG_DATA_HOME="/config/addons_config"
# GENERAL MODIFICATIONS
#######################
# Image specific modifications
# hadolint ignore=DL4006
@@ -57,10 +46,21 @@ RUN \
&& unzip -o vuetorrent.zip -d / >/dev/null \
&& rm vuetorrent.zip >/dev/null
# Global LSIO modifications
ADD "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_lsio.sh" "/ha_lsio.sh"
ARG CONFIGLOCATION="/config/addons_config/qBittorrent"
RUN chmod 744 /ha_lsio.sh && if grep -qr "lsio" /etc; then /ha_lsio.sh "$CONFIGLOCATION"; fi && rm /ha_lsio.sh
# ADD QBIT_MANAGE
#################
ENV QBM_DOCKER True
ENV QBT_SKIP_QB_VERSION_CHECK True
RUN \
# Install qbit_manage
mkdir -p /qbit_manage && \
curl -o /tmp/qbit_manage.tar.gz -L "https://github.com/StuffAnThings/qbit_manage/archive/master.tar.gz" && \
tar xf /tmp/qbit_manage.tar.gz -C /qbit_manage --strip-components=1 && \
\
# Install dependencies
apk add py3-pip && \
pip install --no-cache-dir --upgrade --requirement /qbit_manage/requirements.txt --ignore-installed
##################
# 3 Install apps #
@@ -137,12 +137,3 @@ LABEL \
#################
# 6 Healthcheck #
#################
ENV HEALTH_PORT="" \
HEALTH_URL=""
HEALTHCHECK \
--interval=5s \
--retries=5 \
--start-period=30s \
--timeout=25s \
CMD pgrep qbittorrent || exit 1

View File

@@ -23,21 +23,10 @@ _Thanks to everyone having starred my repo! To star it click on the image below,
---
[Qbittorrent](https://github.com/qbittorrent/qBittorrent) is a cross-platform free and open-source BitTorrent client.
This addon is based on the docker image from [linuxserver.io](https://www.linuxserver.io/).
This addons has several configurable options :
- allowing to mount local external drive, or smb share from the addon
- [alternative webUI](https://github.com/qbittorrent/qBittorrent/wiki/List-of-known-alternate-WebUIs)
- usage of ssl
- ingress
- optional openvpn support
- allow setting specific DNS servers
This addon is based on the docker image from [trigus42](trigus42/qbittorrentvpn).
## Configuration
---
Webui can be found at <http://homeassistant:8080>, or in your sidebar using Ingress.
The default username/password : described in the startup log.
Configurations can be done through the app webUI, except for the following options
@@ -46,13 +35,17 @@ Network disk is mounted to /mnt/share name
You need to map the exposed port in your router if you want the best speed and connectivity.
Options can be configured through two ways :
- Addon options
```yaml
PGID: user
GPID: user
ssl: true/false
certfile: fullchain.pem #ssl certificate, must be located in /ssl
keyfile: privkey.pem #sslkeyfile, must be located in /ssl
whitelist: "localhost,192.168.0.0/16" # list ip subnets that won't need a password (optional)
LAN_NETWORK: "localhost,192.168.0.0/16" # list ip subnets that won't need a password (optional)
customUI: selection from list # alternative webUI can be set here. Latest version set at each addon start. Select 'custom' to fill it yourself in the webui
DNS_servers: 8.8.8.8,1.1.1.1 # Keep blank to use routers DNS, or set custom DNS to avoid spamming in case of local DNS ad-remover
SavePath: "/share/qbittorrent" # Define the download directory
@@ -61,15 +54,19 @@ networkdisks: "//SERVER/SHARE" # optional, list of smb servers to mount, separat
cifsusername: "username" # optional, smb username, same for all smb shares
cifspassword: "password" # optional, smb password
cifsdomain: "domain" # optional, allow setting the domain for the smb share
openvpn_enabled: true/false # is openvpn required to start qbittorrent
openvpn_config": For example "config.ovpn" # name of the file located in /config/openvpn.
openvpn_username": USERNAME
openvpn_password: YOURPASSWORD
openvpn_alt_mode: bind at container level and not app level
VPN_ENABLED: true/false # is openvpn required to start qbittorrent
VPN_USERNAME": USERNAME
VPN_PASSWORD: YOURPASSWORD
run_duration: 12h #for how long should the addon run. Must be formatted as number + time unit (ex : 5s, or 2m, or 12h, or 5d...)
silent: true #suppresses debug messages
```
- Config.yaml (advanced usage)
Additional variables can be set as ENV variables by adding them in the config.yaml in the location defined in your addon options according to this guide : https://github.com/alexbelgium/hassio-addons/wiki/Add%E2%80%90ons-feature-:-add-env-variables
The complete list of ENV variables can be seen here : https://github.com/Trigus42/alpine-qbittorrentvpn#environment-variables
## Installation
---
@@ -119,8 +116,10 @@ pull-filter ignore "dhcp-option DNS6"
pull-filter ignore "tun-ipv6"
pull-filter ignore "ifconfig-ipv6"
```
</details>
<details>
<summary>### Monitored folders (@FaliseDotCom)</summary>
@@ -130,30 +129,31 @@ pull-filter ignore "ifconfig-ipv6"
```json
{
"folder/to/watch": {
"add_torrent_params": {
"category": "",
"content_layout": "Original",
"download_limit": -1,
"download_path": "[folder/for/INCOMPLETE_downloads]",
"operating_mode": "AutoManaged",
"ratio_limit": -2,
"save_path": "[folder/for/COMPLETED_downloads]",
"seeding_time_limit": -2,
"skip_checking": false,
"stopped": false,
"tags": [
],
"upload_limit": -1,
"use_auto_tmm": false,
"use_download_path": true
},
"recursive": false
}
"folder/to/watch": {
"add_torrent_params": {
"category": "",
"content_layout": "Original",
"download_limit": -1,
"download_path": "[folder/for/INCOMPLETE_downloads]",
"operating_mode": "AutoManaged",
"ratio_limit": -2,
"save_path": "[folder/for/COMPLETED_downloads]",
"seeding_time_limit": -2,
"skip_checking": false,
"stopped": false,
"tags": [],
"upload_limit": -1,
"use_auto_tmm": false,
"use_download_path": true
},
"recursive": false
}
}
```
</details>
<details>
<summary>### nginx error code (@Nanianmichaels)</summary>
@@ -171,19 +171,24 @@ Wait a couple minutes and restart addon, it could be a temporary unavailability
> [cont-init.d] 00-local_mounts.sh: exited 0.
Try to mount by putting the partition label in the "localdisks" options instead of the hardware name
</details>
<details>
<summary>### Loss of metadata fetching with openvpn after several days (@almico)</summary>
Add `ping-restart 60` to your config.ovpn
</details>
<details>
<summary>### Downloads info are empty on small scale window (@aviadlevy)</summary>
When my window size width is lower than 960 pixels my downloads are empty.
Solution is to reset the Vuetorrent settings.
</details>
## Support

View File

@@ -1,8 +1,8 @@
{
"build_from": {
"aarch64": "lscr.io/linuxserver/qbittorrent:arm64v8-latest",
"amd64": "lscr.io/linuxserver/qbittorrent:amd64-latest",
"armv7": "lscr.io/linuxserver/qbittorrent:arm32v7-4.5.3"
"aarch64": "trigus42/qbittorrentvpn:latest",
"amd64": "trigus42/qbittorrentvpn:latest",
"armv7": "trigus42/qbittorrentvpn:latest"
},
"codenotary": {
"signer": "alexandrep.github@gmail.com"

View File

@@ -62,29 +62,37 @@
"environment": {
"PGID": "0",
"PUID": "0",
"WEBUI_PORT": "8080"
"WEBUI_PORT": "8080",
"ADDITIONAL_PORTS": "59595,6882",
"DOWNLOAD_DIR_CHOWN": "true",
"SET_FWMARK": "true",
"QBITTORRENTLOGPATH": "/config/qBittorrent/data/logs"
},
"image": "ghcr.io/alexbelgium/qbittorrent-{arch}",
"ingress": true,
"init": false,
"map": [
"media:rw",
"config:rw",
"addon_config:rw",
"homeassistant_config:rw",
"share:rw",
"ssl"
],
"name": "Qbittorrent",
"options": {
"qbit_manage": false,
"DNS_server": "8.8.8.8,1.1.1.1",
"PGID": "0",
"PUID": "0",
"SavePath": "/share/qBittorrent",
"Username": "admin",
"QBT_USERNAME": "admin",
"VPN_TYPE": "openvpn",
"certfile": "fullchain.pem",
"customUI": "vuetorrent",
"keyfile": "privkey.pem",
"VPN_ENABLED": "no",
"ssl": false,
"whitelist": "localhost,127.0.0.1,172.30.0.0/16,192.168.0.0/16"
"LAN_NETWORK": "localhost,127.0.0.1,172.30.0.0/16,192.168.0.0/16"
},
"panel_icon": "mdi:progress-download",
"ports": {
@@ -103,16 +111,18 @@
},
"privileged": [
"SYS_ADMIN",
"SYS_MODULE",
"DAC_READ_SEARCH",
"NET_ADMIN"
],
"schema": {
"DNS_server": "str?",
"qbit_manage": "bool",
"PGID": "int?",
"PUID": "int?",
"SavePath": "str?",
"TZ": "str?",
"Username": "str?",
"QBT_USERNAME": "str?",
"certfile": "str",
"cifsdomain": "str?",
"cifspassword": "str?",
@@ -121,19 +131,17 @@
"keyfile": "str",
"localdisks": "str?",
"networkdisks": "str?",
"openvpn_alt_mode": "bool?",
"openvpn_config": "str?",
"openvpn_enabled": "bool?",
"openvpn_password": "str?",
"openvpn_username": "str?",
"LAN_NETWORK": "str",
"VPN_ENABLED": "list(yes|no)",
"VPN_PASSWORD": "str?",
"VPN_USERNAME": "str?",
"VPN_TYPE": "list(openvpn|wireguard)?",
"run_duration": "str?",
"silent": "bool?",
"smbv1": "bool?",
"ssl": "bool",
"whitelist": "str?"
"ssl": "bool"
},
"slug": "qbittorrent",
"udev": true,
"url": "https://github.com/alexbelgium/hassio-addons",
"version": "4.6.2"
"version": "4.6.2-wireguard_ovpn"
}

View File

@@ -1,9 +0,0 @@
#!/bin/bash
mkdir -p /config/addons_config/qBittorrent
if [ -f /config/addons_config/qbittorrent/qBittorrent.conf ] && [ -f /config/addons_config/qBittorrent/qBittorrent.conf ]; then
echo "Restore folders"
mv /config/addons_config/qBittorrent /config/addons_config/qBittorrent_old
mv /config/addons_config/qbittorrent /config/addons_config/qBittorrent
fi

View File

@@ -0,0 +1,4 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
curl --max-time 10 --connect-timeout 5 -s ipecho.net/plain > /currentip

View File

@@ -0,0 +1,96 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
# Create new folders
mkdir -p /config/wireguard
mkdir -p /config/openvpn
mkdir -p /config/qBittorrent/config
mkdir -p /config/qBittorrent/data
if [ -f /homeassistant/addons_config/qBittorrent/qBittorrent.conf ]; then
bashio::log.warning "----------------------------------------"
bashio::log.warning "Migrating configuration to the new addon"
bashio::log.warning "----------------------------------------"
mv /homeassistant/addons_config/qBittorrent/*.json /config/qBittorrent/config/
mv /homeassistant/addons_config/qBittorrent/*.conf /config/qBittorrent/config/
if [ -d /homeassistant/addons_config/qBittorrent/rss ]; then mv /homeassistant/addons_config/qBittorrent/rss /config/qBittorrent/config/; fi
mv /homeassistant/addons_config/qBittorrent/* /config/qBittorrent/data/
if [ -d /config/qBittorrent/data/addons_config ]; then rm -r /config/qBittorrent/data/addons_config; fi
if [ -d /config/qBittorrent/data/qBittorrent ]; then rm -r /config/qBittorrent/data/qBittorrent; fi
rm -r /homeassistant/addons_config/qBittorrent
bashio::log.yellow "... moved files from /config/addons_config/qBittorrent to /addon_configs/$HOSTNAME/qBitorrent (must be accessed with my Filebrowser addon)"
fi
if [ -d /homeassistant/openvpn ]; then
if [ "$(ls -A /homeassistant/openvpn)" ]; then
mv /homeassistant/openvpn/* /config/openvpn/
rm -r /homeassistant/openvpn
bashio::log.yellow "... moved files from /config/openvpn to /addon_configs/$HOSTNAME/openvpn"
fi
fi
if [ -f /homeassistant/addons_config/qbittorrent/config.yaml ]; then
mv /homeassistant/addons_config/qbittorrent/* /config/
rm -r /homeassistant/addons_config/qbittorrent
bashio::log.yellow "... moved config.yaml from /config/addons_config/qbittorrent to /addon_configs/$HOSTNAME"
fi
if [ -f /homeassistant/addons_autoscrips/qbittorrent.sh ]; then
mv /homeassistant/addons_autoscrips/qbittorrent.sh /config/
bashio::log.yellow "... moved qbittorrent.sh from /config/addons_autoscripts to /addon_configs/$HOSTNAME"
fi
if bashio::config.has_value 'openvpn_enable'; then
if bashio::config.true 'openvpn_enabled'; then
bashio::addon.option "VPN_ENABLED" "yes"
bashio::log.yellow "... openvpn_enable : was true, VPN_ENABLED set to yes"
bashio::addon.option "VPN_TYPE" "openvpn"
bashio::log.yellow "... openvpn_enable : was true, VPN_TYPE set to openvpn"
fi
bashio::addon.option "openvpn_enable"
bashio::log.yellow "... openvpn_enable : removed as not used anymore"
fi
if bashio::config.has_value 'openvpn_username'; then
bashio::addon.option "VPN_USERNAME" "$(bashio::config "openvpn_username")"
bashio::log.yellow "... openvpn_username : was set, VPN_USERNAME set to $(bashio::config "openvpn_username")"
bashio::addon.option "openvpn_username"
bashio::log.yellow "... openvpn_username : removed as not used anymore"
fi
if bashio::config.has_value 'Username'; then
bashio::addon.option "QBT_USERNAME" "$(bashio::config "Username")"
bashio::log.yellow "... Username : was set, QBT_USERNAME set to $(bashio::config "Username")"
bashio::addon.option "Username"
bashio::log.yellow "... Username : removed as not used anymore"
fi
if bashio::config.has_value 'openvpn_password'; then
bashio::addon.option "VPN_PASSWORD" "$(bashio::config "openvpn_password")"
bashio::log.yellow "... openvpn_password : was set, VPN_PASSWORD set to $(bashio::config "openvpn_password")"
bashio::addon.option "openvpn_password"
bashio::log.yellow "... openvpn_password : removed as not used anymore"
fi
if bashio::config.has_value 'whitelist'; then
bashio::addon.option "LAN_NETWORK" "$(bashio::config "whitelist")"
bashio::log.yellow "... whitelist : was set, LAN_NETWORK set to $(bashio::config "whitelist")"
bashio::addon.option "whitelist"
bashio::log.yellow "... whitelist : removed as not used anymore"
fi
if bashio::config.has_value 'smbv1'; then
bashio::addon.option "smbv1"
bashio::log.yellow "... smbv1 : removed as not used anymore"
fi
if bashio::config.has_value 'openvpn_config'; then
openvpn_config="$(bashio::config "openvpn_config")"
if [ -f "$openvpn_config" ]; then
mv "$openvpn_config" /config/openvpn/
fi
fi
if [ -d /config/qBittorrent/qBittorrent ]; then
rm -r /config/qBittorrent/qBittorrent
fi

View File

@@ -7,7 +7,7 @@ set -e
##########
# Define preferences line
CONFIG_LOCATION=/config/addons_config/qBittorrent
CONFIG_LOCATION=/config/qBittorrent/config/
mkdir -p "$CONFIG_LOCATION"
# copy default config
@@ -19,9 +19,8 @@ cd "$CONFIG_LOCATION"/ || true
LINE=$(sed -n '/\[Preferences\]/=' qBittorrent.conf) || bashio::exit.nok "qBittorrent.conf not valid"
LINE=$((LINE + 1))
# Remove unused folders
if [ -d "$CONFIG_LOCATION"/addons_config ]; then rm -r "$CONFIG_LOCATION"/addons_config; fi
if [ -d "$CONFIG_LOCATION"/qBittorrent ]; then rm -r "$CONFIG_LOCATION"/qBittorrent; fi
# Check file size
ORIGINAL_SIZE="$(wc -c "$CONFIG_LOCATION"/qBittorrent.conf)"
###########
# TIMEOUT #
@@ -68,20 +67,16 @@ chown -R "$PUID:$PGID" "$DOWNLOADS" || bashio::log.fatal "Error, please check de
sed -i -e '/CSRFProtection/d' \
-e '/ClickjackingProtection/d' \
-e '/HostHeaderValidation/d' \
-e '/WebUI\Address/d' \
-e '/Address/d' \
-e "$LINE i\WebUI\\\CSRFProtection=false" \
-e "$LINE i\WebUI\\\ClickjackingProtection=false" \
-e "$LINE i\WebUI\\\HostHeaderValidation=false" \
-e "$LINE i\WebUI\\\Address=*" qBittorrent.conf
#sed -i '/WebUI\ReverseProxySupportEnabled/d' qBittorrent.conf
#sed -i "$LINE i\WebUI\\\ReverseProxySupportEnabled=true" qBittorrent.conf
-e "$LINE i\WebUI\\\Address=\*" qBittorrent.conf
################
# Correct Port #
################
# sed -i '/PortRangeMin/d' qBittorrent.conf
# sed -i "$LINE i\Connection\\\PortRangeMin=6881" qBittorrent.conf
sed -i "s|6881|59595|g" qBittorrent.conf # Correction if required
################
@@ -110,7 +105,7 @@ fi
cd "$CONFIG_LOCATION"/ || true
WHITELIST="$(bashio::config 'whitelist')"
WHITELIST="$(bashio::config 'LAN_NETWORK')"
#clean data
sed -i '/AuthSubnetWhitelist/d' qBittorrent.conf
@@ -128,22 +123,45 @@ fi
###############
cd "$CONFIG_LOCATION"/ || true
if bashio::config.has_value 'Username'; then
USERNAME=$(bashio::config 'Username')
#clean data
sed -i '/WebUI\\\Username/d' qBittorrent.conf
#add data
sed -i "/\[Preferences\]/a\WebUI\\\Username=$USERNAME" qBittorrent.conf
bashio::log.info "WEBUI username set to $USERNAME"
if bashio::config.has_value 'QBT_USERNAME'; then
QBT_USERNAME=$(bashio::config 'QBT_USERNAME')
else
if ! grep -q Username qBittorrent.conf; then
sed -i "/\[Preferences\]/a\WebUI\\\Username=admin" qBittorrent.conf
fi
QBT_USERNAME="admin"
fi
LINE2="$(sed -n '/Password_PBKDF2/=' qBittorrent.conf)"
if [[ "$LINE" -gt "$LINE2" ]]; then sed -i '/Password_PBKDF2/d' qBittorrent.conf; fi
if ! grep -q Password_PBKDF2 qBittorrent.conf; then
sed -i "/\[Preferences\]/a\WebUI\\\Password_PBKDF2=\"@ByteArray(cps93Gf8ma8EM3QRon+spg==:wYFoMNVmdiqzWYQ6mFrvET+RRbBSIPVfXFFeEy0ZEagxvNuEF7uGVnG5iq8oeu38kGLtmJqCM2w8cTdtORDP2A==)\"" qBittorrent.conf
#clean data
sed -i '/WebUI\\\Username/d' qBittorrent.conf
#add data
sed -i "/\[Preferences\]/a\WebUI\\\Username=$QBT_USERNAME" qBittorrent.conf
bashio::log.info "WEBUI username set to $QBT_USERNAME"
###############
# PASSWORD #
###############
# Set initial password to homeassistant
cd "$CONFIG_LOCATION"/ || true
NEEDREBOOT=""
if ! grep -q "Password_PBKDF2" qBittorrent.conf; then
function escape_special_characters() {
local value="$1"
value=$(echo "$value" | sed 's/[&/\;.<>`$*(){}[\]~^|!?@%#=,:+_-]/\\&/g')
echo "$value"
}
PBKDF2="UDxNW6zG8wJHG9PvnGFP4A==:gJZEXLbR2XYNN042G4ygLMvZi2BhHm2m6Soz6GVCrCuVZH6OSkUan7AvUDEiSodHckUm8oNTkx9atQwcUf/JLQ=="
PBKDF2="$(escape_special_characters "$PBKDF2")"
sed -i "/\[Preferences\]/a\WebUI\\\Password_PBKDF2=\"@ByteArray($PBKDF2)\"" qBittorrent.conf
NEEDREBOOT=true
fi
####################
# REBOOT IF NEEDED #
####################
# Reboot if first time password is set, or if password is changed
# Check file size
if [[ "$ORIGINAL_SIZE" != "$(wc -c "$CONFIG_LOCATION"/qBittorrent.conf)" ]]; then
bashio::log.info "Configuration changed, rebooting"
bashio::addon.restart
fi
@@ -217,5 +235,5 @@ fi
# CLOSE #
##########
bashio::log.info "Default username/password : $USERNAME/homeassistant"
bashio::log.info "Default username/password : $QBT_USERNAME/homeassistant. Please change your password on first connection"
bashio::log.info "Configuration can be found in $CONFIG_LOCATION"

View File

@@ -0,0 +1,31 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
set -e
if bashio::config.true "qbit_manage"; then
bashio::log.info "qbit_manage activated, setting system"
# Set folder
echo "... setting folder"
mkdir -p /config/qbit_manage
chmod -R 777 /config/qbit_manage
# Create default file
if [ ! -f /config/qbit_manage/qbit_manage.yml ]; then
echo "... create default file"
cp /qbit_manage/config/config.yml.sample /config/qbit_manage/qbit_manage.yml
fi
# Set qBittorrent options
echo "... align QBT username and password"
sed -i "/host:/c\ host: \"localhost:8080\"" /config/qbit_manage/qbit_manage.yml
sed -i "/user:/c\ user: \"$(bashio::config "QBT_USERNAME")\"" /config/qbit_manage/qbit_manage.yml
sed -i "s=root_dir: \"/data/torrents/\"=$(bashio::config.has_value "SavePath")=g" /config/qbit_manage/qbit_manage.yml
sed -i "s=remote_dir: \"/mnt/user/data/torrents/\"=$(bashio::config.has_value "SavePath")=g" /config/qbit_manage/qbit_manage.yml
# Startup delay 30s ; config file specific ; log file specific
python /qbit_manage/qbit_manage.py -sd 30 --config-file "/config/qbit_manage/qbit_manage.yml" --log-file "/config/qbit_manage/qbit_manage.log" & true
bashio::log.info "qbit_manage started with config in /addon_configs/$HOSTNAME/qbit_manage/qbit_manage.yaml accessible with the Filebrowser addon"
fi

View File

@@ -1,118 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
set -e
# ==============================================================================
declare openvpn_config
declare openvpn_username
declare openvpn_password
QBT_CONFIG_FILE="/config/addons_config/qBittorrent/qBittorrent.conf"
if bashio::config.true 'openvpn_enabled'; then
bashio::log.info "Configuring openvpn"
# Get current ip
curl -s ipecho.net/plain > /currentip
#####################
# CONFIGURE OPENVPN #
#####################
openvpn_config=$(bashio::config 'openvpn_config')
cp "/config/openvpn/${openvpn_config}" /etc/openvpn/config.ovpn || bashio::log.error "openvpn config file not found in /config/openvpn/${openvpn_config}"
openvpn_username=$(bashio::config 'openvpn_username')
echo "${openvpn_username}" >/etc/openvpn/credentials
openvpn_password=$(bashio::config 'openvpn_password')
echo "${openvpn_password}" >>/etc/openvpn/credentials
sed -i 's/auth-user-pass.*/auth-user-pass \/etc\/openvpn\/credentials/g' /etc/openvpn/config.ovpn
# Permissions
chmod 600 /etc/openvpn/credentials
chmod 755 /etc/openvpn/up.sh
chmod 755 /etc/openvpn/down.sh
chmod 755 /etc/openvpn/up-qbittorrent.sh
chmod +x /etc/openvpn/up.sh
chmod +x /etc/openvpn/up-qbittorrent.sh
bashio::log.info "openvpn correctly set, qbittorrent will run tunnelled through openvpn"
#########################
# CONFIGURE QBITTORRENT #
#########################
# WITH CONTAINER BINDING
#########################
# If alternative mode enabled, bind container
if bashio::config.true 'openvpn_alt_mode'; then
echo "Using container binding"
# Remove interface
echo "... deleting previous interface settings"
sed -i '/Interface/d' "$QBT_CONFIG_FILE"
# Modify ovpn config
if grep -q route-nopull /etc/openvpn/config.ovpn; then
echo "... removing route-nopull from your config.ovpn"
sed -i '/route-nopull/d' /etc/openvpn/config.ovpn
fi
# Exit
exit 0
fi
# WITH INTERFACE BINDING
#########################
# Connection with interface binding
echo "Using interface binding in the qBittorrent app"
# Define preferences line
cd /config/addons_config/qBittorrent/ || exit 1
LINE=$(sed -n '/\[Preferences\]/=' "$QBT_CONFIG_FILE")
LINE=$((LINE + 1))
SESSION=$(sed -n '/\[BitTorrent\]/=' "$QBT_CONFIG_FILE")
# If qBittorrent.conf exists
if [ -f "$QBT_CONFIG_FILE" ]; then
# Remove previous line and bind tun0
echo "... deleting previous interface settings"
sed -i '/Interface/d' "$QBT_CONFIG_FILE"
# Bind tun0
echo "... binding tun0 interface in qBittorrent configuration"
sed -i "$LINE i\Connection\\\Interface=tun0" "$QBT_CONFIG_FILE"
sed -i "$LINE i\Connection\\\InterfaceName=tun0" "$QBT_CONFIG_FILE"
if [ "$SESSION" != "" ]; then
SESSION=$((SESSION + 1))
sed -i "$SESSION i\Session\\\Interface=tun0" "$QBT_CONFIG_FILE"
sed -i "$SESSION i\Session\\\InterfaceName=tun0" "$QBT_CONFIG_FILE"
fi
else
bashio::log.error "qBittorrent config file doesn't exist, openvpn must be added manually to qbittorrent options "
exit 1
fi
# Modify ovpn config
if ! grep -q route-nopull /etc/openvpn/config.ovpn; then
echo "... adding route-nopull to your config.ovpn"
sed -i "1a route-nopull" /etc/openvpn/config.ovpn
fi
else
##################
# REMOVE OPENVPN #
##################
# Ensure no redirection by removing the direction tag
if [ -f "$QBT_CONFIG_FILE" ]; then
sed -i '/Interface/d' "$QBT_CONFIG_FILE"
fi
bashio::log.info "Direct connection without VPN enabled"
fi

View File

@@ -1,36 +0,0 @@
#!/bin/sh
# shellcheck disable=SC2154,SC2004,SC2059,SC2086
# Copyright (c) 2006-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Contributed by Roy Marples (uberlord@gentoo.org)
# If we have a service specific script, run this now
if [ -x /etc/openvpn/"${RC_SVCNAME}"-down.sh ] ; then
/etc/openvpn/"${RC_SVCNAME}"-down.sh "$@"
fi
# Restore resolv.conf to how it was
if [ "${PEER_DNS}" != "no" ]; then
if [ -x /sbin/resolvconf ] ; then
/sbin/resolvconf -d "${dev}"
elif [ -e /etc/resolv.conf-"${dev}".sv ] ; then
# Important that we cat instead of move incase resolv.conf is
# a symlink and not an actual file
cat /etc/resolv.conf-"${dev}".sv > /etc/resolv.conf
rm -f /etc/resolv.conf-"${dev}".sv
fi
fi
if [ -n "${RC_SVCNAME}" ]; then
# Re-enter the init script to start any dependant services
if /etc/init.d/"${RC_SVCNAME}" --quiet status ; then
export IN_BACKGROUND=true
if [ -d /var/run/s6/container_environment ]; then printf "%s" "true" > /var/run/s6/container_environment/IN_BACKGROUND; fi
printf "%s" "IN_BACKGROUND=\"true\"" >> ~/.bashrc
/etc/init.d/"${RC_SVCNAME}" --quiet stop
fi
fi
exit 0
# vim: ts=4 :

View File

@@ -1,9 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
set -e
WEBUI_PORT=${WEBUI_PORT:-8080}
exec \
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost ${WEBUI_PORT}" \
s6-setuidgid abc /usr/bin/qbittorrent-nox --webui-port="${WEBUI_PORT}"

View File

@@ -1,97 +0,0 @@
#!/bin/sh
# shellcheck disable=SC2154,SC2004,SC2059,SC2086
# launch qbittorrent
/etc/openvpn/up-qbittorrent.sh "${4}" &
# Copyright (c) 2006-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Contributed by Roy Marples (uberlord@gentoo.org)
# Setup our resolv.conf
# Vitally important that we use the domain entry in resolv.conf so we
# can setup the nameservers are for the domain ONLY in resolvconf if
# we're using a decent dns cache/forwarder like dnsmasq and NOT nscd/libc.
# nscd/libc users will get the VPN nameservers before their other ones
# and will use the first one that responds - maybe the LAN ones?
# non resolvconf users just the the VPN resolv.conf
# FIXME:- if we have >1 domain, then we have to use search :/
# We need to add a flag to resolvconf to say
# "these nameservers should only be used for the listed search domains
# if other global nameservers are present on other interfaces"
# This however, will break compatibility with Debians resolvconf
# A possible workaround would be to just list multiple domain lines
# and try and let resolvconf handle it
if [ "${PEER_DNS}" != "no" ]; then
NS=
DOMAIN=
SEARCH=
i=1
while true ; do
eval opt=\$foreign_option_${i}
[ -z "${opt}" ] && break
if [ "${opt}" != "${opt#dhcp-option DOMAIN *}" ] ; then
if [ -z "${DOMAIN}" ] ; then
DOMAIN="${opt#dhcp-option DOMAIN *}"
else
SEARCH="${SEARCH}${SEARCH:+ }${opt#dhcp-option DOMAIN *}"
fi
elif [ "${opt}" != "${opt#dhcp-option DNS *}" ] ; then
NS="${NS}nameserver ${opt#dhcp-option DNS *}\n"
fi
i=$((${i} + 1))
done
if [ -n "${NS}" ] ; then
DNS="# Generated by openvpn for interface ${dev}\n"
if [ -n "${SEARCH}" ] ; then
DNS="${DNS}search ${DOMAIN} ${SEARCH}\n"
elif [ -n "${DOMAIN}" ]; then
DNS="${DNS}domain ${DOMAIN}\n"
fi
DNS="${DNS}${NS}"
if [ -x /sbin/resolvconf ] ; then
printf "${DNS}" | /sbin/resolvconf -a "${dev}"
else
# Preserve the existing resolv.conf
if [ -e /etc/resolv.conf ] ; then
cp /etc/resolv.conf /etc/resolv.conf-"${dev}".sv
fi
printf "${DNS}" > /etc/resolv.conf
chmod 644 /etc/resolv.conf
fi
fi
fi
# Below section is Gentoo specific
# Quick summary - our init scripts are re-entrant and set the RC_SVCNAME env var
# as we could have >1 openvpn service
if [ -n "${RC_SVCNAME}" ]; then
# If we have a service specific script, run this now
if [ -x /etc/openvpn/"${RC_SVCNAME}"-up.sh ] ; then
/etc/openvpn/"${RC_SVCNAME}"-up.sh "$@"
fi
# Re-enter the init script to start any dependant services
if ! /etc/init.d/"${RC_SVCNAME}" --quiet status ; then
export IN_BACKGROUND=true
if [ -d /var/run/s6/container_environment ]; then printf "%s" "true" > /var/run/s6/container_environment/IN_BACKGROUND; fi
printf "%s" "IN_BACKGROUND=\"true\"" >> ~/.bashrc
/etc/init.d/${RC_SVCNAME} --quiet start
fi
fi
###############
# ALLOW WEBUI #
###############
ip route add 10.0.0.0/8 via 172.30.32.1
ip route add 192.168.0.0/16 via 172.30.32.1
ip route add 172.16.0.0/12 via 172.30.32.1
exit 0
# vim: ts=4 :

View File

@@ -1,11 +0,0 @@
#============================#
# ALEXBELGIUM'S ADDONS #
#============================#
_.------.
_.-` ('>.-`"""-.
'.--'` _'` _ .--.)
-' '-.-';` `
' - _.' ``'--.
'---` .-'""`
/`
#=== Home Assistant Addon ===#

View File

@@ -1,23 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
set -e
WEBUI_PORT=${WEBUI_PORT:-8080}
if bashio::config.true 'silent'; then
sed -i 's|/proc/1/fd/1 hassio;|off;|g' /etc/nginx/nginx.conf
fi
if bashio::config.true 'openvpn_enabled'; then
exec /usr/sbin/openvpn --config /etc/openvpn/config.ovpn --script-security 2 --up /etc/openvpn/up.sh --down /etc/openvpn/down.sh
else
if bashio::config.true 'silent'; then
exec \
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost ${WEBUI_PORT}" \
s6-setuidgid abc /usr/bin/qbittorrent-nox --webui-port="${WEBUI_PORT}" >/dev/null
else
exec \
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost ${WEBUI_PORT}" \
s6-setuidgid abc /usr/bin/qbittorrent-nox --webui-port="${WEBUI_PORT}"
fi
fi

View File

@@ -8,20 +8,15 @@ bashio::net.wait_for 8080 localhost 900
bashio::log.info "Starting NGinx..."
# Check vpn is working
if [ -f /currentip ]; then
if [[ "$(bashio::config 'VPN_ENABLED')" == "yes" ]]; then
exec nginx & \
while true; do
# Get vpn ip
if bashio::config.true 'openvpn_alt_mode'; then
curl -s ipecho.net/plain > /vpnip
else
curl -s ipecho.net/plain --interface tun0 > /vpnip
fi
curl -s ipecho.net/plain --interface tun0 > /vpnip
# Verify ip has changed
if [[ "$(cat /vpnip)" = "$(cat /currentip)" ]]; then
bashio::log.fatal "VPN is not properly configured. Your ip is exposed. Please fix this, or do not use the vpn alt mode"
bashio::log.fatal "VPN is not properly configured. Your ip is exposed."
bashio::exit.nok
fi
@@ -32,7 +27,7 @@ if [ -f /currentip ]; then
bashio::log.info "VPN is up and running with ip $(cat /vpnip), based in country : $COUNTRY"
# Check every 15m
sleep 15m
sleep 30m
true
done

View File

@@ -4,6 +4,6 @@
"repository": "alexbelgium/hassio-addons",
"slug": "qbittorrent",
"source": "github",
"upstream_repo": "linuxserver/docker-qbittorrent",
"upstream_repo": "trigus42/qbittorrentvpn",
"upstream_version": "4.6.2"
}