Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Color scheme
  4.  
  5. RED='\033[0;31m'
  6. NC='\033[0m'
  7. GREEN='\033[1;32m'
  8. BLUE='\033[0;34m'
  9. CYAN='\033[0;36m'
  10. LBLUE='\033[1;34m'
  11. LLBLUE='\033[1:225m'
  12. ORANGE=$(tput setaf 172)
  13. YELLOW=$(tput setaf 11)
  14.  
  15.  
  16. function msg_box() {
  17. local term_width=50
  18. local str=("$@") msg_width
  19. printf '\n'
  20.  
  21. for line in "${str[@]}"; do
  22. ((msg_width<${#line})) && { msg_width="${#line}"; }
  23.  
  24. if [ $msg_width -gt $term_width ]; then
  25. error_quit "\$msg_width exceeds \$term_width.\n"
  26. fi
  27.  
  28. x=$(($term_width - $msg_width))
  29. pad=$(($x / 2))
  30. done
  31.  
  32. printf '%s┌' "${ORANGE}" && printf '%.0s─' {0..49} && printf '┐\n' && printf '│%49s │\n'
  33.  
  34. for line in "${str[@]}"; do
  35. rpad=$((50 - $pad - $msg_width))
  36. printf "│%$pad.${pad}s" && printf '%s%*s' "$YELLOW" "-$msg_width" "$line" "${ORANGE}" && printf "%$rpad.${rpad}s│\n"
  37. done
  38.  
  39. printf '│%49s │\n' && printf '└' && printf '%.0s─' {0..49} && printf '┘\n%s' ${RESET}
  40. }
  41.  
  42. function menu() {
  43. msg_box "1.System Info 2.Disk List" "3.Disk Name 4.Proc Info" "5.Raid Info 6.MB Info" "7.Bios Info 8.Memory Info" "9.Net Info 10.Graph Info" "11.Sound Info 12.Disk Ident" "0.Exit"
  44. }
  45.  
  46.  
  47. function input {
  48. printf "${LBLUE}$ Provide one option (number): ${NC}"
  49. read -r d
  50. echo -e "\n"
  51. }
  52.  
  53. function selectors {
  54. case "$d" in
  55. "0") clear && exit ;;
  56. "1") echo "Hostname: $HOSTNAME"; uptime ;;
  57. "2") df -h ;;
  58. "3") printf "${YELLOW}Enter SCSI Hard Disks (e.g /dev/sda): ${NC}"
  59. read -r a
  60. echo -e "\n"
  61. sudo hdparm -i $a | grep -i model ;;
  62. "4") cat /proc/cpuinfo ;;
  63. "5") lspci | grep -i raid ;;
  64. "6") sudo dmidecode -t baseboard ;;
  65. "7") sudo dmidecode -t bios ;;
  66. "8") sudo dmidecode -t memory ;;
  67. "9") sudo lspci | grep -i eth ;;
  68. "10") sudo lspci | grep -i vga ;;
  69. "11") lspci | grep -i audio ;;
  70. "12") c=`cat /sys/block/sda/queue/rotational`
  71. if [[ $c == 1 ]]; then
  72. printf "${YELLOW}Your disk is HDD"
  73. else
  74. printf "${YELLOW}Your disk is SSD"
  75. fi ;;
  76. *) printf "${RED}No option (number) provided${NC}" ;
  77. esac
  78. }
  79.  
  80.  
  81. function print_prompt() {
  82. declare wantreturn=${3} str end default
  83. if [ -n "$wantreturn" ]; then
  84. str="$(printf "${CYAN}To return to press [Enter]${NC}")"
  85. else
  86. str="$(printf "${CYAN}To return to Press any key${NC}")"
  87. fi
  88. end="${2:-$str}"
  89. [ -z "$end" ] && end="$str"
  90. default="${1} ${str}"
  91. printf "$default"
  92. if [ -n "$wantreturn" ]; then
  93. read
  94. else
  95. read -n1 -s
  96. fi
  97. }
  98.  
  99. while true; do
  100. clear
  101. menu
  102. input
  103. selectors
  104. echo -e "\n"
  105. print_prompt
  106. clear
  107. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement