1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-15 18:40:05 +00:00
This commit is contained in:
Tw93
2025-12-08 18:59:52 +08:00
parent 1ffd677bf2
commit 88c5f92ac4
8 changed files with 38 additions and 38 deletions

View File

@@ -31,7 +31,7 @@ list_login_items() {
check_touchid_sudo() { check_touchid_sudo() {
# Check whitelist # Check whitelist
if command -v is_whitelisted >/dev/null && is_whitelisted "check_touchid"; then return; fi if command -v is_whitelisted > /dev/null && is_whitelisted "check_touchid"; then return; fi
# Check if Touch ID is configured for sudo # Check if Touch ID is configured for sudo
local pam_file="/etc/pam.d/sudo" local pam_file="/etc/pam.d/sudo"
if [[ -f "$pam_file" ]] && grep -q "pam_tid.so" "$pam_file" 2> /dev/null; then if [[ -f "$pam_file" ]] && grep -q "pam_tid.so" "$pam_file" 2> /dev/null; then
@@ -56,7 +56,7 @@ check_touchid_sudo() {
check_rosetta() { check_rosetta() {
# Check whitelist # Check whitelist
if command -v is_whitelisted >/dev/null && is_whitelisted "check_rosetta"; then return; fi if command -v is_whitelisted > /dev/null && is_whitelisted "check_rosetta"; then return; fi
# Check Rosetta 2 (for Apple Silicon Macs) # Check Rosetta 2 (for Apple Silicon Macs)
if [[ "$(uname -m)" == "arm64" ]]; then if [[ "$(uname -m)" == "arm64" ]]; then
if [[ -f "/Library/Apple/usr/share/rosetta/rosetta" ]]; then if [[ -f "/Library/Apple/usr/share/rosetta/rosetta" ]]; then
@@ -70,7 +70,7 @@ check_rosetta() {
check_git_config() { check_git_config() {
# Check whitelist # Check whitelist
if command -v is_whitelisted >/dev/null && is_whitelisted "check_git_config"; then return; fi if command -v is_whitelisted > /dev/null && is_whitelisted "check_git_config"; then return; fi
# Check basic Git configuration # Check basic Git configuration
if command -v git > /dev/null 2>&1; then if command -v git > /dev/null 2>&1; then
local git_name=$(git config --global user.name 2> /dev/null || echo "") local git_name=$(git config --global user.name 2> /dev/null || echo "")
@@ -96,7 +96,7 @@ check_all_config() {
check_filevault() { check_filevault() {
# Check whitelist # Check whitelist
if command -v is_whitelisted >/dev/null && is_whitelisted "check_filevault"; then return; fi if command -v is_whitelisted > /dev/null && is_whitelisted "check_filevault"; then return; fi
# Check FileVault encryption status # Check FileVault encryption status
if command -v fdesetup > /dev/null 2>&1; then if command -v fdesetup > /dev/null 2>&1; then
local fv_status=$(fdesetup status 2> /dev/null || echo "") local fv_status=$(fdesetup status 2> /dev/null || echo "")
@@ -111,7 +111,7 @@ check_filevault() {
check_firewall() { check_firewall() {
# Check whitelist # Check whitelist
if command -v is_whitelisted >/dev/null && is_whitelisted "firewall"; then return; fi if command -v is_whitelisted > /dev/null && is_whitelisted "firewall"; then return; fi
# Check firewall status # Check firewall status
unset FIREWALL_DISABLED unset FIREWALL_DISABLED
local firewall_status=$(defaults read /Library/Preferences/com.apple.alf globalstate 2> /dev/null || echo "0") local firewall_status=$(defaults read /Library/Preferences/com.apple.alf globalstate 2> /dev/null || echo "0")
@@ -127,7 +127,7 @@ check_firewall() {
check_gatekeeper() { check_gatekeeper() {
# Check whitelist # Check whitelist
if command -v is_whitelisted >/dev/null && is_whitelisted "gatekeeper"; then return; fi if command -v is_whitelisted > /dev/null && is_whitelisted "gatekeeper"; then return; fi
# Check Gatekeeper status # Check Gatekeeper status
if command -v spctl > /dev/null 2>&1; then if command -v spctl > /dev/null 2>&1; then
local gk_status=$(spctl --status 2> /dev/null || echo "") local gk_status=$(spctl --status 2> /dev/null || echo "")
@@ -145,7 +145,7 @@ check_gatekeeper() {
check_sip() { check_sip() {
# Check whitelist # Check whitelist
if command -v is_whitelisted >/dev/null && is_whitelisted "check_sip"; then return; fi if command -v is_whitelisted > /dev/null && is_whitelisted "check_sip"; then return; fi
# Check System Integrity Protection # Check System Integrity Protection
if command -v csrutil > /dev/null 2>&1; then if command -v csrutil > /dev/null 2>&1; then
local sip_status=$(csrutil status 2> /dev/null || echo "") local sip_status=$(csrutil status 2> /dev/null || echo "")
@@ -209,7 +209,7 @@ is_cache_valid() {
check_homebrew_updates() { check_homebrew_updates() {
# Check whitelist # Check whitelist
if command -v is_whitelisted >/dev/null && is_whitelisted "check_brew_updates"; then return; fi if command -v is_whitelisted > /dev/null && is_whitelisted "check_brew_updates"; then return; fi
if ! command -v brew > /dev/null 2>&1; then if ! command -v brew > /dev/null 2>&1; then
return return
fi fi
@@ -337,7 +337,7 @@ check_appstore_updates() {
check_macos_update() { check_macos_update() {
# Check whitelist # Check whitelist
if command -v is_whitelisted >/dev/null && is_whitelisted "check_macos_updates"; then return; fi if command -v is_whitelisted > /dev/null && is_whitelisted "check_macos_updates"; then return; fi
local spinner_started=false local spinner_started=false
if [[ -t 1 ]]; then if [[ -t 1 ]]; then
printf " Checking macOS updates...\r" printf " Checking macOS updates...\r"
@@ -542,7 +542,7 @@ check_memory_usage() {
check_login_items() { check_login_items() {
# Check whitelist # Check whitelist
if command -v is_whitelisted >/dev/null && is_whitelisted "check_login_items"; then return; fi if command -v is_whitelisted > /dev/null && is_whitelisted "check_login_items"; then return; fi
local login_items_count=0 local login_items_count=0
local -a login_items_list=() local -a login_items_list=()
@@ -661,7 +661,7 @@ check_swap_usage() {
check_brew_health() { check_brew_health() {
# Check whitelist # Check whitelist
if command -v is_whitelisted >/dev/null && is_whitelisted "check_brew_health"; then return; fi if command -v is_whitelisted > /dev/null && is_whitelisted "check_brew_health"; then return; fi
# Check Homebrew doctor # Check Homebrew doctor
if command -v brew > /dev/null 2>&1; then if command -v brew > /dev/null 2>&1; then
# Show spinner while running brew doctor # Show spinner while running brew doctor

View File

@@ -513,8 +513,8 @@ find_app_files() {
[[ -d ~/Library/Android ]] && files_to_clean+=("$HOME/Library/Android") [[ -d ~/Library/Android ]] && files_to_clean+=("$HOME/Library/Android")
[[ -d ~/.android ]] && files_to_clean+=("$HOME/.android") [[ -d ~/.android ]] && files_to_clean+=("$HOME/.android")
[[ -d ~/.gradle ]] && files_to_clean+=("$HOME/.gradle") [[ -d ~/.gradle ]] && files_to_clean+=("$HOME/.gradle")
[[ -d ~/Library/Application\ Support/Google ]] && \ [[ -d ~/Library/Application\ Support/Google ]] &&
while IFS= read -r -d '' dir; do files_to_clean+=("$dir"); done < <(find ~/Library/Application\ Support/Google -maxdepth 1 -name "AndroidStudio*" -print0 2>/dev/null) while IFS= read -r -d '' dir; do files_to_clean+=("$dir"); done < <(find ~/Library/Application\ Support/Google -maxdepth 1 -name "AndroidStudio*" -print0 2> /dev/null)
fi fi
# Xcode # Xcode
@@ -526,12 +526,12 @@ find_app_files() {
# IntelliJ IDEA, PyCharm, WebStorm, etc. (JetBrains IDEs) # IntelliJ IDEA, PyCharm, WebStorm, etc. (JetBrains IDEs)
if [[ "$bundle_id" =~ jetbrains ]] || [[ "$app_name" =~ IntelliJ|PyCharm|WebStorm|GoLand|RubyMine|PhpStorm|CLion|DataGrip|Rider ]]; then if [[ "$bundle_id" =~ jetbrains ]] || [[ "$app_name" =~ IntelliJ|PyCharm|WebStorm|GoLand|RubyMine|PhpStorm|CLion|DataGrip|Rider ]]; then
local ide_name="$app_name" local ide_name="$app_name"
[[ -d ~/Library/Application\ Support/JetBrains ]] && \ [[ -d ~/Library/Application\ Support/JetBrains ]] &&
while IFS= read -r -d '' dir; do files_to_clean+=("$dir"); done < <(find ~/Library/Application\ Support/JetBrains -maxdepth 1 -name "${ide_name}*" -print0 2>/dev/null) while IFS= read -r -d '' dir; do files_to_clean+=("$dir"); done < <(find ~/Library/Application\ Support/JetBrains -maxdepth 1 -name "${ide_name}*" -print0 2> /dev/null)
[[ -d ~/Library/Caches/JetBrains ]] && \ [[ -d ~/Library/Caches/JetBrains ]] &&
while IFS= read -r -d '' dir; do files_to_clean+=("$dir"); done < <(find ~/Library/Caches/JetBrains -maxdepth 1 -name "${ide_name}*" -print0 2>/dev/null) while IFS= read -r -d '' dir; do files_to_clean+=("$dir"); done < <(find ~/Library/Caches/JetBrains -maxdepth 1 -name "${ide_name}*" -print0 2> /dev/null)
[[ -d ~/Library/Logs/JetBrains ]] && \ [[ -d ~/Library/Logs/JetBrains ]] &&
while IFS= read -r -d '' dir; do files_to_clean+=("$dir"); done < <(find ~/Library/Logs/JetBrains -maxdepth 1 -name "${ide_name}*" -print0 2>/dev/null) while IFS= read -r -d '' dir; do files_to_clean+=("$dir"); done < <(find ~/Library/Logs/JetBrains -maxdepth 1 -name "${ide_name}*" -print0 2> /dev/null)
fi fi
# Unity # Unity

View File

@@ -304,7 +304,7 @@ cleanup_temp_files() {
if [[ ${#MOLE_TEMP_DIRS[@]} -gt 0 ]]; then if [[ ${#MOLE_TEMP_DIRS[@]} -gt 0 ]]; then
for file in "${MOLE_TEMP_DIRS[@]}"; do for file in "${MOLE_TEMP_DIRS[@]}"; do
[[ -d "$file" ]] && rm -rf "$file" 2> /dev/null || true # SAFE: cleanup_temp_files [[ -d "$file" ]] && rm -rf "$file" 2> /dev/null || true # SAFE: cleanup_temp_files
done done
fi fi

View File

@@ -89,7 +89,7 @@ remove_apps_from_dock() {
fi fi
# Execute Python helper to prune dock entries for the given app paths # Execute Python helper to prune dock entries for the given app paths
python3 - "$@" << 'PY' 2>/dev/null || return 0 python3 - "$@" << 'PY' 2> /dev/null || return 0
import os import os
import plistlib import plistlib
import subprocess import subprocess

View File

@@ -100,7 +100,7 @@ safe_remove() {
debug_log "Removing: $path" debug_log "Removing: $path"
# Perform the deletion # Perform the deletion
if rm -rf "$path" 2> /dev/null; then # SAFE: safe_remove implementation if rm -rf "$path" 2> /dev/null; then # SAFE: safe_remove implementation
return 0 return 0
else else
[[ "$silent" != "true" ]] && log_error "Failed to remove: $path" [[ "$silent" != "true" ]] && log_error "Failed to remove: $path"
@@ -135,7 +135,7 @@ safe_sudo_remove() {
debug_log "Removing (sudo): $path" debug_log "Removing (sudo): $path"
# Perform the deletion # Perform the deletion
if sudo rm -rf "$path" 2> /dev/null; then # SAFE: safe_sudo_remove implementation if sudo rm -rf "$path" 2> /dev/null; then # SAFE: safe_sudo_remove implementation
return 0 return 0
else else
log_error "Failed to remove (sudo): $path" log_error "Failed to remove (sudo): $path"

View File

@@ -418,7 +418,7 @@ batch_uninstall_applications() {
done done
done done
if [[ ${#removed_paths[@]} -gt 0 ]]; then if [[ ${#removed_paths[@]} -gt 0 ]]; then
remove_apps_from_dock "${removed_paths[@]}" 2>/dev/null || true remove_apps_from_dock "${removed_paths[@]}" 2> /dev/null || true
fi fi
fi fi