-
Notifications
You must be signed in to change notification settings - Fork 0
/
sheen_cli
128 lines (112 loc) · 2.72 KB
/
sheen_cli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# this file contains a selectable menu for all standard tasks
# you may pull this via a wget <URL> to the server you are working on and execute this script to perform tasks
#!/bin/bash
# clear the screen so we have clean start
clear
# tput_menu: a menu driven system information program
BG_BLUE="$(tput setab 4)"
BG_CYAN="$(tput setab 6)"
BG_BLACK="$(tput setab 0)"
FG_GREEN="$(tput setaf 2)"
FG_WHITE="$(tput setaf 7)"
# Save screen
tput smcup
# Display menu until selection == 0
while [[ $REPLY != 0 ]]; do
echo -n ${BG_CYAN}${FG_WHITE}
clear
cat <<- _EOF_
Please Select:
- - - - - - - - - - - - - - - - -
1 - SYSTEM INFORMATION
- - - - - - - - - - - - - - - - -
1a. display hostname and uptime
1b. display disk space
1c. display home space utilization
1d. list files open to the internet (lsof -ni)
1e. display current used shell
1f. show linux version
1g. show running services
1h. show installed packages (includes versions) "q" to quit
1j. show currently running processes on machine
- - - - - - - - - - - - - - - - -
2 - PACKAGE MANAGEMENT
- - - - - - - - - - - - - - - - -
2a.
- - - - - - - - - - - - - - - - -
4 - SERVICES
- - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
5 - NETWORKING
- - - - - - - - - - - - - - - - -
5a. show current dns servers
5b. netcat connectivity test
5c. tcpdump - traffic check
- - - - - - - - - - - - - - - - -
6 - LOGS
- - - - - - - - - - - - - - - - -
6a. list any files that have /var/auth.log open
6b. check auth.log for errors
- - - - - - - - - - - - - - - - -
7 - DOCKER
- - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - -
9 - UFW aka uncomplicated firewall
- - - - - - - - - - - - - - - - -
9a. show ufw rules
9b. add ufw rule
9c. tail ufw logs for troubleshooting
-
- - - - - - - - - - - - - - - - -
q. Quit
_EOF_
read -p "Enter selection > " selection
# Clear area beneath menu
tput cup 10 0
echo -n ${BG_BLACK}${FG_GREEN}
tput ed
tput cup 11 0
# Act on selection
case $selection in
1a) echo "Hostname: $HOSTNAME"
uptime
;;
1b) df -h /
;;
1c) if [[ $(id -u) -eq 0 ]]; then
echo "Home Space Utilization (All Users)"
du -sh /home/* 2> /dev/null
else
echo "Home Space Utilization ($USER)"
du -s $HOME/* 2> /dev/null | sort -nr
fi
;;
1d) sudo lsof -ni
;;
1e) echo $SHELL
;;
1f) cat /etc/*release
;;
1g) sudo systemctl | grep running
;;
1h) dpkg-query -l
;;
1j) ps -aux | more
;;
5a) cat /etc/resolv.conf
;;
6b) sudo grep error /var/log/auth.log
;;
9) sudo ufw show added
;;
q) break
;;
*) echo "Invalid entry."
;;
esac
printf "\n\nPress any key to continue."
read -n 1
done
# Restore screen
tput rmcup
echo "Program terminated."