Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed WEBUI_PORT to WEBUI_PORT_ENV #9

Open
wants to merge 2 commits into
base: bionic
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions qbittorrent/iptables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ while : ; do
fi
done

echo "[info] WebUI port defined as ${WEBUI_PORT}" | ts '%Y-%m-%d %H:%M:%.S'
echo "[info] WebUI port defined as ${WEBUI_PORT_ENV}" | ts '%Y-%m-%d %H:%M:%.S'

# strip whitespace from start and end of LAN_NETWORK
export LAN_NETWORK=$(echo "${LAN_NETWORK}" | sed -e 's~^[ \t]*~~;s~[ \t]*$~~')
Expand Down Expand Up @@ -47,10 +47,10 @@ if [[ $iptable_mangle_exit_code == 0 ]]; then
echo "[info] iptable_mangle support detected, adding fwmark for tables" | ts '%Y-%m-%d %H:%M:%.S'

# setup route for qbittorrent webui using set-mark to route traffic for port 8080 to eth0
if [ -z "${WEBUI_PORT}" ]; then
if [ -z "${WEBUI_PORT_ENV}" ]; then
echo "8080 webui" >> /etc/iproute2/rt_tables
else
echo "${WEBUI_PORT} webui" >> /etc/iproute2/rt_tables
echo "${WEBUI_PORT_ENV} webui" >> /etc/iproute2/rt_tables
fi

ip rule add fwmark 1 table webui
Expand Down Expand Up @@ -99,12 +99,12 @@ iptables -A INPUT -s "${docker_network_cidr}" -d "${docker_network_cidr}" -j ACC
iptables -A INPUT -i eth0 -p $VPN_PROTOCOL --sport $VPN_PORT -j ACCEPT

# accept input to qbittorrent webui port
if [ -z "${WEBUI_PORT}" ]; then
if [ -z "${WEBUI_PORT_ENV}" ]; then
iptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --sport 8080 -j ACCEPT
else
iptables -A INPUT -i eth0 -p tcp --dport ${WEBUI_PORT} -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --sport ${WEBUI_PORT} -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport ${WEBUI_PORT_ENV} -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --sport ${WEBUI_PORT_ENV} -j ACCEPT
fi

# accept input to qbittorrent daemon port - used for lan access
Expand Down Expand Up @@ -144,23 +144,23 @@ iptables -A OUTPUT -o eth0 -p $VPN_PROTOCOL --dport $VPN_PORT -j ACCEPT
if [[ $iptable_mangle_exit_code == 0 ]]; then

# accept output from qBittorrent webui port - used for external access
if [ -z "${WEBUI_PORT}" ]; then
if [ -z "${WEBUI_PORT_ENV}" ]; then
iptables -t mangle -A OUTPUT -p tcp --dport 8080 -j MARK --set-mark 1
iptables -t mangle -A OUTPUT -p tcp --sport 8080 -j MARK --set-mark 1
else
iptables -t mangle -A OUTPUT -p tcp --dport ${WEBUI_PORT} -j MARK --set-mark 1
iptables -t mangle -A OUTPUT -p tcp --sport ${WEBUI_PORT} -j MARK --set-mark 1
iptables -t mangle -A OUTPUT -p tcp --dport ${WEBUI_PORT_ENV} -j MARK --set-mark 1
iptables -t mangle -A OUTPUT -p tcp --sport ${WEBUI_PORT_ENV} -j MARK --set-mark 1
fi

fi

# accept output from qBittorrent webui port - used for lan access
if [ -z "${WEBUI_PORT}" ]; then
if [ -z "${WEBUI_PORT_ENV}" ]; then
iptables -A OUTPUT -o eth0 -p tcp --dport 8080 -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 8080 -j ACCEPT
else
iptables -A OUTPUT -o eth0 -p tcp --dport ${WEBUI_PORT} -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport ${WEBUI_PORT} -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --dport ${WEBUI_PORT_ENV} -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport ${WEBUI_PORT_ENV} -j ACCEPT
fi

# accept output to qBittorrent daemon port - used for lan access
Expand Down
8 changes: 4 additions & 4 deletions qbittorrent/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ fi


# Set qBittorrent WebUI and Incoming ports
if [ ! -z "${WEBUI_PORT}" ]; then
webui_port_exist=$(cat /config/qBittorrent/config/qBittorrent.conf | grep -m 1 'WebUI\\Port='${WEBUI_PORT})
if [ ! -z "${WEBUI_PORT_ENV}" ]; then
webui_port_exist=$(cat /config/qBittorrent/config/qBittorrent.conf | grep -m 1 'WebUI\\Port='${WEBUI_PORT_ENV})
if [[ -z "${webui_port_exist}" ]]; then
webui_exist=$(cat /config/qBittorrent/config/qBittorrent.conf | grep -m 1 'WebUI\\Port')
if [[ ! -z "${webui_exist}" ]]; then
# Get line number of WebUI Port
LINE_NUM=$(grep -Fn -m 1 'WebUI\Port' /config/qBittorrent/config/qBittorrent.conf | cut -d: -f 1)
sed -i "${LINE_NUM}s@.*@WebUI\\Port=${WEBUI_PORT}@" /config/qBittorrent/config/qBittorrent.conf
sed -i "${LINE_NUM}s@.*@WebUI\\Port=${WEBUI_PORT_ENV}@" /config/qBittorrent/config/qBittorrent.conf
else
echo "WebUI\Port=${WEBUI_PORT}" >> /config/qBittorrent/config/qBittorrent.conf
echo "WebUI\Port=${WEBUI_PORT_ENV}" >> /config/qBittorrent/config/qBittorrent.conf
fi
fi
fi
Expand Down