improved bashrc-proxyscript

This commit is contained in:
tke
2019-11-19 14:59:08 +01:00
parent 85f714d408
commit 414de286cd

View File

@@ -1,4 +1,5 @@
#!/bin/bash
marker="#PROXY_A93JK2"
path=$(dirname $(readlink -f "${0}"))
. "${path}/get_proxy.sh"
@@ -15,11 +16,12 @@ encpassword=$(echo -n ${password} | xxd -p | sed -e 's/\(..\)/%\1/g' )
if ! grep -qF -e "PROXY_A93JK2" "${bashrc_file}" ; then
echo "[ -f ${proxy_file} ] && . ${proxy_file} #PROXY_A93JK2" >> "${bashrc_file}"
echo "[ -f ${noproxy_file} ] && . ${noproxy_file} #PROXY_A93JK2" >> "${bashrc_file}"
fi
echo 'export "HTTP_PROXY=http://'"${username}"':"'"${encpassword}@${proxy_ip}:${proxy_port}/" > "${proxy_file}"
echo 'export "HTTPS_PROXY=http://'"${username}"':"'"${encpassword}@${proxy_ip}:${proxy_port}/" >> "${proxy_file}"
echo 'export "http_proxy=http://'"${username}"':"'"${encpassword}@${proxy_ip}:${proxy_port}/" >> "${proxy_file}"
echo 'export "https_proxy=http://'"${username}"':"'"${encpassword}@${proxy_ip}:${proxy_port}/" >> "${proxy_file}"
echo "[ -f ${noproxy_file} ] && . ${noproxy_file}" >> "${proxy_file}"
[ -f "${noproxy_file}" ] || echo 'export "NO_PROXY=localhost,127.0.0.1"' > "${noproxy_file}"