From 46722120356ca00634a7c1334ceac19c9a1d55ae Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Wed, 10 Feb 2021 10:58:05 +0100 Subject: [PATCH] webui --- qbittorrent/config.json | 2 +- .../etc/cont-init.d/91-configuration.sh | 97 +++++++++---------- 2 files changed, 49 insertions(+), 50 deletions(-) diff --git a/qbittorrent/config.json b/qbittorrent/config.json index bbfdbc17a..4fdf988fc 100644 --- a/qbittorrent/config.json +++ b/qbittorrent/config.json @@ -53,7 +53,7 @@ "PUID": "int", "PGID": "int", "localdisks": "str?", - "customUI": "list(vuetorrent|qbit-matUI)?", + "customUI": "list(vuetorrent|qbit-matUI|qb-web?", "networkdisks": "str?", "cifsusername": "str?", "cifspassword": "str?", diff --git a/qbittorrent/rootfs/etc/cont-init.d/91-configuration.sh b/qbittorrent/rootfs/etc/cont-init.d/91-configuration.sh index 4fae8fe10..8b068f259 100644 --- a/qbittorrent/rootfs/etc/cont-init.d/91-configuration.sh +++ b/qbittorrent/rootfs/etc/cont-init.d/91-configuration.sh @@ -4,10 +4,10 @@ # INIT # ########## -# Define preferences line +# Define preferences line cd /config/qBittorrent/ LINE=$(sed -n '/Preferences/=' qBittorrent.conf) -LINE=$[LINE + 1] +LINE=$((LINE + 1)) ################ # SSL CONFIG # @@ -16,69 +16,68 @@ LINE=$[LINE + 1] # Clean data sed -i '/HTTPS/d' qBittorrent.conf - bashio::config.require.ssl if bashio::config.true 'ssl'; then bashio::log.info "ssl enabled. If webui don't work, disable ssl or check your certificate paths" - #set variables - CERTFILE=$(bashio::config 'certfile') + #set variables + CERTFILE=$(bashio::config 'certfile') KEYFILE=$(bashio::config 'keyfile') sed -i "$LINE i\WebUI\\\HTTPS\\\Enabled=True" qBittorrent.conf sed -i "$LINE i\WebUI\\\HTTPS\\\CertificatePath=/ssl/$CERTFILE" qBittorrent.conf sed -i "$LINE i\WebUI\\\HTTPS\\\KeyPath=/ssl/$KEYFILE" qBittorrent.conf fi -################ -# Alternate UI # -################ - -#clean data -sed -i '/AlternativeUIEnabled/d' qBittorrent.conf - -if bashio::config.has_value 'customUI'; then -bashio::log.info "Alternate UI enabled. If webui don't work, disable this option" -CUSTOMUI=$(bashio::config 'customUI') - -### IF VUETORRENT -if [ CUSTOMUI="vuetorrent" ];then - CUSTOMUI="WDaan/VueTorrent" - curl -s -S -J -L -o /release.zip $(curl -s https://api.github.com/repos/WDaan/VueTorrent/releases/latest | grep -o "http.*release.zip") > /dev/null - mkdir -p /data/$CUSTOMUI - unzip -o /release.zip -d /data/$CUSTOMUI/ - rm /*.zip - CUSTOMUIDIR=$(find /data/$CUSTOMUI -iname "public" -type d) - FOLDER="$(dirname "$CUSTOMUIDIR")" - sed -i "$LINE i\WebUI\\\AlternativeUIEnabled=true" /config/qBittorrent/qBittorrent.conf - sed -i "$LINE i\WebUI\\\RootFolder=$CUSTOMUIDIR" /config/qBittorrent/qBittorrent.conf -fi - -### IF qbit-matUI -if [ CUSTOMUI="qbit-matUI" ];then -CUSTOMUI="bill-ahmed/qbit-matUI" -curl -J -L -o /release.zip $(curl -s https://api.github.com/repos/bill-ahmed/qbit-matUI/releases/latest | grep -o "http.*Unix.*.zip") -mkdir -p /data/$CUSTOMUI -unzip -o /release.zip -d /data/$CUSTOMUI/ -rm /*.zip -CUSTOMUIDIR=$(find /data/$CUSTOMUI -iname "public" -type d) -FOLDER="$(dirname "$CUSTOMUIDIR")" -sed -i "$LINE i\WebUI\\\AlternativeUIEnabled=true" /config/qBittorrent/qBittorrent.conf -sed -i "$LINE i\WebUI\\\RootFolder=$CUSTOMUIDIR" /config/qBittorrent/qBittorrent.conf -fi - -fi - ################ # WHITELIST # ################ cd /config/qBittorrent/ if bashio::config.has_value 'whitelist'; then -WHITELIST=$(bashio::config 'whitelist') + WHITELIST=$(bashio::config 'whitelist') + #clean data + sed -i '/AuthSubnetWhitelist/d' qBittorrent.conf + sed -i "$LINE i\WebUI\\\AuthSubnetWhitelistEnabled=true" qBittorrent.conf + sed -i "$LINE i\WebUI\\\AuthSubnetWhitelist=$WHITELIST" qBittorrent.conf + bashio::log.info "Whitelisted subsets will not require a password : $WHITELIST" +fi + +################ +# Alternate UI # +################ + #clean data -sed -i '/AuthSubnetWhitelist/d' qBittorrent.conf -sed -i "$LINE i\WebUI\\\AuthSubnetWhitelistEnabled=true" qBittorrent.conf -sed -i "$LINE i\WebUI\\\AuthSubnetWhitelist=$WHITELIST" qBittorrent.conf -bashio::log.info "Whitelisted subsets will not require a password : $WHITELIST" +sed -i '/AlternativeUIEnabled/d' qBittorrent.conf +rm -f -r /data/webui +mkdir -p /data/webui + +if bashio::config.has_value 'customUI'; then + ### Variables + CUSTOMUI=$(bashio::config 'customUI') + bashio::log.info "Alternate UI enabled : $CUSTOMUI. If webui don't work, disable this option" + + ### Download WebUI + case $CUSTOMUI in + "vuetorrent") + curl -s -S -J -L -o /data/webui/release.zip $(curl -s https://api.github.com/repos/WDaan/VueTorrent/releases/latest | grep -o "http.*release.zip") >/dev/null + ;; + + "qbit-matUI") + curl -J -L -o /data/webui/release.zip $(curl -s https://api.github.com/repos/bill-ahmed/qbit-matUI/releases/latest | grep -o "http.*Unix.*.zip") >/dev/null + ;; + + "qb-web") + curl -J -L -o /data/webui/release.zip $(curl -s https://api.github.com/repos/CzBiX/qb-web/releases/latest | grep -o "http.*.zip") >/dev/null + ;; + esac + + ### Install WebUI + mkdir -p /data/webui/$CUSTOMUI + unzip -u -q /data/webui/release.zip -d /data/webui/$CUSTOMUI + rm /data/webui/*.zip + CUSTOMUIDIR=$(find /data/webui/$CUSTOMUI -iname "public" -type d) + CUSTOMUIDIR="$(dirname "$CUSTOMUIDIR")" + sed -i "$LINE i\WebUI\\\AlternativeUIEnabled=true" /config/qBittorrent/qBittorrent.conf + sed -i "$LINE i\WebUI\\\RootFolder=$CUSTOMUIDIR" /config/qBittorrent/qBittorrent.conf fi ##########