Repository navigation
Expand file tree
/
Copy pathmaster-cleanup.sh
More file actions
executable file
·108 lines (88 loc) · 2.2 KB
/
Copy pathmaster-cleanup.sh
File metadata and controls
executable file
·108 lines (88 loc) · 2.2 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
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
PURGE_DATA=0
MODE="all"
CLEANUP_SCRIPTS=(
"cleanup/remove-hey-webapp.sh"
"cleanup/remove-basecamp-webapp.sh"
"cleanup/remove-fizzy-webapp.sh"
"cleanup/remove-1password.sh"
"cleanup/remove-signal-desktop.sh"
"cleanup/remove-typora.sh"
"cleanup/remove-helix.sh"
)
step_index=0
step_total=0
run_script() {
local script_path="$SCRIPT_DIR/$1"
shift
if [ ! -f "$script_path" ]; then
echo "Missing cleanup script: $script_path"
exit 1
fi
bash "$script_path" "$@"
}
run_step() {
local label="$1"
shift
step_index=$((step_index + 1))
printf '\n[%d/%d] %s\n' "$step_index" "$step_total" "$label"
"$@"
}
script_args() {
local script_name="$1"
if [ "$PURGE_DATA" -ne 1 ]; then
return
fi
case "$script_name" in
cleanup/remove-1password.sh|cleanup/remove-signal-desktop.sh|cleanup/remove-typora.sh|cleanup/remove-helix.sh)
printf '%s\n' "--purge-data"
;;
esac
}
usage() {
cat <<'EOF'
Usage: ./master-cleanup.sh [all] [--purge-data]
Runs the repo's cleanup scripts for unwanted Omarchy apps and packages.
Options:
all Run the full cleanup set (default)
--purge-data Pass data-purge flags to cleanup scripts that support it
help|-h|--help
EOF
}
for arg in "$@"; do
case "$arg" in
all)
MODE="all"
;;
--purge-data)
PURGE_DATA=1
;;
help|-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $arg" >&2
usage >&2
exit 1
;;
esac
done
case "$MODE" in
all)
step_total=${#CLEANUP_SCRIPTS[@]}
;;
*)
echo "Unknown cleanup mode: $MODE" >&2
exit 1
;;
esac
echo "Cleanup mode: $MODE"
echo "Purge data: $(if [ "$PURGE_DATA" -eq 1 ]; then echo yes; else echo no; fi)"
for cleanup_script in "${CLEANUP_SCRIPTS[@]}"; do
mapfile -t extra_args < <(script_args "$cleanup_script")
run_step "Running $cleanup_script" run_script "$cleanup_script" "${extra_args[@]}"
done