speed.sh 1007 B

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. #19/12/2019
  3. [[ $(dpkg --get-selections|grep -w "python"|head -1) ]] || apt-get install python -y &>/dev/null
  4. declare -A cor=( [0]="\033[1;37m" [1]="\033[1;34m" [2]="\033[1;31m" [3]="\033[1;33m" [4]="\033[1;32m" )
  5. SCPfrm="/etc/ger-frm" && [[ ! -d ${SCPfrm} ]] && exit
  6. SCPinst="/etc/ger-inst" && [[ ! -d ${SCPinst} ]] && exit
  7. echo -e "${cor[4]} $(fun_trans "Speed Test") [VPS-MX By @Kalix1]"
  8. msg -bar
  9. ping=$(ping -c1 google.com |awk '{print $8 $9}' |grep -v loss |cut -d = -f2 |sed ':a;N;s/\n//g;ta')
  10. # PROGRESS - BAR
  11. (
  12. echo -ne "[" >&2
  13. while [[ ! -e /tmp/pyend ]]; do
  14. echo -ne "." >&2
  15. sleep 0.8s
  16. done
  17. rm /tmp/pyend
  18. echo -e "]" >&2
  19. ) &
  20. starts_test=$(python ${SCPfrm}/speedtest.py) && touch /tmp/pyend
  21. sleep 0.6s
  22. down_load=$(echo "$starts_test" | grep "Download" | awk '{print $2,$3}')
  23. up_load=$(echo "$starts_test" | grep "Upload" | awk '{print $2,$3}')
  24. msg -ama " $(fun_trans "Latencia"): $ping"
  25. msg -ama " $(fun_trans "Subida"): $up_load"
  26. msg -ama " $(fun_trans "Descarga"): $down_load"
  27. msg -bar