Updated scripts based on latest release of docker-transmission-openvpn, updated Dockerfile, fetches now vpn config externally

This commit is contained in:
Eldwan Brianne
2021-10-03 18:47:35 +02:00
parent 9f0bc3c941
commit 3a04130588
10504 changed files with 735 additions and 772708 deletions

View File

@@ -10,7 +10,9 @@ log() {
# This script will be called with tun/tap device name as parameter 1, and local IP as parameter 4
# See https://openvpn.net/index.php/open-source/documentation/manuals/65-openvpn-20x-manpage.html (--up cmd)
log "Up script executed with $*"
if [[ "$4" = "" ]]; then
log "ERROR, unable to obtain tunnel address"
log "killing $PPID"
@@ -31,12 +33,46 @@ if [[ ! -e "/dev/random" ]]; then
ln -s /dev/urandom /dev/random
fi
. /etc/deluge/userSetup.sh
# if config file doesnt exist (wont exist until user changes a setting) then copy default config file
if [[ ! -f /config/core.conf ]]; then
log "[info] Deluge config file doesn't exist, copying default..."
cp /etc/config/core.conf /config
else
log "[info] Deluge config file already exists, skipping copy"
fi
# if config file doesnt exist then copy stock config file
if [[ ! -f /config/web.conf ]]; then
log "[info] Deluge webui config file doesn't exist, copying default..."
cp /etc/config/web.conf /config
else
log "[info] Deluge webui config file already exists, skipping copy"
fi
log "Using ip of interface $1: $4"
export DELUGE_BIND_ADDRESS_IPV4=$4
if [ -e /config/core.conf ]; then
log "Updating Deluge conf file: listen_interface=$DELUGE_BIND_ADDRESS_IPV4"
log "Updating Deluge conf file"
#Interface
sed -i -e "s/\"listen_interface\": \".*\"/\"listen_interface\": \"$DELUGE_BIND_ADDRESS_IPV4\"/" /config/core.conf
#Deamon port
sed -i -e "s/\"daemon_port\": \".*\"/\"daemon_port\": \"$DELUGE_DEAMON_PORT\"/" /config/core.conf
#location
sed -i -e "s/\"download_location\": \".*\"/\"download_location\": \"${DELUGE_INCOMPLETE_DIR//\//\\/}\"/" /config/core.conf
sed -i -e "s/\"autoadd_location\": \".*\"/\"autoadd_location\": \"${DELUGE_WATCH_DIR//\//\\/}\"/" /config/core.conf
sed -i -e "s/\"move_completed_path\": \".*\"/\"move_completed_path\": \"${DELUGE_DOWNLOAD_DIR//\//\\/}\"/" /config/core.conf
sed -i -e "s/\"torrentfiles_location\": \".*\"/\"torrentfiles_location\": \"${DELUGE_TORRENT_DIR//\//\\/}\"/" /config/core.conf
fi
if [ -e /config/web.conf ]; then
log "Updating Deluge web conf file"
#Deamon port
sed -i -e "s/\"default_daemon\": \".*\"/\"default_daemon\": \"127.0.0.1:$DELUGE_DEAMON_PORT\"/" /config/web.conf
#Web port
sed -i -e "s/\"port\": \".*\"/\"port\": \"$DELUGE_WEB_PORT\"/" /config/web.conf
fi
if [[ "true" = "$DROP_DEFAULT_ROUTE" ]]; then
@@ -44,31 +80,6 @@ if [[ "true" = "$DROP_DEFAULT_ROUTE" ]]; then
ip r del default || exit 1
fi
## If we use UFW or the LOCAL_NETWORK we need to grab network config info
if [[ "${ENABLE_UFW,,}" == "true" ]] || [[ -n "${LOCAL_NETWORK-}" ]]; then
eval $(/sbin/ip r l | awk '{if($5!="tun0"){print "GW="$3"\nINT="$5; exit}}')
## IF we use UFW_ALLOW_GW_NET along with ENABLE_UFW we need to know what our netmask CIDR is
if [[ "${ENABLE_UFW,,}" == "true" ]] && [[ "${UFW_ALLOW_GW_NET,,}" == "true" ]]; then
eval $(ip r l dev ${INT} | awk '{if($3=="link"){print "GW_CIDR="$1; exit}}')
fi
fi
log "Got local network ${GW} and CIDR ${GW_CIDR} on interface ${INT}"
# if [[ "${ENABLE_UFW,,}" == "true" && "${UFW_ALLOW_GW_NET,,}" == "true" ]]; then
# log "Allow from ${GW_CIDR}"
# ufw allow from ${GW_CIDR}
# fi
if [[ -n "${LOCAL_NETWORK-}" ]]; then
if [[ -n "${GW-}" ]] && [[ -n "${INT-}" ]]; then
for localNet in ${LOCAL_NETWORK//,/ }; do
log "Adding route to local network ${localNet} via ${GW} dev ${INT}"
/sbin/ip r a "${localNet}" via "${GW}" dev "${INT}"
done
fi
fi
# check if ufw is disabled (re-enable it)
if [[ "${ENABLE_UFW,,}" == "true" ]]; then
ufw status | grep -qw active
@@ -79,8 +90,14 @@ if [[ "${ENABLE_UFW,,}" == "true" ]]; then
fi
fi
if [[ "true" = "$LOG_TO_STDOUT" ]]; then
LOGFILE=/dev/stdout
else
LOGFILE=/config/deluged.log
fi
log "Starting Deluge"
exec su --preserve-environment abc -s /bin/bash -c "/usr/bin/deluged -d -c /config -L info -l /config/deluged.log" &
exec su --preserve-environment ${RUN_AS} -s /bin/bash -c "/usr/bin/deluged -d -c /config -L info -l $LOGFILE" &
# wait for deluge daemon process to start (listen for port)
while [[ $(netstat -lnt | awk '$6 == "LISTEN" && $4 ~ ".58846"') == "" ]]; do
@@ -88,7 +105,7 @@ while [[ $(netstat -lnt | awk '$6 == "LISTEN" && $4 ~ ".58846"') == "" ]]; do
done
log "Starting Deluge webui..."
exec su --preserve-environment abc -s /bin/bash -c "/usr/bin/deluge-web -c /config -L info -l /config/web.log" &
exec su --preserve-environment ${RUN_AS} -s /bin/bash -c "/usr/bin/deluge-web -c /config -L info -l $LOGFILE" &
# Configure port forwarding if applicable
if [[ -x /etc/openvpn/${OPENVPN_PROVIDER,,}/update-port.sh && -z $DISABLE_PORT_UPDATER ]]; then
@@ -104,4 +121,4 @@ if [[ -x /config/deluge-post-start.sh ]]; then
log "/config/deluge-post-start.sh returned $?"
fi
log "Deluge startup script complete."
log "Deluge startup script complete."