diff options
author | Dieter Bloms <dieter@bloms.de> | 2012-02-24 09:37:49 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2012-02-24 09:52:35 +0000 |
commit | 69ff54f4f8e5a75fe21e987d8b95e0804d8d6fe6 (patch) | |
tree | 45a1e453497ff5df04fcc404614dc8a51be3a0dc /setup-proxy.in | |
parent | 3ed9c1d7846d62d6a83b5f9d9f93cbfe2c515ef7 (diff) | |
download | alpine-conf-69ff54f4f8e5a75fe21e987d8b95e0804d8d6fe6.zip |
setup-proxy: new tool for configuring proxy
Diffstat (limited to 'setup-proxy.in')
-rw-r--r-- | setup-proxy.in | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/setup-proxy.in b/setup-proxy.in new file mode 100644 index 0000000..6b0d978 --- /dev/null +++ b/setup-proxy.in @@ -0,0 +1,66 @@ +#!/bin/sh + +PREFIX= +. "$PREFIX/lib/libalpine.sh" + +PROFILE="$ROOT/etc/profile.d/proxy.sh" + +if [ -f "$PROFILE" ] ; then + proxyserver=`grep "^# proxyserver" $PROFILE | cut -f 2 -d '='` + proxyuser=`grep "^# proxyuser" $PROFILE | cut -f 2 -d '='` + proxypass=`grep "^# proxypass" $PROFILE | cut -f 2 -d '='` +fi + +echon "name of proxyserver ? (e.g proxy.domain.loc:8080) [$proxyserver] " +default_read proxyserver $proxyserver +echo $proxyserver | grep ":" >/dev/null +if [ "$?" = "1" ] ; then + echon "port of proxyserver ? [8080] " + default_read proxyport "8080" + proxyserver=$proxyserver:$proxyport +fi + +if [ "$proxyuser" = "" ] ; then + needauth="no" +else + needauth="yes" +fi +echon "do you need authentication ? [$needauth] " +default_read needauth $needauth + +if [ "$needauth" = "yes" ]; then + echon "username ? (e.g felix) leave empty if not required [$proxyuser] " + default_read proxyuser $proxyuser + + if [ -n "$proxyuser" ] ; then + echon "password for proxyserver ? [$proxypass] " + default_read proxypass $proxypass + else + proxypass="" + fi +else + proxyuser="" + proxypass="" +fi + +( + echo "# proxyserver=$proxyserver" + echo "# proxyuser=$proxyuser" + echo "# proxypass=$proxypass" +) > $PROFILE + +if [ "$proxyuser" = "" ] ; then + ( + echo "export http_proxy=http://$proxyserver/" + echo "export https_proxy=http://$proxyserver/" + echo "export ftp_proxy=http://$proxyserver/" + ) >> $PROFILE +else + ( + echo "export http_proxy=http://$proxyuser:$proxypass@$proxyserver/" + echo "export https_proxy=http://$proxyuser:$proxypass@$proxyserver/" + echo "export ftp_proxy=http://$proxyuser:$proxypass@$proxyserver/" + ) >> $PROFILE +fi + +echo -e "\nto make changes active please do login again or source $PROFILE with \". $PROFILE\"" |