mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-03 22:34:11 +02:00
New generation
This commit is contained in:
@@ -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
|
||||
4
qbittorrent/rootfs/etc/cont-init.d/00-ipleak.sh
Normal file
4
qbittorrent/rootfs/etc/cont-init.d/00-ipleak.sh
Normal 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
|
||||
96
qbittorrent/rootfs/etc/cont-init.d/00-migration.sh
Normal file
96
qbittorrent/rootfs/etc/cont-init.d/00-migration.sh
Normal 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
|
||||
@@ -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"
|
||||
|
||||
31
qbittorrent/rootfs/etc/cont-init.d/92-qbit_manage.sh
Normal file
31
qbittorrent/rootfs/etc/cont-init.d/92-qbit_manage.sh
Normal 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
|
||||
@@ -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
|
||||
@@ -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 :
|
||||
@@ -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}"
|
||||
@@ -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 :
|
||||
@@ -1,11 +0,0 @@
|
||||
#============================#
|
||||
# ALEXBELGIUM'S ADDONS #
|
||||
#============================#
|
||||
_.------.
|
||||
_.-` ('>.-`"""-.
|
||||
'.--'` _'` _ .--.)
|
||||
-' '-.-';` `
|
||||
' - _.' ``'--.
|
||||
'---` .-'""`
|
||||
/`
|
||||
#=== Home Assistant Addon ===#
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user