unixbench.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #! /bin/bash
  2. #==============================================================#
  3. # Description: Unixbench script #
  4. # Author: Teddysun <[email protected]> #
  5. # Intro: https://teddysun.com/245.html #
  6. #==============================================================#
  7. cur_dir=/opt/unixbench
  8. # Check System
  9. [[ $EUID -ne 0 ]] && echo 'Error: This script must be run as root!' && exit 1
  10. [[ -f /etc/redhat-release ]] && os='centos'
  11. [[ ! -z "`egrep -i debian /etc/issue`" ]] && os='debian'
  12. [[ ! -z "`egrep -i ubuntu /etc/issue`" ]] && os='ubuntu'
  13. [[ "$os" == '' ]] && echo 'Error: Your system is not supported to run it!' && exit 1
  14. # Install necessary libaries
  15. if [ "$os" == 'centos' ]; then
  16. yum -y install make automake gcc autoconf gcc-c++ time perl-Time-HiRes
  17. else
  18. apt-get -y update
  19. apt-get -y install make automake gcc autoconf time perl
  20. fi
  21. # Create new soft download dir
  22. mkdir -p ${cur_dir}
  23. cd ${cur_dir}
  24. # Download UnixBench5.1.3
  25. if [ -s UnixBench5.1.3.tgz ]; then
  26. echo "UnixBench5.1.3.tgz [found]"
  27. else
  28. echo "UnixBench5.1.3.tgz not found!!!download now..."
  29. if ! wget -c https://dl.lamp.sh/files/UnixBench5.1.3.tgz; then
  30. echo "Failed to download UnixBench5.1.3.tgz, please download it to ${cur_dir} directory manually and try again."
  31. exit 1
  32. fi
  33. fi
  34. tar -zxvf UnixBench5.1.3.tgz && rm -f UnixBench5.1.3.tgz
  35. cd UnixBench/
  36. #Run unixbench
  37. make
  38. ./Run
  39. echo
  40. echo
  41. echo "======= Script description and score comparison completed! ======= "
  42. echo
  43. echo