Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0010e5b

Browse files
authored
Merge pull request ruanyf#14 from amaurybsouza/master
New script for hardware information for Linux systems
2 parents 667d554 + 1514a3b commit 0010e5b

File tree

2 files changed

+174
-0
lines changed

2 files changed

+174
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ A collection of simple Bash scripts.
3737
1. [Disk-Space.sh](scripts/disk-space.sh): check if the disk space crosses the limit
3838
1. [CollectNetworkInfo.sh](scripts/collectnetworkinfo.sh): gather information related to server
3939
1. [RemoteBackup.sh](scripts/remotebackup.sh): backup a local file into a remote server
40+
1. [HardwareInfo.sh](scripts/hardware_machine.sh): show hardware information for systems Linux
4041

4142
## Math
4243

scripts/hardware_machine.sh

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
#!/usr/bin/env bash
2+
# ------------------------------------------------------------------------ #
3+
# Script Name: hardware_machine.sh
4+
# Description: Show informations about machine hardware.
5+
# Written by: Amaury Souza
6+
# Maintenance: Amaury Souza
7+
# ------------------------------------------------------------------------ #
8+
# Usage:
9+
# $ ./hardware_machine.sh
10+
# ------------------------------------------------------------------------ #
11+
# Bash Version:
12+
# Bash 4.4.19
13+
# ------------------------------------------------------------------------ #
14+
15+
function menuprincipal () {
16+
clear
17+
TIME=1
18+
echo " "
19+
echo $0
20+
echo " "
21+
echo "Choose an option below!
22+
23+
1 - Verify desktop processor
24+
2 - Verify system kernel
25+
3 - Verify installed softwares
26+
4 - Operation system version
27+
5 - Verify desktop memory
28+
6 - Verify serial number
29+
7 - Verify system IP
30+
0 - Exit"
31+
echo " "
32+
echo -n "Chosen option: "
33+
read opcao
34+
case $opcao in
35+
1)
36+
function processador () {
37+
CPU_INFO=`cat /proc/cpuinfo | grep -i "^model name" | cut -d ":" -f2 | sed -n '1p'`
38+
echo "CPU model: $CPU_INFO"
39+
sleep $TIME
40+
}
41+
processador
42+
read -n 1 -p "<Enter> for main menu"
43+
menuprincipal
44+
;;
45+
46+
2)
47+
function kernel () {
48+
#RED HAT: cat /etc/redhat-release
49+
KERNEL_VERSION_UBUNTU=`uname -r`
50+
KERNEL_VERSION_CENTOS=`uname -r`
51+
if [ -f /etc/lsb-release ]
52+
then
53+
echo "kernel version: $KERNEL_VERSION_UBUNTU"
54+
else
55+
echo "kernel version: $KERNEL_VERSION_CENTOS"
56+
fi
57+
}
58+
kernel
59+
read -n 1 -p "<Enter> for main menu"
60+
menuprincipal
61+
;;
62+
63+
3)
64+
function softwares () {
65+
#while true; do
66+
TIME=3
67+
echo " "
68+
echo "Choose an option below for program's list!
69+
70+
1 - List Ubuntu programs
71+
2 - List Fedora programs
72+
3 - Install programs
73+
4 - Back to menu"
74+
echo " "
75+
echo -n "Chosen option: "
76+
read alternative
77+
case $alternative in
78+
1)
79+
echo "Listing all programs Ubuntu's systems..."
80+
sleep $TIME
81+
dpkg -l > /tmp/programs.txt
82+
echo Programs listed and available at /tmp
83+
sleep $TIME
84+
echo " "
85+
echo "Back to menu!" | tr [a-z] [A-Z]
86+
sleep $TIME
87+
;;
88+
2)
89+
echo "Listing all programs Fedora's systems..."
90+
sleep $TIME
91+
yum list installed > /tmp/programs.txt
92+
echo Programs listed and available at /tmp
93+
sleep $TIME
94+
;;
95+
3)
96+
echo Installing programss...
97+
LIST_OF_APPS="pinta brasero gimp vlc inkscape blender filezilla"
98+
#use aptitude command for programs loop.
99+
apt install aptitude -y
100+
aptitude install -y $LIST_OF_APPS
101+
;;
102+
4)
103+
echo Back to main menu...
104+
sleep $TIME
105+
;;
106+
esac
107+
#done
108+
}
109+
softwares
110+
menuprincipal
111+
;;
112+
113+
4)
114+
function sistema () {
115+
VERSION=`cat /etc/os-release | grep -i ^PRETTY`
116+
if [ -f /etc/os-release ]
117+
then
118+
echo "The system version: $VERSION"
119+
else
120+
echo "System not supported"
121+
fi
122+
}
123+
sistema
124+
read -n 1 -p "<Enter> for main menu"
125+
menuprincipal
126+
;;
127+
128+
129+
5)
130+
function memory () {
131+
MEMORY_FREE=`free -m | grep ^Mem | tr -s ' ' | cut -d ' ' -f 4`
132+
#MEMORY_TOTAL=
133+
#MEMORY_USED=
134+
echo Verifying system memory...
135+
echo "Memory free is: $MEMORY_FREE"
136+
}
137+
memory
138+
read -n 1 -p "<Enter> for main menu"
139+
menuprincipal
140+
;;
141+
142+
6)
143+
function serial () {
144+
SERIAL_NUMBER=`dmidecode -t 1 | grep -i serial`
145+
echo $SERIAL_NUMBER
146+
}
147+
serial
148+
read -n 1 -p "<Enter> for main menu"
149+
menuprincipal
150+
;;
151+
152+
7)
153+
function ip () {
154+
IP_SISTEMA=`hostname -I`
155+
echo IP is: $IP_SISTEMA
156+
}
157+
ip
158+
read -n 1 -p "<Enter> for main menu"
159+
menuprincipal
160+
;;
161+
162+
0)
163+
echo Exiting the system...
164+
sleep $TIME
165+
exit 0
166+
;;
167+
168+
*)
169+
echo Invalid option, try again!
170+
;;
171+
esac
172+
}
173+
menuprincipal

0 commit comments

Comments
 (0)