Advertisement
Guest User

Untitled

a guest
Jun 13th, 2018
2,107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. #!/bin/bash
  2. # Colors
  3. red="\033[1;31m" green="\033[1;32m" yellow="\033[1;33m" white="\033[1;37m" normal="\033[0m"
  4. # permissions
  5. if [ $USER != root ]; then echo -e $red"ERROR:$normal You need root privileges to continue... (sudo)" ; exit 0; fi
  6. # Variables
  7. TEMP=/tmp/temp.$$
  8. trap 'rm -f $TEMP; exit 0' 0 1 2 3 15
  9. tcp_files="https://www.hidemyass.com/vpn-config/TCP/"
  10. udp_files="https://www.hidemyass.com/vpn-config/UDP/"
  11.  
  12. # Checking for required packages
  13. curl=`which sed`
  14. if [ "$curl" == "" ]; then echo -e $green"Installing sed..." && apt-get -y --force-yes install sed > nul
  15. fi
  16. curl=`which openvpn`
  17. if [ "$curl" == "" ]; then echo -e $green"Installing openvpn..." && apt-get -y --force-yes install openvpn > nul
  18. fi
  19. curl=`which wget`
  20. if [ "$curl" == "" ]; then echo -e $green"Installing wget..." && apt-get -y --force-yes install wget > nul
  21. fi
  22. curl=`which curl`
  23. if [ "$curl" == "" ]; then echo -e $green"Installing curl..." && apt-get -y --force-yes install curl > nul
  24. fi
  25.  
  26. # functions
  27. function title () {
  28. echo -e $green"====$yellow HMA-GRABBER$green ===="$normal; }
  29. function show.progress () { i=0
  30. while [ -r $TEMP ]; do clear; title
  31. echo -e $yellow"Downloading $white$servers$yellow files:$white elapsed time $i seconds"$normal
  32. let i=i+1; sleep 1; done; }
  33. function start () { clear; title
  34. echo -e $yellow"This script will download/update your HideMyAss OpenVPN configuration files."$normal
  35. echo -e $white"Are you sure you wish to continue?$red (y/n)"$normal
  36. stty -echo; read -n 1 RESP; stty echo; echo
  37. case "$RESP" in
  38. y|Y) clear; title
  39. read -p "Your HMA! username: " username; stty -echo
  40. read -p "Your HMA! password: " password; stty echo; echo
  41. echo -e $green"Checking servers and files:"
  42. tcp_servers=$(curl -s --compressed "$tcp_files" | grep -o '.ovpn"' | wc -l)
  43. udp_servers=$(curl -s --compressed "$udp_files" | grep -o '.ovpn"' | wc -l)
  44. servers=$[tcp_servers+udp_servers+crt_files+key_files]
  45. echo -e $yellow"TCP:$white $tcp_servers"; sleep 1
  46. echo -e $yellow"UDP:$white $udp_servers"; sleep 1
  47. touch $TEMP
  48. show.progress &
  49. rm rf /etc/openvpn/*.* > /dev/null 2>&1
  50. echo -e "$username\n$password" > /etc/openvpn/hmauser.pass
  51. wget --quiet -t 3 -T 20 -r -A.ovpn -nd --no-parent -e robots=off $tcp_files $udp_files -P /etc/openvpn/
  52. rm -f $TEMP
  53. echo -e $green"done!$white You can find the files in$yellow /etc/openvpn/"$normal; sleep 1
  54. echo -e $white"Credentials stored in$yellow /etc/openvpn/hmauser.pass"$normal; sleep 1
  55. echo -e $white"Applying settings..."$normal
  56. sed -i 's|auth-user-pass|auth-user-pass /etc/openvpn/hmauser.pass|g' /etc/openvpn/*; sleep 5
  57. sed -i '/show-net-up/d' /etc/openvpn/*; sleep 1
  58. sed -i '/dhcp-renew/d' /etc/openvpn/*; sleep 1
  59. sed -i '/dhcp-release/d' /etc/openvpn/*; sleep 1
  60. echo -e $green"All done!"$normal ;;
  61. n|N) echo -e $green"Good bye!"$normal ;;
  62. *) echo -e $red"ERROR:$normal $RESP is not an option."; sleep 2 ; start ;;
  63. esac; }
  64. # run script
  65. start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement