· 7 years ago · Sep 09, 2018, 02:24 PM
1#!/bin/bash
2####################################################################
3# Sathish Arthar (Sathisharthar {at} gmail.com) - Jan 2014
4####################################################################
5#simple menu driven shell script to to get information about your Linux server / desktop and Do some Users and File operations Quickly.
6
7
8# Define variables
9LSB=/usr/bin/lsb_release
10
11# Purpose: Display pause prompt
12# $1-> Message (optional)
13function pause(){
14local message="$@"
15[ -z $message ] && message="Press [Enter] key to continue..."
16read -p "$message" readEnterKey
17}
18
19# Purpose - Display a menu on screen
20function show_menu(){
21date
22echo "---------------------------"
23echo " Main Menu"
24echo "---------------------------"
25echo "1. Operating system info"
26echo "2. Hostname and dns info"
27echo "3. Network info"
28echo "4. Who is online"
29echo "5. Last logged in users"
30echo "6. Free and used memory info"
31echo "7. Get my ip address"
32echo "8. My Disk Usage"
33echo "9. Process Usage"
34echo "10. Users Operations"
35echo "11. File Operations"
36echo "12. Exit"
37}
38
39# Purpose - Display header message
40# $1 - message
41function write_header(){
42local h="$@"
43echo "---------------------------------------------------------------"
44echo " ${h}"
45echo "---------------------------------------------------------------"
46}
47
48# Purpose - Get info about your operating system
49function os_info(){
50write_header " System information "
51echo "Operating system : $(uname)"
52[ -x $LSB ] && $LSB -a || echo "$LSB command is not insalled (set \$LSB variable)"
53#pause "Press [Enter] key to continue..."
54pause
55}
56
57# Purpose - Get info about host such as dns, IP, and hostname
58function host_info(){
59local dnsips=$(sed -e '/^$/d' /etc/resolv.conf | awk '{if (tolower($1)=="nameserver") print $2}')
60write_header " Hostname and DNS information "
61echo "Hostname : $(hostname -s)"
62echo "DNS domain : $(hostname -d)"
63echo "Fully qualified domain name : $(hostname -f)"
64echo "Network address (IP) : $(hostname -i)"
65echo "DNS name servers (DNS IP) : ${dnsips}"
66pause
67}
68
69# Purpose - Network inferface and routing info
70function net_info(){
71devices=$(netstat -i | cut -d" " -f1 | egrep -v "^Kernel|Iface|lo")
72write_header " Network information "
73echo "Total network interfaces found : $(wc -w <<<${devices})"
74echo "*** IP Addresses Information ***"
75ip -4 address show
76echo "***********************"
77echo "*** Network routing ***"
78echo "***********************"
79netstat -nr
80echo "**************************************"
81echo "*** Interface traffic information ***"
82echo "**************************************"
83netstat -i
84pause
85}
86# Purpose - Display a list of users currently logged on
87# display a list of receltly loggged in users
88function user_info(){
89local cmd="$1"
90case "$cmd" in
91who) write_header " Who is online "; who -H; pause ;;
92last) write_header " List of last logged in users "; last ; pause ;;
93esac
94}
95# Purpose - Display used and free memory info
96function mem_info(){
97write_header " Free and used memory "
98free -m
99echo "*********************************"
100echo "*** Virtual memory statistics ***"
101echo "*********************************"
102vmstat
103echo "***********************************"
104echo "*** Top 5 memory eating process ***"
105echo "***********************************"
106ps auxf | sort -nr -k 4 | head -5
107pause
108}
109# Purpose - Get Public IP address form your ISP
110function ip_info(){
111cmd='curl -s'
112write_header " Public IP information "
113ipservice=checkip.dyndns.org
114pipecmd=(sed -e 's/.*Current IP Address: //' -e 's/<.*$//') #using brackets to use it as an array and avoid need of scaping
115$cmd "$ipservice" | "${pipecmd[@]}"
116pause
117}
118# purpose - Get Disk Usage Information
119function disk_info() {
120usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1)
121 partition=$(echo $output | awk '{print $2}')
122write_header " Disk Usage Info"
123if [ "$EXCLUDE_LIST" != "" ] ; then
124 df -H | grep -vE "^Filesystem|tmpfs|cdrom|${EXCLUDE_LIST}" | awk '{print $5 " " $6}'
125else
126 df -H | grep -vE "^Filesystem|tmpfs|cdrom" | awk '{print $5 " " $6}'
127fi
128pause
129}
130#Purpose of Process Usage Information
131function proc_info() {
132write_header " Process Usage Info"
133txtred=$(tput setaf 1)
134txtgrn=$(tput setaf 2)
135txtylw=$(tput setaf 3)
136txtblu=$(tput setaf 4)
137txtpur=$(tput setaf 5)
138txtcyn=$(tput setaf 6)
139txtrst=$(tput sgr0)
140COLUMNS=$(tput cols)
141center() {
142 w=$(( $COLUMNS / 2 - 20 ))
143 while IFS= read -r line
144 do
145 printf "%${w}s %s\n" ' ' "$line"
146 done
147}
148centerwide() {
149 w=$(( $COLUMNS / 2 - 30 ))
150 while IFS= read -r line
151 do
152 printf "%${w}s %s\n" ' ' "$line"
153 done
154}
155while :
156do
157clear
158echo ""
159echo ""
160echo "${txtcyn}(please enter the number of your selection below)${txtrst}" | centerwide
161echo ""
162echo "1. Show all processes" | center
163echo "2. Kill a process" | center
164echo "3. Bring up top" | center
165echo "4. ${txtpur}Return to Main Menu${txtrst}" | center
166echo "5. ${txtred}Shut down${txtrst}" | center
167echo ""
168read processmenuchoice
169case $processmenuchoice in
1701 )
171 clear && echo "" && echo "${txtcyn}(press ENTER or use arrow keys to scroll list, press Q to return to menu)${txtrst}" | centerwide && read
172 ps -ef | less
173;;
1742 )
175 clear && echo "" && echo "Please enter the PID of the process you would like to kill:" | centerwide
176 read pidtokill
177 kill -2 $pidtokill && echo "${txtgrn}Process terminated successfully.${txtrst}" | center || echo "${txtred}Process failed to terminate. Please check the PID and try again.${txtrst}" | centerwide
178 echo "" && echo "${txtcyn}(press ENTER to continue)${txtrst}" | center && read
179;;
1803 )
181 top
182;;
1834 )
184 clear && echo "" && echo "Are you sure you want to return to the main menu? ${txtcyn}y/n${txtrst}" | centerwide && echo ""
185 read exitays
186 case $exitays in
187 y | Y )
188 clear && exit
189 ;;
190 n | N )
191 clear && echo "" && echo "Okay. Nevermind then." | center && echo "" && echo "${txtcyn}(Press ENTER to continue.)${txtrst}" | center && read
192 ;;
193 * )
194 clear && echo "" && echo "${txtred}Please make a valid selection.${txtrst}" | center && echo "" && echo "${txtcyn}(Press ENTER to continue.)${txtrst}" | center && read
195 esac
196;;
1975 )
198 clear && echo "" && echo "Are you sure you want to shut down? ${txtcyn}y/n${txtrst}" | centerwide && echo ""
199 read shutdownays
200 case $shutdownays in
201 y | Y )
202 clear && shutdown -h now
203 ;;
204 n | N )
205 clear && echo "" && echo "Okay. Nevermind then." | center && echo "" && echo "${txtcyn}(Press ENTER to continue.)${txtrst}" | center && read
206 ;;
207 * )
208 clear && echo "" && echo "${txtred}Please make a valid selection." | center && echo "" && echo "${txtcyn}(Press ENTER to continue.)${txtrst}" | center && read
209 ;;
210 esac
211;;
212* )
213 clear && echo "" && echo "${txtred}Please make a valid selection." | center && echo "" && echo "${txtcyn}(Press ENTER to continue.)${txtrst}" | center && read
214;;
215esac
216done
217pause
218}
219#Purpose - For getting User operation and infrmations
220function user_infos() {
221write_header "User Operations"
222txtred=$(tput setaf 1)
223txtgrn=$(tput setaf 2)
224txtylw=$(tput setaf 3)
225txtblu=$(tput setaf 4)
226txtpur=$(tput setaf 5)
227txtcyn=$(tput setaf 6)
228txtrst=$(tput sgr0)
229COLUMNS=$(tput cols)
230center() {
231 w=$(( $COLUMNS / 2 - 20 ))
232 while IFS= read -r line
233 do
234 printf "%${w}s %s\n" ' ' "$line"
235 done
236}
237centerwide() {
238 w=$(( $COLUMNS / 2 - 30 ))
239 while IFS= read -r line
240 do
241 printf "%${w}s %s\n" ' ' "$line"
242 done
243}
244while :
245do
246clear
247echo ""
248echo ""
249echo "${txtcyn}(please enter the number of your selection below)${txtrst}" | centerwide
250echo ""
251echo "1. Create a user" | center
252echo "2. Change the group for a user" | center
253echo "3. Create a group" | center
254echo "4. Delete a user" | center
255echo "5. Change a password" | center
256echo "6. ${txtpur}Return to Main Menu${txtrst}" | center
257echo "7. ${txtred}Shut down${txtrst}" | center
258echo ""
259read usermenuchoice
260case $usermenuchoice in
2611 )
262 clear && echo "" && echo "Please enter the new username below: ${txtcyn}(NO SPACES OR SPECIAL CHARACTERS!)${txtrst}" | centerwide && echo ""
263 read newusername
264 echo "" && echo "Please enter a group for the new user: ${txtcyn}(STILL NO SPACES OR SPECIAL CHARACTERS!)${txtrst}" | centerwide && echo ""
265 read newusergroup
266 echo "" && echo "What is the new user's full name? ${txtcyn}(YOU CAN USE SPACES HERE IF YOU WANT!)${txtrst}" | centerwide && echo ""
267 read newuserfullname
268 echo "" && echo ""
269 groupadd $newusergroup
270 useradd -g $newusergroup -c "$newuserfullname" $newusername && echo "${txtgrn}New user $newusername created successfully.${txtrst}" | center || echo "${txtred}Could not create new user.${txtrst}" | center
271 echo "" && echo "${txtcyn}(press ENTER to continue)${txtrst}" | center
272 read
273;;
2742 )
275 clear && echo "" && echo "Which user needs to be in a different group? ${txtcyn}(USER MUST EXIST!)${txtrst}" | centerwide && echo ""
276 read usermoduser
277 echo "" && echo "What should be the new group for this user? ${txtcyn}(NO SPACES OR SPECIAL CHARACTERS!)${txtrst}" | centerwide && echo ""
278 read usermodgroup
279 echo "" && echo ""
280 groupadd $usermodgroup
281 usermod -g $usermodgroup $usermoduser && echo "${txtgrn}User $usermoduser added to group $usermodgroup successfully.${txtrst}" | center || echo "${txtred}Could not add user to group. Please check if user exists.${txtrst}" | centerwide
282 echo "" && echo "${txtcyn}(press ENTER to continue)${txtrst}" | center
283 read
284;;
2853 )
286 clear && echo "" && echo "Please enter a name for the new group below: ${txtcyn}(NO SPACES OR SPECIAL CHARACTERS!)${txtrst}" | centerwide && echo ""
287 read newgroup
288 echo "" && echo ""
289 groupadd $newgroup && echo "${txtgrn}Group $newgroup created successfully.${txtrst}" | center || echo "${txtred}Failed to create group. Please check if group already exists.${txtrst}" | centerwide
290 echo "" && echo "${txtcyn}(press ENTER to continue)${txtrst}" | center
291 read
292;;
2934 )
294 clear && echo "" && echo "Please enter the username to be deleted below: ${txtcyn}(THIS CANNOT BE UNDONE!)${txtrst}" | centerwide && echo ""
295 read deletethisuser
296 echo "" && echo "${txtred}ARE YOU ABSOLUTELY SURE YOU WANT TO DELETE THIS USER? SERIOUSLY, THIS CANNOT BE UNDONE! ${txtcyn}y/n${txtrst}" | centerwide
297 read deleteuserays
298 echo "" && echo ""
299 case $deleteuserays in
300 y | Y )
301 userdel $deletethisuser && echo "${txtgrn}User $deletethisuser deleted successfully." | center || echo "${txtred}Failed to delete user. Please check username and try again.${txtrst}" | centerwide
302 ;;
303 n | N )
304 echo "Okay. Nevermind then." | center
305 ;;
306 * )
307 echo "${txtred}Please make a valid selection.${txtrst}" | center
308 ;;
309 esac
310 echo "" && echo "${txtcyn}(press ENTER to continue)${txtrst}" | center
311 read
312;;
3135 )
314 clear && echo "" && echo "Which user's password should be changed?" | centerwide
315 read passuser
316 echo ""
317 passwd $passuser && echo "${txtgrn}Password for $passuser changed successfully.${txtrst}" | center || echo "${txtred}Failed to change password.${txtrst}" | center
318 echo "" && echo "${txtcyn}(press ENTER to continue)${txtrst}" | center
319 read
320;;
3216 )
322 clear && echo "" && echo "Are you sure you want to return to the main menu? ${txtcyn}y/n${txtrst}" | centerwide && echo ""
323 read exitays
324 case $exitays in
325 y | Y )
326 clear && exit
327 ;;
328 n | N )
329 clear && echo "" && echo "Okay. Nevermind then." | center && echo "" && echo "${txtcyn}(Press ENTER to continue.)${txtrst}" | center && read
330 ;;
331 * )
332 clear && echo "" && echo "${txtred}Please make a valid selection.${txtrst}" | center && echo "" && echo "${txtcyn}(Press ENTER to continue.)${txtrst}" | center && read
333 ;;
334 esac
335;;
3367 )
337 clear && echo "" && echo "Are you sure you want to shut down? ${txtcyn}y/n${txtrst}" | centerwide && echo ""
338 read shutdownays
339 case $shutdownays in
340 y | Y )
341 clear && shutdown -h now
342 ;;
343 n | N )
344 clear && echo "" && echo "Okay. Nevermind then." | center && echo "" && echo "${txtcyn}(Press ENTER to continue.)${txtrst}" | center && read
345 ;;
346 * )
347 clear && echo "" && echo "${txtred}Please make a valid selection.${txtrst}" | center && echo "" && echo "${txtcyn}(Press ENTER to continue.)${txtrst}" | center && read
348 ;;
349 esac
350;;
351* )
352 clear && echo "" && echo "${txtred}Please make a valid selection.${txtrst}" | center && echo "" && echo "${txtcyn}(Press ENTER to continue.)${txtrst}" | center && read
353;;
354esac
355done
356pause
357}
358#Purpose - For File Opertios
359function file_info() {
360write_header "File OPerations"
361txtred=$(tput setaf 1)
362txtgrn=$(tput setaf 2)
363txtylw=$(tput setaf 3)
364txtblu=$(tput setaf 4)
365txtpur=$(tput setaf 5)
366txtcyn=$(tput setaf 6)
367txtrst=$(tput sgr0)
368COLUMNS=$(tput cols)
369center() {
370 w=$(( $COLUMNS / 2 - 20 ))
371 while IFS= read -r line
372 do
373 printf "%${w}s %s\n" ' ' "$line"
374 done
375}
376centerwide() {
377 w=$(( $COLUMNS / 2 - 30 ))
378 while IFS= read -r line
379 do
380 printf "%${w}s %s\n" ' ' "$line"
381 done
382}
383while :
384do
385clear
386echo ""
387echo ""
388echo "${txtcyn}(please enter the number of your selection below)${txtrst}" | centerwide
389echo ""
390echo "1. Create a file" | center
391echo "2. Delete a file" | center
392echo "3. Create a directory" | center
393echo "4. Delete a directory" | center
394echo "5. Create a symbolic link" | center
395echo "6. Change ownership of a file" | center
396echo "7. Change permissions on a file" | center
397echo "8. Modify text within a file" | center
398echo "9. Compress a file" | center
399echo "10. Decompress a file" | center
400echo "11. ${txtpur}Return to main menu${txtrst}" | center
401echo "12. ${txtred}Shut down${txtrst}" | center
402echo ""
403read mainmenuchoice
404case $mainmenuchoice in
4051 )
406 clear && echo "" && echo "Current working directory:" | center && pwd | center
407 echo "" && echo "Please enter the ${txtcyn}full path${txtrst} and filename for the new file:" | centerwide && echo ""
408 echo "${txtcyn}(if file exists, it will be touched)${txtrst}" | center && echo ""
409 read touchfile
410 echo "" && echo ""
411 touch $touchfile && echo "${txtgrn}File $touchfile touched successfully.${txtrst}" | centerwide || echo "${txtred}Touch failed. How did you even do that?${txtrst}" | center
412 echo "" && echo "${txtcyn}(press ENTER to continue)${txtrst}" | center && read
413;;
4142 )
415 clear && echo "" && echo "Current working directory:" | center && pwd | center && echo "" && ls && echo ""
416 echo "Please enter the ${txtcyn}full path${txtrst} and filename for the file to be deleted:" | centerwide && echo ""
417 read rmfile
418 echo "" && echo ""
419 rm -i $rmfile && echo "${txtgrn}File removed successfully.${txtrst}" | center || echo "${txtred}File removal failed.${txtrst}" | center
420 echo "" && echo "${txtcyn}(press ENTER to continue)${txtrst}" | center && read
421;;
4223 )
423 clear && echo "" && echo "Current working directory:" | center && pwd | center && echo "" && ls && echo ""
424 echo "Please enter the ${txtcyn}full path${txtrst} for the directory to be created:" | centerwide && echo ""
425 read mkdirdir
426 echo "" && echo ""
427 mkdir $mkdirdir && echo "${txtgrn}Directory $mkdirdir created successfully.${txtrst}" | centerwide || echo "${txtred}Failed to create directory.${txtrst}" | center
428 echo "" && echo "${txtcyn}(press ENTER to continue)${txtrst}" | center && read
429;;
4304 )
431 clear && echo "" && echo "Current working directory:" | center && pwd | center && echo "" && ls && echo ""
432 echo "Please enter the ${txtcyn}full path${txtrst} for the directory to be removed: ${txtcyn}(MUST BE EMPTY!)${txtrst}" | centerwide && echo ""
433 read rmdirdir
434 echo "" && echo ""
435 rmdir $rmdirdir && echo "${txtgrn}Directory $rmdirdir removed successfully.${txtrst}" | centerwide || echo "${txtred}Failed to remove directory. Please ensure directory is empty.${txtrst}" | centerwide
436 echo "" && echo "${txtcyn}(press ENTER to continue)${txtrst}" | center && read
437;;
4385 )
439 clear && echo "" && echo "Please enter the input file for the symbolic link: ${txtcyn}(FULL PATH!)${txtrst}" | centerwide && echo ""
440 read symlinfile
441 echo "" && echo "Please enter the output file for the symbolic link: ${txtcyn}(SERIOUSLY, FULL PATH!)${txtrst}" | centerwide && echo ""
442 read symloutfile
443 echo "" && echo ""
444 ln -s $symlinfile $symloutfile
445 cat $symloutfile && clear && echo "" && echo "${txtgrn}Symbolic link created successfully at $symloutfile${txtrst}" | centerwide || echo "${txtred}Failed to create symbolic link. Please check paths and filenames and try again.${txtrst}" | centerwide && rm -f $symloutfile
446 echo "" && echo "${txtcyn}(press ENTER to continue)${txtrst}" | center && read
447;;
4486 )
449 clear && echo "" && echo "Which file's ownership should be changed? ${txtcyn}(MUST EXIST, USE FULL PATH!)${txtrst}" | centerwide && echo ""
450 read chownfile
451 echo "" && echo "Please enter the username for the new owner of $chownfile: ${txtcyn}(USER MUST EXIST)${txtrst}" | centerwide && echo ""
452 read chownuser
453 echo "" && echo "Please enter the new group for $chownfile: ${txtcyn}(GROUP MUST EXIST)${txtrst}" | centerwide && echo ""
454 read chowngroup
455 echo "" && echo ""
456 chown $chownuser.$chowngroup $chownfile && echo "${txtgrn}Ownership of $chownfile changed successfully.${txtrst}" | centerwide || echo "${txtred}Failed to change ownership. Please check if user, group and file exist.${txtrst}" | center
457 echo "" && echo "${txtcyn}(press ENTER to continue)${txtrst}" | center && read
458;;
4597 )
460 clear && echo "" && echo "Which file's permissions should be changed? ${txtcyn}(MUST EXIST, USE FULL PATH!)${txtrst}" | centerwide && echo ""
461 read chmodfile
462 echo "" && echo "Please enter the three-digit numeric string for the permissions you would like to set:" | centerwide
463 echo ""
464 echo "${txtcyn}( format is [owner][group][all] | ex: ${txtrst}777${txtcyn} for full control for everyone )${txtrst}" | centerwide
465 echo ""
466 echo "${txtcyn}4 = read${txtrst}" | center
467 echo "${txtcyn}2 = write${txtrst}" | center
468 echo "${txtcyn}1 = execute${txtrst}" | center
469 echo ""
470 read chmodnum
471 echo "" && echo ""
472 chmod $chmodnum $chmodfile && echo "${txtgrn}Permissions for $chmodfile changed successfully.${txtrst}" | centerwide || echo "${txtred}Failed to set permissions.${txtrst}" | center
473 echo "" && echo "${txtcyn}(press ENTER to continue)${txtrst}" | center && read
474;;
4758 )
476 clear && echo "" && echo "Please enter the full path and filename for the file you wish to edit:" | centerwide && echo ""
477 read editfile
478 echo "Which program would you like to use to edit this file?" | centerwide && echo ""
479 echo "${txtcyn}(please enter the number of your selection below)${txtrst}" | centerwide
480 echo "1. vim" | center
481 echo "2. nano" | center
482 echo "3. mcedit" | center
483 echo "4. emacs" | center
484 echo "5. pico" | center
485 echo ""
486 read editapp
487 echo ""
488 case $editapp in
489 1 )
490 vim $editfile || echo "${txtred}Failed to open vim. Please check if it is installed.${txtrst}" | centerwide
491 ;;
492
493 2 )
494 nano $editfile || echo "${txtred}Failed to open nano. Please check if it is installed.${txtrst}" | centerwide
495 ;;
496 3 )
497 mcedit $editfile || echo "${txtred}Failed to open mcedit. Please check if it is installed.${txtrst}" | centerwide
498 ;;
499 4 )
500 emacs $editfile || echo "${txtred}Failed to open emacs. Please check if it is installed.${txtrst}" | centerwide
501 ;;
502 5 )
503 pico $editfile || echo "${txtred}Failed to open pico. Please check if it is installed.${txtrst}" | centerwide
504 ;;
505 * )
506 echo "${txtred}Please make a valid selection.${txtrst}" | center
507 ;;
508 esac
509 echo "" && echo "${txtcyn}(press ENTER to continue)${txtrst}" | center && read
510;;
5119 )
512 clear && echo "" && echo "Please enter the ${txtcyn}full path${txtrst} and filename for the file you wish to compress:" | centerwide && echo ""
513 read pressfile
514 echo "" && echo "Which method of compression would you like to use?" | centerwide && echo ""
515 echo "${txtcyn}(please enter the number of your selection below)${txtrst}" | centerwide
516 echo ""
517 echo "1. gzip" | center
518 echo "2. bzip2" | center
519 echo "3. compress" | center
520 echo ""
521 read pressmethod
522 echo ""
523 case $pressmethod in
524 1 )
525 gzip $pressfile && echo "${txtgrn}File compressed successfully.${txtrst}" | center || echo "${txtred}File failed to compress.${txtrst}" | center
526 ;;
527 2 )
528 bzip2 $pressfile && echo "${txtgrn}File compressed successfully.${txtrst}" | center || echo "${txtred}File failed to compress.${txtrst}" | center
529 ;;
530 3 )
531 compress $pressfile && echo "${txtgrn}File compressed successfully.${txtrst}" | center || echo "${txtred}File failed to compress.${txtrst}" | center
532 ;;
533 * )
534 echo "${txtred}Please make a valid selection.${txtrst}" | center
535 ;;
536 esac
537 echo "" && echo "${txtcyn}(press ENTER to continue)${txtrst}" | center && read
538;;
53910 )
540 clear && echo "" && echo "Please enter the ${txtcyn}full path${txtrst} and filename for the file you wish to decompress:" | centerwide && echo ""
541 read depressfile
542 case $depressfile in
543 *.gz | *.GZ )
544 gunzip $depressfiles && echo "${txtgrn}File decompressed successfully.${txtrst}" | center || echo "${txtred}File failed to decompress.${txtrst}" | center
545 ;;
546 *.bz2 | *.BZ2 )
547 bunzip2 $depressfile && echo "${txtgrn}File decompressed successfully.${txtrst}" | center || echo "${txtred}File failed to decompress.${txtrst}" | center
548 ;;
549
550 *.z | *.Z )
551 uncompress $depressfile && echo "${txtgrn}File decompressed successfully.${txtrst}" | center || echo "${txtred}File failed to decompress.${txtrst}" | center
552 ;;
553
554 * )
555 echo "${txtred}File does not appear to use a valid compression method (gzip, bzip2, or compress). Please decompress manually.${txtrst}" | centerwide
556 esac
557 echo "" && echo "${txtcyn}(press ENTER to continue)${txtrst}" | center && read
558;;
55911 )
560 clear && echo "" && echo "Are you sure you want to return to the main menu? ${txtcyn}y/n${txtrst}" | centerwide && echo ""
561 read exitays
562 case $exitays in
563 y | Y )
564 clear && exit
565 ;;
566 n | N )
567 clear && echo "" && echo "Okay. Nevermind then." | center && echo "" && echo "${txtcyn}(Press ENTER to continue.)${txtrst}" | center && read
568 ;;
569 * )
570 clear && echo "" && echo "${txtred}Please make a valid selection.${txtrst}" | center && echo "" && echo "${txtcyn}(Press ENTER to continue.)${txtrst}" | center && read
571 esac
572;;
57312 )
574 clear && echo "" && echo "Are you sure you want to shut down? ${txtcyn}y/n${txtrst}" | centerwide && echo ""
575 read shutdownays
576 case $shutdownays in
577 y | Y )
578 clear && shutdown -h now
579 ;;
580 n | N )
581 clear && echo "" && echo "Okay. Nevermind then." | center && echo "" && echo "${txtcyn}(Press ENTER to continue.)${txtrst}" | center && read
582 ;;
583 * )
584 clear && echo "" && echo "${txtred}Please make a valid selection.${txtrst}" | center && echo "" && echo "${txtcyn}(Press ENTER to continue.)${txtrst}" | center && read
585 ;;
586 esac
587;;
588* )
589 clear && echo "" && echo "${txtred}Please make a valid selection.${txtrst}" | center && echo "" && echo "${txtcyn}(Press ENTER to continue.)${txtrst}" | center && read
590;;
591esac
592done
593pause
594}
595# Purpose - Get input via the keyboard and make a decision using case..esac
596function read_input(){
597local c
598read -p "Enter your choice [ 1 -12 ] " c
599case $c in
6001) os_info ;;
6012) host_info ;;
6023) net_info ;;
6034) user_info "who" ;;
6045) user_info "last" ;;
6056) mem_info ;;
6067) ip_info ;;
6078) disk_info ;;
6089) proc_info ;;
60910) user_infos ;;
61011) file_info ;;
61112) echo "Bye!"; exit 0 ;;
612*)
613echo "Please select between 1 to 12 choice only."
614pause
615esac
616}
617# ignore CTRL+C, CTRL+Z and quit singles using the trap
618trap '' SIGINT SIGQUIT SIGTSTP
619# main logic
620while true
621do
622clear
623show_menu # display memu
624read_input # wait for user input
625done