wondershaper.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/bash
  2. clear
  3. TEXT='\033[30;107;2m'
  4. INFO='\033[97;44m'
  5. WARNING='\033[97;43m'
  6. ERROR='\033[97;41m'
  7. SUCCESS='\033[97;42m'
  8. GREEN='\033[92m'
  9. YELLOW='\033[93m'
  10. RESET='\033[0m'
  11. if [ "${EUID}" -ne 0 ]; then
  12. echo -e "${ERROR} ERROR ${RESET}${TEXT} You need to run this script as root! ${RESET}"; exit 1
  13. fi
  14. cek=$(cat /home/limit)
  15. NIC=$(ip -o $ANU -4 route show to default | awk '{print $5}');
  16. function start {
  17. echo -e "Limit Speed All Service"
  18. read -p "Set maximum download rate (in Kbps): " down
  19. read -p "Set maximum upload rate (in Kbps): " up
  20. if [[ -z "$down" ]] && [[ -z "$up" ]]; then
  21. echo > /dev/null 2>&1
  22. else
  23. wondershaper -a $NIC -d $down -u $up > /dev/null 2>&1
  24. systemctl enable --now wondershaper.service
  25. echo "start" > /home/limit
  26. echo "Done"
  27. fi
  28. }
  29. function stop {
  30. wondershaper -ca $NIC
  31. systemctl stop wondershaper.service
  32. echo "Stop Configuration"
  33. sleep 0.5
  34. echo > /home/limit
  35. echo "Done"
  36. }
  37. if [[ "$cek" = "start" ]]; then
  38. sts="[ON]"
  39. else
  40. sts="[OFF]"
  41. fi
  42. clear
  43. echo -e " =============================="
  44. echo -e " Limit Bandwidth Speed "
  45. echo -e " =============================="
  46. echo -e " Status $sts"
  47. echo -e " 1. Start Limit"
  48. echo -e " 2. Stop Limit"
  49. echo -e " Press CTRL+C to return"
  50. read -rp " Please Enter The Correct Number : " -e choose
  51. if [[ "$choose" = "1" ]]; then
  52. start
  53. elif [[ "$choose" = "2" ]]; then
  54. stop
  55. else
  56. clear; echo " You Entered The Wrong Number" && menu
  57. fi