#!/bin/bash # 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 [ "$wait" == "end" ] && echo "Giving up!" && exit 1 echo "No config yet..." sleep $wait done . /opt/openslx/config || echo "Error sourcing config for setup_proxy" [ -z "$SLX_PROXY_MODE" -o "x$SLX_PROXY_MODE" == "xoff" ] && echo "proxy mode disabled." && exit 0 PROXY=off if [ "$SLX_PROXY_MODE" == "on" ]; then PROXY=on elif [ "$SLX_PROXY_MODE" == "auto" -a -n "$SLX_PXE_CLIENT_IP" ]; then [[ "$SLX_PXE_CLIENT_IP" =~ ^10\. ]] && PROXY=on [[ "$SLX_PXE_CLIENT_IP" =~ ^192\.168\. ]] && PROXY=on [[ "$SLX_PXE_CLIENT_IP" =~ ^172\.[123][0-9]\. ]] && PROXY=on fi [ "$PROXY" == "off" ] && echo "Proxy mode not required." && exit 0 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 chown redsocks:redsocks /run/redsocks systemctl start redsocks cat > "/opt/openslx/iptables/rules.d/10-redoscks-proxy" <