-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleanmac-interactive
More file actions
executable file
·329 lines (290 loc) · 9.34 KB
/
cleanmac-interactive
File metadata and controls
executable file
·329 lines (290 loc) · 9.34 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
#!/bin/bash
# cleanmac-interactive - Interactive Dashboard for CleanMac Pro v3.0.0 (Fixed)
# Part of CleanMac-Pro by Dan13681989
# Handle command-line arguments
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
echo "CleanMac Pro v3.0.0"
echo "Usage: cleanmac [OPTION]"
echo "Options:"
echo " --help, -h Show this help"
echo " --version, -v Show version"
echo " (no args) Launch interactive dashboard"
exit 0
fi
if [ "$1" = "--version" ] || [ "$1" = "-v" ]; then
echo "CleanMac Pro v3.0.0"
exit 0
fi
if [ $# -gt 0 ]; then
echo "Error: Unknown option '$1'"
echo "Try: cleanmac --help"
exit 1
fi
# Colors for UI
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
BOLD='\033[1m'
DIM='\033[2m'
# Configuration
CONFIG_FILE="$HOME/.cleanmacrc"
BACKUP_DIR="$HOME/Documents/CleanMac_Backups"
VERSION="3.0.0"
LAST_RUN_FILE="$HOME/.cleanmac_last_run"
# ASCII Art Header
show_header() {
clear
echo -e "${CYAN}${BOLD}"
echo " ____ _ __ __ ____ "
echo " / ___| | ___ _ __ __ _| \/ |_ __| _ \ _ __ ___ _ __ "
echo " | | | |/ _ \| '__/ _\` | |\/| | '__| |_) | '__/ _ \ '_ \ "
echo " | |___| | (_) | | | (_| | | | | | | __/| | | __/ |_) |"
echo " \____|_|\___/|_| \__,_|_| |_|_| |_| |_| \___| .__/ "
echo " |_| "
echo -e "${NC}${DIM} Professional macOS Optimization Tool v${VERSION}${NC}"
echo "="
}
# System Information Dashboard
system_dashboard() {
echo -e "\n${BLUE}${BOLD}📊 SYSTEM DASHBOARD${NC}"
echo "------------------------------------------"
# Disk space
disk_info=$(df -h / | tail -1)
echo -e "💾 Disk: $(echo $disk_info | awk '{print $3 " / " $2 " used (" $5 ")"}')"
# Memory
memory=$(vm_stat | grep "Pages free" | awk '{printf "%.1f", $3*4096/1073741824}')
echo -e "🧠 Memory: ${GREEN}${memory}GB${NC} free"
# CPU
cpu_usage=$(top -l 1 -s 0 | grep "CPU usage" | awk '{print $3}' | tr -d '%')
echo -e "⚡ CPU: ${YELLOW}${cpu_usage}%${NC} user"
# Network
if ping -c 1 -t 2 8.8.8.8 &>/dev/null; then
echo -e "🌐 Network: ${GREEN}Connected${NC}"
else
echo -e "🌐 Network: ${RED}Offline${NC}"
fi
# Last cleanup
if [[ -f "$LAST_RUN_FILE" ]]; then
last_run=$(date -r "$LAST_RUN_FILE" "+%Y-%m-%d %H:%M")
echo -e "🧹 Last Clean: ${GREEN}${last_run}${NC}"
else
echo -e "🧹 Last Clean: ${RED}Never${NC}"
fi
}
# Simple progress bar
progress_bar() {
local duration=${1:-2}
echo -ne "["
for i in {1..20}; do
echo -ne "▓"
sleep 0.1
done
echo -e "] Done!"
}
# Main Menu
main_menu() {
while true; do
show_header
system_dashboard
echo -e "\n${GREEN}${BOLD}🚀 MAIN MENU${NC}"
echo "------------------------------------------"
echo "1) Quick Clean (Safe cache cleaning)"
echo "2) Analyze Disk Usage"
echo "3) Find Large Files"
echo "4) Docker Cleanup"
echo "5) Security Scan"
echo "6) Network Optimization"
echo "7) Advanced Tools"
echo "8) System Monitor"
echo "9) Settings"
echo "a) Schedule Management (Custom)"
echo "b) Backup System (Custom)"
echo "0) Exit"
echo -ne "\n${BOLD}Select option [0-9,a,b]: ${NC}"
read -n 1 -r choice
echo
case $choice in
1) quick_clean_menu ;;
2) analyze_disk_menu ;;
3) large_files_menu ;;
4) docker_cleanup_menu ;;
5) security_scan_menu ;;
6) network_optimize_menu ;;
7) advanced_tools_menu ;;
8) system_monitor ;;
9) settings_menu ;;
a) custom_schedule_menu ;;
b) custom_backup_menu ;;
0) echo -e "\n${GREEN}👋 Thank you for using CleanMac Pro!${NC}"; exit 0 ;;
*) echo -e "${RED}Invalid selection!${NC}"; sleep 1 ;;
esac
done
}
# Custom Schedule Menu (Your feature)
custom_schedule_menu() {
echo -e "\n${YELLOW}${BOLD}📅 CUSTOM SCHEDULE MANAGEMENT${NC}"
echo "------------------------------------------"
echo "Running custom schedule manager..."
./scripts/manage_schedule.sh status
echo -e "\n${DIM}Press Enter to continue...${NC}"
read -r
}
# Custom Backup Menu (Your feature)
custom_backup_menu() {
echo -e "\n${YELLOW}${BOLD}💾 CUSTOM BACKUP SYSTEM${NC}"
echo "------------------------------------------"
echo "Running custom backup system..."
./scripts/backup_system.sh info
echo -e "\n${DIM}Press Enter to continue...${NC}"
read -r
}
# Quick Clean Menu
quick_clean_menu() {
echo -e "\n${GREEN}${BOLD}🚀 QUICK CLEAN${NC}"
echo "------------------------------------------"
if [[ -f "./cleanmac-smart-cache" ]]; then
echo -e "${YELLOW}Running smart cache cleanup...${NC}"
./cleanmac-smart-cache
date > "$LAST_RUN_FILE"
elif [[ -f "./scripts/system_cleanup.sh" ]]; then
echo -e "${YELLOW}Running system cleanup...${NC}"
./scripts/system_cleanup.sh
date > "$LAST_RUN_FILE"
else
echo -e "${RED}Cleanup scripts not found!${NC}"
fi
echo -e "\n${DIM}Press Enter to continue...${NC}"
read -r
}
# Analyze Disk Menu
analyze_disk_menu() {
echo -e "\n${YELLOW}${BOLD}🔍 DISK ANALYSIS${NC}"
echo "------------------------------------------"
echo "Disk analysis would run here..."
echo -e "\n${DIM}Press Enter to continue...${NC}"
read -r
}
# Large Files Menu
large_files_menu() {
echo -e "\n${YELLOW}${BOLD}📁 LARGE FILES${NC}"
echo "------------------------------------------"
echo "Large file finder would run here..."
echo -e "\n${DIM}Press Enter to continue...${NC}"
read -r
}
# Docker Cleanup Menu
docker_cleanup_menu() {
echo -e "\n${CYAN}${BOLD}🐳 DOCKER CLEANUP${NC}"
echo "------------------------------------------"
echo "Docker cleanup would run here..."
echo -e "\n${DIM}Press Enter to continue...${NC}"
read -r
}
# Security Scan Menu
security_scan_menu() {
echo -e "\n${RED}${BOLD}🔒 SECURITY SCAN${NC}"
echo "------------------------------------------"
echo "Security scan would run here..."
echo -e "\n${DIM}Press Enter to continue...${NC}"
read -r
}
# Network Optimization Menu
network_optimize_menu() {
echo -e "\n${BLUE}${BOLD}🌐 NETWORK OPTIMIZATION${NC}"
echo "------------------------------------------"
echo "1) [INFO] Use option 2 instead"
echo "2) Run Full Network Optimizer (with speed test)"
echo "3) Flush DNS Cache"
echo "0) Back"
echo -ne "\nSelect: "
read -n 1 -r option
echo
case $option in
1) echo "This option is deprecated. Please use option 2." ;;
2) ./scripts/network_optimizer.sh ;;
3) echo "Flushing DNS cache..." ;;
0) return ;;
*) echo -e "${RED}Invalid selection!${NC}" ;;
esac
echo -e "\n${DIM}Press Enter to continue...${NC}"
read -r
}
# Advanced Tools Menu
advanced_tools_menu() {
echo -e "\n${MAGENTA}${BOLD}🛠️ ADVANCED TOOLS${NC}"
echo "------------------------------------------"
echo "1) Empty Trash"
echo "2) Clear DNS Cache"
echo "3) Reset Launchpad"
echo "4) Clean Xcode Cache"
echo "5) Clean npm Cache"
echo "0) Back"
echo -ne "\nSelect: "
read -n 1 -r option
echo
case $option in
1) echo "Emptying trash..." ;;
2) echo "Clearing DNS cache..." ;;
3) echo "Resetting launchpad..." ;;
4) echo "Cleaning Xcode cache..." ;;
5) echo "Cleaning npm cache..." ;;
0) return ;;
*) echo -e "${RED}Invalid selection!${NC}" ;;
esac
echo -e "\n${DIM}Press Enter to continue...${NC}"
read -r
}
# System Monitor
system_monitor() {
echo -e "\n${GREEN}${BOLD}📊 SYSTEM MONITOR${NC}"
echo "------------------------------------------"
echo "System monitoring would run here..."
echo -e "\n${DIM}Press Enter to continue...${NC}"
read -r
}
# Settings Menu
settings_menu() {
echo -e "\n${BLUE}${BOLD}⚙️ SETTINGS${NC}"
echo "------------------------------------------"
echo "1) View Current Config"
echo "2) Change Backup Directory"
echo "3) Reset Configuration"
echo "0) Back"
echo -ne "\nSelect: "
read -n 1 -r option
echo
case $option in
1)
echo -e "\n${CYAN}Current Configuration:${NC}"
if [[ -f "$CONFIG_FILE" ]]; then
cat "$CONFIG_FILE"
else
echo "Using default settings"
echo "BACKUP_DIR: $BACKUP_DIR"
fi
;;
2)
echo -ne "New backup directory: "
read -r new_dir
if [[ -n "$new_dir" ]]; then
BACKUP_DIR="$new_dir"
echo "Backup directory updated to: $BACKUP_DIR"
fi
;;
3)
echo -e "${RED}Resetting configuration...${NC}"
rm -f "$CONFIG_FILE"
echo "Configuration reset to defaults"
;;
0) return ;;
*) echo -e "${RED}Invalid selection!${NC}" ;;
esac
echo -e "\n${DIM}Press Enter to continue...${NC}"
read -r
}
# Start the main menu
main_menu