Advertisement
Guest User

Untitled

a guest
Jan 4th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. function proxy_on() {
  2. export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
  3.  
  4. if (( $# > 0 )); then
  5. valid=$(echo $@ | sed -n 's/\([0-9]\{1,3\}.\)\{4\}:\([0-9]\+\)/&/p')
  6. if [[ $valid != $@ ]]; then
  7. >&2 echo "Invalid address"
  8. return 1
  9. fi
  10.  
  11. export http_proxy="http://$1/" \
  12. https_proxy=$http_proxy \
  13. ftp_proxy=$http_proxy \
  14. rsync_proxy=$http_proxy
  15. echo "Proxy environment variable set."
  16. return 0
  17. fi
  18.  
  19. echo -n "username: "; read username
  20. if [[ $username != "" ]]; then
  21. echo -n "password: "
  22. read -es password
  23. local pre="$username:$password@"
  24. fi
  25.  
  26. echo -n "server: "; read server
  27. echo -n "port: "; read port
  28. export http_proxy="http://$pre$server:$port/" \
  29. https_proxy=$http_proxy \
  30. ftp_proxy=$http_proxy \
  31. rsync_proxy=$http_proxy \
  32. HTTP_PROXY=$http_proxy \
  33. HTTPS_PROXY=$http_proxy \
  34. FTP_PROXY=$http_proxy \
  35. RSYNC_PROXY=$http_proxy
  36. }
  37.  
  38. function proxy_off(){
  39. unset http_proxy https_proxy ftp_proxy rsync_proxy \
  40. HTTP_PROXY HTTPS_PROXY FTP_PROXY RSYNC_PROXY
  41. echo -e "Proxy environment variable removed."
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement