mirror of
https://github.com/tw93/Mole.git
synced 2026-02-16 23:24:11 +00:00
fix: remove Time Machine mount check
This commit is contained in:
@@ -267,40 +267,21 @@ tm_is_running() {
|
|||||||
grep -qE '(^|[[:space:]])("Running"|Running)[[:space:]]*=[[:space:]]*1([[:space:]]*;|$)' <<< "$st"
|
grep -qE '(^|[[:space:]])("Running"|Running)[[:space:]]*=[[:space:]]*1([[:space:]]*;|$)' <<< "$st"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Returns 0 if snapshot mounts exist under local snapshot paths
|
|
||||||
# Returns 1 if none found
|
|
||||||
# Returns 2 if mount state cannot be determined
|
|
||||||
tm_snapshots_mounted() {
|
|
||||||
local m
|
|
||||||
if ! m="$(run_with_timeout 3 mount 2> /dev/null)"; then
|
|
||||||
return 2
|
|
||||||
fi
|
|
||||||
# Match modern and legacy local-snapshot browse mounts:
|
|
||||||
# - /Volumes/com.apple.TimeMachine.localsnapshots/... (APFS)
|
|
||||||
# - /.TimeMachine (APFS)
|
|
||||||
# - /Volumes/MobileBackups (HFS+, legacy)
|
|
||||||
grep -qE '[[:space:]]on[[:space:]](/\.TimeMachine(/|[[:space:]])|/Volumes/com\.apple\.TimeMachine\.localsnapshots(/|[[:space:]])|/Volumes/MobileBackups(/|[[:space:]]))' <<< "$m"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Local APFS snapshots (keep the most recent).
|
# Local APFS snapshots (keep the most recent).
|
||||||
clean_local_snapshots() {
|
clean_local_snapshots() {
|
||||||
if ! command -v tmutil > /dev/null 2>&1; then
|
if ! command -v tmutil > /dev/null 2>&1; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local rc_running rc_mounted
|
local rc_running=0
|
||||||
rc_running=0
|
|
||||||
tm_is_running || rc_running=$?
|
tm_is_running || rc_running=$?
|
||||||
|
|
||||||
rc_mounted=0
|
if [[ $rc_running -eq 2 ]]; then
|
||||||
tm_snapshots_mounted || rc_mounted=$?
|
|
||||||
|
|
||||||
if [[ $rc_running -eq 2 || $rc_mounted -eq 2 ]]; then
|
|
||||||
echo -e " ${YELLOW}!${NC} Could not determine Time Machine status; skipping snapshot cleanup"
|
echo -e " ${YELLOW}!${NC} Could not determine Time Machine status; skipping snapshot cleanup"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $rc_running -eq 0 || $rc_mounted -eq 0 ]]; then
|
if [[ $rc_running -eq 0 ]]; then
|
||||||
echo -e " ${YELLOW}!${NC} Time Machine is active; skipping snapshot cleanup"
|
echo -e " ${YELLOW}!${NC} Time Machine is active; skipping snapshot cleanup"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -126,7 +126,6 @@ tmutil() {
|
|||||||
start_section_spinner(){ :; }
|
start_section_spinner(){ :; }
|
||||||
stop_section_spinner(){ :; }
|
stop_section_spinner(){ :; }
|
||||||
tm_is_running(){ return 1; }
|
tm_is_running(){ return 1; }
|
||||||
tm_snapshots_mounted(){ return 1; }
|
|
||||||
|
|
||||||
DRY_RUN="false"
|
DRY_RUN="false"
|
||||||
clean_local_snapshots
|
clean_local_snapshots
|
||||||
@@ -157,7 +156,6 @@ start_section_spinner(){ :; }
|
|||||||
stop_section_spinner(){ :; }
|
stop_section_spinner(){ :; }
|
||||||
note_activity(){ :; }
|
note_activity(){ :; }
|
||||||
tm_is_running(){ return 1; }
|
tm_is_running(){ return 1; }
|
||||||
tm_snapshots_mounted(){ return 1; }
|
|
||||||
|
|
||||||
DRY_RUN="true"
|
DRY_RUN="true"
|
||||||
clean_local_snapshots
|
clean_local_snapshots
|
||||||
@@ -193,7 +191,6 @@ start_section_spinner(){ :; }
|
|||||||
stop_section_spinner(){ :; }
|
stop_section_spinner(){ :; }
|
||||||
note_activity(){ :; }
|
note_activity(){ :; }
|
||||||
tm_is_running(){ return 1; }
|
tm_is_running(){ return 1; }
|
||||||
tm_snapshots_mounted(){ return 1; }
|
|
||||||
|
|
||||||
unset -f read_key
|
unset -f read_key
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user