mirror of
https://github.com/tw93/Mole.git
synced 2026-02-14 17:02:26 +00:00
Merge branch 'main' of github.com:tw93/Mole
This commit is contained in:
@@ -320,7 +320,7 @@ clean_orphaned_app_data() {
|
|||||||
# These are left behind when apps are uninstalled but their system services remain
|
# These are left behind when apps are uninstalled but their system services remain
|
||||||
clean_orphaned_system_services() {
|
clean_orphaned_system_services() {
|
||||||
# Requires sudo
|
# Requires sudo
|
||||||
if ! sudo -n true 2>/dev/null; then
|
if ! sudo -n true 2> /dev/null; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -371,13 +371,13 @@ clean_orphaned_system_services() {
|
|||||||
if [[ "$bundle_id" == $file_pattern ]] && [[ ! -d "$app_path" ]]; then
|
if [[ "$bundle_id" == $file_pattern ]] && [[ ! -d "$app_path" ]]; then
|
||||||
orphaned_files+=("$plist")
|
orphaned_files+=("$plist")
|
||||||
local size_kb
|
local size_kb
|
||||||
size_kb=$(sudo du -sk "$plist" 2>/dev/null | awk '{print $1}' || echo "0")
|
size_kb=$(sudo du -sk "$plist" 2> /dev/null | awk '{print $1}' || echo "0")
|
||||||
((total_orphaned_kb += size_kb))
|
((total_orphaned_kb += size_kb))
|
||||||
((orphaned_count++))
|
((orphaned_count++))
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done < <(sudo find /Library/LaunchDaemons -maxdepth 1 -name "*.plist" -print0 2>/dev/null)
|
done < <(sudo find /Library/LaunchDaemons -maxdepth 1 -name "*.plist" -print0 2> /dev/null)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Scan system LaunchAgents
|
# Scan system LaunchAgents
|
||||||
@@ -399,13 +399,13 @@ clean_orphaned_system_services() {
|
|||||||
if [[ "$bundle_id" == $file_pattern ]] && [[ ! -d "$app_path" ]]; then
|
if [[ "$bundle_id" == $file_pattern ]] && [[ ! -d "$app_path" ]]; then
|
||||||
orphaned_files+=("$plist")
|
orphaned_files+=("$plist")
|
||||||
local size_kb
|
local size_kb
|
||||||
size_kb=$(sudo du -sk "$plist" 2>/dev/null | awk '{print $1}' || echo "0")
|
size_kb=$(sudo du -sk "$plist" 2> /dev/null | awk '{print $1}' || echo "0")
|
||||||
((total_orphaned_kb += size_kb))
|
((total_orphaned_kb += size_kb))
|
||||||
((orphaned_count++))
|
((orphaned_count++))
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done < <(sudo find /Library/LaunchAgents -maxdepth 1 -name "*.plist" -print0 2>/dev/null)
|
done < <(sudo find /Library/LaunchAgents -maxdepth 1 -name "*.plist" -print0 2> /dev/null)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Scan PrivilegedHelperTools
|
# Scan PrivilegedHelperTools
|
||||||
@@ -425,13 +425,13 @@ clean_orphaned_system_services() {
|
|||||||
if [[ "$filename" == $file_pattern ]] && [[ ! -d "$app_path" ]]; then
|
if [[ "$filename" == $file_pattern ]] && [[ ! -d "$app_path" ]]; then
|
||||||
orphaned_files+=("$helper")
|
orphaned_files+=("$helper")
|
||||||
local size_kb
|
local size_kb
|
||||||
size_kb=$(sudo du -sk "$helper" 2>/dev/null | awk '{print $1}' || echo "0")
|
size_kb=$(sudo du -sk "$helper" 2> /dev/null | awk '{print $1}' || echo "0")
|
||||||
((total_orphaned_kb += size_kb))
|
((total_orphaned_kb += size_kb))
|
||||||
((orphaned_count++))
|
((orphaned_count++))
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done < <(sudo find /Library/PrivilegedHelperTools -maxdepth 1 -type f -print0 2>/dev/null)
|
done < <(sudo find /Library/PrivilegedHelperTools -maxdepth 1 -type f -print0 2> /dev/null)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
stop_section_spinner
|
stop_section_spinner
|
||||||
@@ -449,9 +449,9 @@ clean_orphaned_system_services() {
|
|||||||
else
|
else
|
||||||
# Unload if it's a LaunchDaemon/LaunchAgent
|
# Unload if it's a LaunchDaemon/LaunchAgent
|
||||||
if [[ "$orphan_file" == *.plist ]]; then
|
if [[ "$orphan_file" == *.plist ]]; then
|
||||||
sudo launchctl unload "$orphan_file" 2>/dev/null || true
|
sudo launchctl unload "$orphan_file" 2> /dev/null || true
|
||||||
fi
|
fi
|
||||||
if sudo rm -f "$orphan_file" 2>/dev/null; then
|
if sudo rm -f "$orphan_file" 2> /dev/null; then
|
||||||
debug_log "Removed orphaned service: $orphan_file"
|
debug_log "Removed orphaned service: $orphan_file"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user