port-squid.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. red='\e[1;31m'
  3. green='\e[0;32m'
  4. NC='\e[0m'
  5. MYIP=$(wget -qO- 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