]> code.delx.au - osx-proxyconf/blobdiff - proxyconf.sh
Make the proxyconf script unset the environment variables if they are not needed
[osx-proxyconf] / proxyconf.sh
index 61b0f50f86004adf93cba29b98ce79f85e5db396..5c49ada1e56f8c7e63e17ef7aa5ff3900e0c67dd 100755 (executable)
@@ -1,17 +1,29 @@
 #!/bin/bash
 
-if [ "$(sysconfig -n "HTTPEnable")" -eq 1 ]; then
-       host="$(sysconfig -s "HTTPProxy")"
-       port="$(sysconfig -n "HTTPPort")"
+if [ "$(sysconfig -q "HTTPEnable")" = "1" ]; then
+       host="$(sysconfig -q "HTTPProxy")"
+       port="$(sysconfig -q "HTTPPort")"
        echo "export http_proxy=\"http://${host}:${port}\""
+else
+       echo "unset http_proxy"
 fi
-if [ "$(sysconfig -n "HTTPSEnable")" -eq 1 ]; then
-       host="$(sysconfig -s "HTTPSProxy")"
-       port="$(sysconfig -n "HTTPSPort")"
+if [ "$(sysconfig -q "HTTPSEnable")" = "1" ]; then
+       host="$(sysconfig -q "HTTPSProxy")"
+       port="$(sysconfig -q "HTTPSPort")"
        echo "export https_proxy=\"http://${host}:${port}\""
+else
+       echo "unset https_proxy"
 fi
-if [ "$(sysconfig -n "FTPEnable")" -eq 1 ]; then
-       host="$(sysconfig -s "FTPProxy")"
-       port="$(sysconfig -n "FTPPort")"
+if [ "$(sysconfig -q "FTPEnable")" = "1" ]; then
+       host="$(sysconfig -q "FTPProxy")"
+       port="$(sysconfig -q "FTPPort")"
        echo "export ftp_proxy=\"http://${host}:${port}\""
+else
+       echo "unset ftp_proxy"
+fi
+if [ -n "${host}" ]; then
+       no_proxy="$(sysconfig ExceptionsList | tr '\n' ',' | sed 's/,$//g')"
+       echo "export no_proxy=\"${no_proxy}\""
+else
+       echo "unset no_proxy"
 fi