-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_tools_menu.sh
More file actions
executable file
·173 lines (163 loc) · 3.85 KB
/
admin_tools_menu.sh
File metadata and controls
executable file
·173 lines (163 loc) · 3.85 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/bin/bash
# admin_tools_menu.sh
# Interactive system and network administration helper menu.
# Function to display menu
display_menu() {
clear
echo "System and Network Administration Script"
echo "---------------------------------------"
echo "1. Check System Information"
echo "2. Network Configuration"
echo "3. Firewall Configuration"
echo "4. User Management"
echo "5. Backup Management"
echo "6. System Maintenance"
echo "7. Exit"
}
# Function to check system information
check_system_info() {
echo "System Information:"
echo "-------------------"
uname -a
echo ""
df -h
echo ""
free -m
read -p "Press Enter to continue..."
}
# Function for network configuration
network_configuration() {
echo "Network Configuration:"
echo "-----------------------"
ip addr show
echo ""
netstat -rn
read -p "Press Enter to continue..."
}
# Function for firewall configuration
firewall_configuration() {
echo "Firewall Configuration:"
echo "-----------------------"
# Add your firewall rules here
echo "Firewall rules:"
iptables -L
read -p "Press Enter to continue..."
}
# Function for user management
user_management() {
echo "User Management:"
echo "----------------"
echo "1. Add User"
echo "2. Delete User"
echo "3. Change Password"
echo "4. List Users"
echo "5. Back"
read -p "Enter your choice: " choice
case $choice in
1)
read -p "Enter username: " username
adduser $username
;;
2)
read -p "Enter username to delete: " username
userdel $username
;;
3)
read -p "Enter username to change password: " username
passwd $username
;;
4)
cat /etc/passwd | cut -d: -f1
read -p "Press Enter to continue..."
;;
5)
;;
*)
echo "Invalid option!"
;;
esac
}
# Function for backup management
backup_management() {
echo "Backup Management:"
echo "------------------"
echo "1. Backup Files"
echo "2. Restore Files"
echo "3. Back"
read -p "Enter your choice: " choice
case $choice in
1)
read -p "Enter source directory: " src_dir
read -p "Enter destination directory: " dest_dir
tar -cvzf $dest_dir/backup_$(date +%Y%m%d).tar.gz $src_dir
;;
2)
read -p "Enter backup file to restore: " backup_file
read -p "Enter destination directory: " dest_dir
tar -xvzf $backup_file -C $dest_dir
;;
3)
;;
*)
echo "Invalid option!"
;;
esac
}
# Function for system maintenance
system_maintenance() {
echo "System Maintenance:"
echo "-------------------"
echo "1. Update System"
echo "2. Upgrade Packages"
echo "3. Clean Up"
echo "4. Back"
read -p "Enter your choice: " choice
case $choice in
1)
apt-get update
;;
2)
apt-get upgrade
;;
3)
apt-get autoremove
;;
4)
;;
*)
echo "Invalid option!"
;;
esac
}
# Main script
while true; do
display_menu
read -p "Enter your choice: " choice
case $choice in
1)
check_system_info
;;
2)
network_configuration
;;
3)
firewall_configuration
;;
4)
user_management
;;
5)
backup_management
;;
6)
system_maintenance
;;
7)
echo "Exiting..."
exit 0
;;
*)
echo "Invalid option!"
;;
esac
done