port-squid.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/bash
  2. red='\e[1;31m'
  3. green='\e[0;32m'
  4. NC='\e[0m'
  5. MYIP=$(wget -qO- https://icanhazip.com);
  6. echo "Checking VPS"
  7. clear
  8. sqd="$(cat /etc/squid/squid.conf | grep -i http_port | awk '{print $2}' | head -n1)"
  9. sqd2="$(cat /etc/squid/squid.conf | grep -i http_port | awk '{print $2}' | tail -n1)"
  10. echo -e "======================================"
  11. echo -e ""
  12. echo -e " [1] Change Port $sqd"
  13. echo -e " [2] Change Port $sqd2"
  14. echo -e " [x] Exit"
  15. echo -e "======================================"
  16. echo -e ""
  17. read -p " Select From Options [1-2 or x] : " prot
  18. echo -e ""
  19. case $prot in
  20. 1)
  21. read -p "New Port Squid: " squid
  22. if [ -z $squid ]; then
  23. echo "Please Input Port"
  24. exit 0
  25. fi
  26. cek=$(netstat -nutlp | grep -w $squid)
  27. if [[ -z $cek ]]; then
  28. sed -i "s/$sqd/$squid/g" /etc/squid/squid.conf
  29. sed -i "s/$sqd/$squid/g" /root/log-install.txt
  30. /etc/init.d/squid restart > /dev/null
  31. echo -e "\e[032;1mPort $squid modified successfully\e[0m"
  32. else
  33. echo "Port $squid is used"
  34. fi
  35. ;;
  36. 2)
  37. read -p "New Port Squid: " squid
  38. if [ -z $squid ]; then
  39. echo "Please Input Port"
  40. exit 0
  41. fi
  42. cek=$(netstat -nutlp | grep -w $squid)
  43. if [[ -z $cek ]]; then
  44. sed -i "s/$sqd2/$squid/g" /etc/squid/squid.conf
  45. sed -i "s/$sqd2/$squid/g" /root/log-install.txt
  46. /etc/init.d/squid restart > /dev/null
  47. echo -e "\e[032;1mPort $squid modified successfully\e[0m"
  48. else
  49. echo "Port $squid is used"
  50. fi
  51. ;;
  52. x)
  53. exit
  54. menu
  55. ;;
  56. *)
  57. echo "Please enter an correct number"
  58. ;;
  59. esac