summaryrefslogtreecommitdiffstats
path: root/core/modules/redsocks
diff options
context:
space:
mode:
authorSimon Rettberg2018-10-02 15:03:40 +0200
committerSimon Rettberg2018-10-02 15:03:40 +0200
commitd0477d48b6619b35b0848fd6cff1679303e54899 (patch)
treedd88c5c7c6d764907d907e5138bf0539c48681eb /core/modules/redsocks
parent[alsa] Try to determine which HDMI port to output sound to (diff)
downloadmltk-d0477d48b6619b35b0848fd6cff1679303e54899.tar.gz
mltk-d0477d48b6619b35b0848fd6cff1679303e54899.tar.xz
mltk-d0477d48b6619b35b0848fd6cff1679303e54899.zip
[redsocks] Set environment variables in addition
Diffstat (limited to 'core/modules/redsocks')
-rwxr-xr-xcore/modules/redsocks/data/opt/openslx/scripts/systemd-setup_proxy15
1 files changed, 11 insertions, 4 deletions
diff --git a/core/modules/redsocks/data/opt/openslx/scripts/systemd-setup_proxy b/core/modules/redsocks/data/opt/openslx/scripts/systemd-setup_proxy
index 97ef8225..37d72392 100755
--- a/core/modules/redsocks/data/opt/openslx/scripts/systemd-setup_proxy
+++ b/core/modules/redsocks/data/opt/openslx/scripts/systemd-setup_proxy
@@ -2,7 +2,7 @@
# Needs full bash
for wait in 1 1 2 3 4 6 8 10 end; do
- grep '^#_RCONFIG_TAG$' /opt/openslx/config > /dev/null && echo "Config found!" && break
+ grep -q '^#_RCONFIG_TAG$' /opt/openslx/config && break
[ "$wait" == "end" ] && echo "Giving up!" && exit 1
echo "No config yet..."
sleep $wait
@@ -17,10 +17,10 @@ if [ "$SLX_PROXY_MODE" == "on" ]; then
PROXY=on
elif [ "$SLX_PROXY_MODE" == "auto" -a -n "$SLX_PXE_CLIENT_IP" ]; then
# auto detection: check if it is actually needed
- RET=$(curl -m 2 -s http://www.google.de/ | grep -o google | wc -l)
+ RET=$(curl -L -m 2 -s http://www.google.de/ | grep -o google | wc -l)
if [ $RET -lt 20 ]; then
sleep 4
- RET=$(curl -m 5 -s http://www.google.de/ | grep -o google | wc -l)
+ RET=$(curl -L -m 5 -s http://www.google.de/ | grep -o google | wc -l)
fi
[ $RET -gt 20 ] && echo "Auto detect: Internet is reachable without proxy." && exit 0
PROXY=on
@@ -29,6 +29,14 @@ fi
[ "$PROXY" == "off" ] && echo "Proxy mode not required." && exit 0
echo "Setting up transparent proxying via $SLX_PROXY_IP"
+# Do this in addition so proxy-aware programs can use it directly
+mkdir -p /etc/profile.d
+if [ "${SLX_PROXY_TYPE#0:5}" = "http-" ]; then
+ echo "export http_proxy=http://${SLX_PROXY_IP}:${SLX_PROXY_PORT}/" > "/etc/profile.d/system-proxy.sh"
+elif [ "${SLX_PROXY_TYPE#0:5}" = "socks" ]; then
+ echo "export ALL_PROXY=${SLX_PROXY_TYPE}://${SLX_PROXY_IP}:${SLX_PROXY_PORT}/" > "/etc/profile.d/system-proxy.sh"
+fi
+
sed -i "s/%%PROXY_IP%%/$SLX_PROXY_IP/g;s/%%PROXY_PORT%%/$SLX_PROXY_PORT/g;s/%%PROXY_TYPE%%/$SLX_PROXY_TYPE/g" /etc/redsocks.conf
mkdir -p /run/redsocks
@@ -58,7 +66,6 @@ fi
iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-port 12345
iptables -t nat -A PREROUTING -i nat1 -p tcp -j REDSOCKS
iptables -t nat -A OUTPUT -o br0 -p tcp -j REDSOCKS
-#iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE
iptables -A INPUT -i br0 -p tcp --dport 12345 -j DROP
HEREDOCBROWN
chmod +x "/opt/openslx/iptables/rules.d/10-redoscks-proxy"