port-ssl.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. ssl="$(cat /etc/stunnel/stunnel.conf | grep -i accept | head -n 2 | cut -d= -f2 | sed 's/ //g' | tr '\n' ' ' | awk '{print $1}')"
  9. ssl2="$(cat /etc/stunnel/stunnel.conf | grep -i accept | head -n 2 | cut -d= -f2 | sed 's/ //g' | tr '\n' ' ' | awk '{print $2}')"
  10. echo -e "======================================"
  11. echo -e ""
  12. echo -e " [1] Change Port $ssl"
  13. echo -e " [2] Change Port $ssl2"
  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 Stunnel4: " stl
  22. if [ -z $stl ]; then
  23. echo "Please Input Port"
  24. exit 0
  25. fi
  26. cek=$(netstat -nutlp | grep -w $stl)
  27. if [[ -z $cek ]]; then
  28. sed -i "s/$ssl/$stl/g" /etc/stunnel/stunnel.conf
  29. sed -i "s/ - Stunnel4 : $ssl, $ssl2/ - Stunnel4 : $stl, $ssl2/g" /root/log-install.txt
  30. /etc/init.d/stunnel4 restart > /dev/null
  31. echo -e "\e[032;1mPort $stl modified successfully\e[0m"
  32. else
  33. echo "Port $stl is used"
  34. fi
  35. ;;
  36. 2)
  37. read -p "New Port Stunnel4: " stl
  38. if [ -z $stl ]; then
  39. echo "Please Input Port"
  40. exit 0
  41. fi
  42. cek=$(netstat -nutlp | grep -w $stl)
  43. if [[ -z $cek ]]; then
  44. sed -i "s/$ssl2/$stl/g" /etc/stunnel/stunnel.conf
  45. sed -i "s/ - Stunnel4 : $ssl, $ssl2/ - Stunnel4 : $ssl, $stl/g" /root/log-install.txt
  46. /etc/init.d/stunnel4 restart > /dev/null
  47. echo -e "\e[032;1mPort $stl modified successfully\e[0m"
  48. else
  49. echo "Port $stl is used"
  50. fi
  51. ;;
  52. x)
  53. exit
  54. menu
  55. ;;
  56. *)
  57. echo "Please enter an correct number"
  58. ;;
  59. esac