chmod +x scripts

This commit is contained in:
Alexandre
2022-06-15 20:44:11 +02:00
parent 0047e2489f
commit 3351e5b29c
218 changed files with 0 additions and 9448 deletions

View File

@@ -1,50 +0,0 @@
#!/bin/bash
# If dockerfile failed install manually
##############################
# Automatic modules download #
##############################
if [ -e "/MODULESFILE" ]; then
MODULES=$(</MODULESFILE)
MODULES="${MODULES:-00-banner.sh}"
echo "Executing modules script : $MODULES"
if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \
&& if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \
&& apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \
&& mkdir -p /etc/cont-init.d \
&& for scripts in $MODULES; do echo "$scripts" && curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" && [ "$(sed -n '/\/bin/p;q' /etc/cont-init.d/"$scripts")" != "" ] || (echo "script failed to install $scripts" && exit 1); done \
&& chmod -R 755 /etc/cont-init.d
fi
#######################
# Automatic installer #
#######################
if [ -e "/ENVFILE" ]; then
PACKAGES=$(</ENVFILE)
echo "Executing dependency script with custom elements : $PACKAGES"
if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \
&& if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \
&& curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/automatic_packages.sh" --output /automatic_packages.sh \
&& chmod 777 /automatic_packages.sh \
&& eval /./automatic_packages.sh "${PACKAGES:-}" \
&& rm /automatic_packages.sh
fi
if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then
for scripts in $MODULES; do
echo "$scripts : executing"
chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts"
chmod a+x /etc/cont-init.d/"$scripts"
/./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?"
rm /etc/cont-init.d/"$scripts"
done | tac
fi
#######################
# Correct permissions #
#######################
[ -d /etc/services.d ] && chmod -R 777 /etc/services.d
[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d

View File

@@ -1,5 +0,0 @@
#!/bin/bash
# Avoid linuxserver anti tamper issues
chown root:root /config/custom-cont-init.d* &>/dev/null || true
chown root:root /config/custom-services* &>/dev/null || true

View File

@@ -1,51 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
DEBUG=$(bashio::config 'TZ')
[ "$DEBUG" = "debug" ] && echo "Before declare"
#################
# NGINX SETTING #
#################
#declare admin_port
declare qbittorrent_protocol=http
[ "$DEBUG" = "debug" ] && echo "Before ssl"
# Generate Ingress configuration
if bashio::config.true 'ssl'; then
qbittorrent_protocol=https
fi
[ "$DEBUG" = "debug" ] && echo "Before cp"
cp /etc/nginx/templates/ingress.gtpl /etc/nginx/servers/ingress.conf
[ "$DEBUG" = "debug" ] && echo "Before sed"
sed -i "s|{{ .interface }}|$(bashio::addon.ip_address)|g" /etc/nginx/servers/ingress.conf
sed -i "s|{{ .port }}|$(bashio::addon.ingress_port)|g" /etc/nginx/servers/ingress.conf
sed -i "s|{{ .protocol }}|${qbittorrent_protocol}|g" /etc/nginx/servers/ingress.conf
sed -i "s|{{ .certfile }}|$(bashio::config 'certfile')|g" /etc/nginx/servers/ingress.conf
sed -i "s|{{ .keyfile }}|$(bashio::config 'keyfile')|g" /etc/nginx/servers/ingress.conf
sed -i "s|{{ .ssl }}|$(bashio::config 'ssl')|g" /etc/nginx/servers/ingress.conf
######################
# VUETORRENT INSTALL #
######################
[ "$DEBUG" = "debug" ] && echo "Before var"
LATEST_RELEASE=$(curl -f -s --retry 5 -L https://api.github.com/repos/wdaan/vuetorrent/releases/latest |
grep "browser_download_url.*zip" |
cut -d : -f 2,3 |
tr -d \" |
xargs)
[ "$DEBUG" = "debug" ] && echo "Before curl"
curl -f -s -S -O -J -L "$LATEST_RELEASE"
[ "$DEBUG" = "debug" ] && echo "Before unzip"
unzip -o vuetorrent.zip -d / >/dev/null
[ "$DEBUG" = "debug" ] && echo "Before rm"
rm /vuetorrent.zip >/dev/null

View File

@@ -1,171 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
##########
# INIT #
##########
# Define preferences line
mkdir -p /config/qBittorrent
cd /config/qBittorrent/ || true
LINE=$(sed -n '/Preferences/=' qBittorrent.conf)
LINE=$((LINE + 1))
###########
# TIMEOUT #
###########
if bashio::config.has_value 'run_duration'; then
rm /etc/services.d/qbittorrent/run
mv /etc/services.d/qbittorrent/timer /etc/services.d/qbittorrent/run
chmod +x /etc/services.d/qbittorrent/run
else
rm /etc/services.d/qbittorrent/timer
fi
##################
# Default folder #
##################
# Set variable
DOWNLOADS=$(bashio::config 'SavePath')
# Set configuration
if bashio::config.has_value 'SavePath'; then
# Replace save path
CURRENTSAVEPATH=$(sed -n '/Downloads\\SavePath/p' qBittorrent.conf)
sed -i "s|${CURRENTSAVEPATH#*=}|$DOWNLOADS|g" qBittorrent.conf 2>/dev/null || true
# Replace session save path
CURRENTSAVEPATH=$(sed -n '/Session\\DefaultSavePath/p' qBittorrent.conf)
sed -i "s|${CURRENTSAVEPATH#*=}|$DOWNLOADS|g" qBittorrent.conf 2>/dev/null || true
# Info
bashio::log.info "Downloads can be found in $DOWNLOADS"
fi
# Create default location
mkdir -p "$DOWNLOADS" || bashio::log.fatal "Error : folder defined in SavePath doesn't exist and can't be created. Check path"
chown -R abc:abc "$DOWNLOADS" || bashio::log.fatal "Error, please check default save folder configuration in addon"
##############
# Avoid bugs #
##############
sed -i '/CSRFProtection/d' qBittorrent.conf
sed -i '/ClickjackingProtection/d' qBittorrent.conf
sed -i '/HostHeaderValidation/d' qBittorrent.conf
sed -i '/WebUI\Address/d' qBittorrent.conf
sed -i "$LINE i\WebUI\\\CSRFProtection=false" qBittorrent.conf
sed -i "$LINE i\WebUI\\\ClickjackingProtection=false" qBittorrent.conf
sed -i "$LINE i\WebUI\\\HostHeaderValidation=false" qBittorrent.conf
sed -i "$LINE i\WebUI\\\Address=*" qBittorrent.conf
################
# Correct Port #
################
# sed -i '/PortRangeMin/d' qBittorrent.conf
# sed -i "$LINE i\Connection\\\PortRangeMin=6881" qBittorrent.conf
################
# SSL CONFIG #
################
# 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')
KEYFILE=$(bashio::config 'keyfile')
#Modify configuration
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
################
# WHITELIST #
################
cd /config/qBittorrent/ || true
if bashio::config.has_value 'whitelist'; then
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
###############
# USERNAME #
###############
cd /config/qBittorrent/ || 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 "$LINE i\WebUI\\\Username=$USERNAME" qBittorrent.conf
bashio::log.info "WEBUI username set to $USERNAME"
fi
################
# Alternate UI #
################
# Clean data
sed -i '/AlternativeUIEnabled/d' qBittorrent.conf
sed -i '/RootFolder/d' qBittorrent.conf
rm -f -r /webui
mkdir -p /webui
chown abc:abc /webui
CUSTOMUI=$(bashio::config 'customUI')
if bashio::config.has_value 'customUI' && [ ! "$CUSTOMUI" = default ]; then
### Variables
bashio::log.info "Alternate UI enabled : $CUSTOMUI. If webui don't work, disable this option"
### Download WebUI
case $CUSTOMUI in
"vuetorrent")
curl -f -s -S -J -L -o /webui/release.zip "$(curl -f -s https://api.github.com/repos/WDaan/VueTorrent/releases/latest | grep -o "http.*vuetorrent.zip" | head -1)" >/dev/null
;;
"qbit-matUI")
curl -f -s -S -J -L -o /webui/release.zip "$(curl -f -s https://api.github.com/repos/bill-ahmed/qbit-matUI/releases/latest | grep -o "http.*Unix.*.zip" | head -1)" >/dev/null
;;
"qb-web")
curl -f -s -S -J -L -o /webui/release.zip "$(curl -f -s https://api.github.com/repos/CzBiX/qb-web/releases | grep -o "http.*qb-web-.*zip" | head -1)" >/dev/null
;;
esac
### Install WebUI
mkdir -p /webui/"$CUSTOMUI"
unzip -q /webui/release.zip -d /webui/"$CUSTOMUI"
rm /webui/*.zip
CUSTOMUIDIR="$(dirname "$(find /webui/"$CUSTOMUI" -iname "public" -type d)")"
# Set qbittorrent
sed -i "$LINE i\WebUI\\\AlternativeUIEnabled=true" /config/qBittorrent/qBittorrent.conf
sed -i "$LINE i\WebUI\\\RootFolder=$CUSTOMUIDIR" /config/qBittorrent/qBittorrent.conf
# Set nginx
#sed -i "s=/vuetorrent/public/=$CUSTOMUIDIR/public/=g" /etc/nginx/servers/ingress.conf
#sed -i "s=vue.torrent=$CUSTOMUI.torrent=g" /etc/nginx/servers/ingress.conf
fi
##########
# CLOSE #
##########
bashio::log.info "Default username/password : admin/adminadmin"
bashio::log.info "Configuration can be found in /config/qBittorrent"

View File

@@ -1,115 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
declare openvpn_config
declare openvpn_username
declare openvpn_password
QBT_CONFIG_FILE="/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/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
sed -i '/Interface/d' "$QBT_CONFIG_FILE"
bashio::log.info "Direct connection without VPN enabled"
fi

View File

@@ -1,34 +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
/etc/init.d/"${RC_SVCNAME}" --quiet stop
fi
fi
exit 0
# vim: ts=4 :

View File

@@ -1,6 +0,0 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
WEBUI_PORT=${WEBUI_PORT:-8080}
exec s6-setuidgid abc /usr/bin/qbittorrent-nox --webui-port="${WEBUI_PORT}"

View File

@@ -1,95 +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
/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 :