limiter 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/bash
  2. #====================================================
  3. # SCRIPT: LIMITER SSHPLUS MANAGER
  4. # DESENVOLVIDO POR: CRAZY_VPN
  5. # CONTATO TELEGRAM: http://t.me/crazy_vpn
  6. # CANAL TELEGRAM: http://t.me/sshplus
  7. #====================================================
  8. clear
  9. database="/root/usuarios.db"
  10. fun_multilogin() {
  11. (
  12. while read user; do
  13. [[ $(grep -wc "$user" $database) != '0' ]] && limit="$(grep -w $user $database | cut -d' ' -f2)" || limit='1'
  14. conssh="$(ps -u $user | grep sshd | wc -l)"
  15. [[ "$conssh" -gt "$limit" ]] && {
  16. pkill -u $user
  17. }
  18. [[ -e /etc/openvpn/openvpn-status.log ]] && {
  19. ovp="$(grep -E ,"$user", /etc/openvpn/openvpn-status.log | wc -l)"
  20. [[ "$ovp" -gt "$limit" ]] && {
  21. pidokill=$(($limit - $ovp))
  22. listpid=$(grep -E ,"$user", /etc/openvpn/openvpn-status.log | cut -d "," -f3 | head -n $pidokill)
  23. while read ovpids; do
  24. (
  25. telnet localhost 7505 <<-EOF
  26. kill $ovpids
  27. EOF
  28. ) &>/dev/null &
  29. done <<<"$listpid"
  30. }
  31. }
  32. done <<<"$(awk -F: '$3 >= 1000 {print $1}' /etc/passwd)"
  33. ) &
  34. }
  35. while true; do
  36. echo 'verificando...'
  37. fun_multilogin > /dev/null 2>&1
  38. sleep 15s
  39. done