Skip to content

Commit

Permalink
Now disable ufw at tunnel down after deluge kill and re-enable it at …
Browse files Browse the repository at this point in the history
…tunnel up
  • Loading branch information
ebrianne committed Mar 17, 2021
1 parent 0376af5 commit fc974ff
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
10 changes: 9 additions & 1 deletion root/etc/deluge/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,15 @@ if [[ -n "${LOCAL_NETWORK-}" ]]; then
fi
fi

ufw status
# check if ufw is disabled (re-enable it)
if [[ "${ENABLE_UFW,,}" == "true" ]]; then
ufw status | grep -qw active
if [[ "$?" != "0" ]]; then
log "Re-enabling ufw"
ufw enable
ufw status
fi
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" &
Expand Down
4 changes: 3 additions & 1 deletion root/etc/deluge/stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ then
fi

log "Sending kill signal to deluge-daemon"
PID=$(pidof deluged)
PID=$(pidof /usr/bin/python3 /usr/bin/deluged)
kill -9 $PID
# Give deluge-daemon time to shut down
for i in {1..10}; do
Expand All @@ -29,3 +29,5 @@ then
/config/deluge-post-stop.sh "$@"
log "/config/deluge-post-stop.sh returned $?"
fi

exec /etc/ufw/disable.sh
2 changes: 1 addition & 1 deletion root/etc/openvpn/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ if [[ "true" = "${ENABLE_UFW}" ]]; then
/etc/ufw/enable.sh tun0 ${CHOSEN_OPENVPN_CONFIG}
fi

DELUGE_CONTROL_OPTS="--script-security 2 --up-delay --up /etc/openvpn/tunnelUp.sh --down /etc/openvpn/tunnelDown.sh"
DELUGE_CONTROL_OPTS="--script-security 2 --auth-nocache --up-delay --up /etc/openvpn/tunnelUp.sh --down /etc/openvpn/tunnelDown.sh"

# shellcheck disable=SC2086
log "Starting openvpn"
Expand Down
4 changes: 1 addition & 3 deletions root/etc/ufw/disable.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ TIMESTAMP_FORMAT='%a %b %d %T %Y'
log() {
echo "$(date +"${TIMESTAMP_FORMAT}") [ufw-disable] $*"
}
# Source our persisted env variables from container startup
. /etc/deluge/environment-variables.sh

ufw reset
log "Disabling ufw"
ufw disable
ufw status

0 comments on commit fc974ff

Please sign in to comment.