mirror of
https://github.com/tw93/Mole.git
synced 2026-02-16 14:43:39 +00:00
Safer and more compatible with modern macOS
This commit is contained in:
@@ -205,15 +205,6 @@ execute_optimization() {
|
|||||||
echo -e "${GRAY} Tip: Move unwanted .plist files to trash${NC}"
|
echo -e "${GRAY} Tip: Move unwanted .plist files to trash${NC}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
network_services)
|
|
||||||
echo -e "${BLUE}${ICON_ARROW}${NC} Resetting network services..."
|
|
||||||
if sudo dscacheutil -flushcache 2> /dev/null && sudo killall -HUP mDNSResponder 2> /dev/null; then
|
|
||||||
echo -e "${GREEN}${ICON_SUCCESS}${NC} Network services reset"
|
|
||||||
else
|
|
||||||
echo -e "${RED}${ICON_ERROR}${NC} Failed to reset network services"
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
cache_refresh)
|
cache_refresh)
|
||||||
echo -e "${BLUE}${ICON_ARROW}${NC} Resetting Quick Look cache..."
|
echo -e "${BLUE}${ICON_ARROW}${NC} Resetting Quick Look cache..."
|
||||||
qlmanage -r cache > /dev/null 2>&1 || true
|
qlmanage -r cache > /dev/null 2>&1 || true
|
||||||
@@ -360,14 +351,7 @@ execute_optimization() {
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
swap_cleanup)
|
swap_cleanup)
|
||||||
echo -e "${BLUE}${ICON_ARROW}${NC} Flushing memory caches..."
|
echo -e "${BLUE}${ICON_ARROW}${NC} Removing swapfiles and resetting dynamic pager..."
|
||||||
if sudo purge > /dev/null 2>&1; then
|
|
||||||
echo -e "${GREEN}${ICON_SUCCESS}${NC} Inactive memory purged"
|
|
||||||
else
|
|
||||||
echo -e "${YELLOW}!${NC} purge command failed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "${BLUE}${ICON_ARROW}${NC} Stopping dynamic pager and removing swapfiles..."
|
|
||||||
if sudo launchctl unload /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist > /dev/null 2>&1; then
|
if sudo launchctl unload /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist > /dev/null 2>&1; then
|
||||||
sudo rm -f /private/var/vm/swapfile* > /dev/null 2>&1 || true
|
sudo rm -f /private/var/vm/swapfile* > /dev/null 2>&1 || true
|
||||||
sudo touch /private/var/vm/swapfile0 > /dev/null 2>&1 || true
|
sudo touch /private/var/vm/swapfile0 > /dev/null 2>&1 || true
|
||||||
@@ -380,6 +364,18 @@ execute_optimization() {
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
startup_cache)
|
startup_cache)
|
||||||
|
local macos_version
|
||||||
|
macos_version=$(sw_vers -productVersion | cut -d '.' -f 1)
|
||||||
|
|
||||||
|
# macOS 11+ has read-only system volume, skip system file operations
|
||||||
|
if [[ "$macos_version" -ge 11 ]] || [[ "$(uname -m)" == "arm64" ]]; then
|
||||||
|
echo -e "${BLUE}${ICON_ARROW}${NC} Rebuilding kext caches..."
|
||||||
|
if sudo kextcache -i / > /dev/null 2>&1; then
|
||||||
|
echo -e "${GREEN}${ICON_SUCCESS}${NC} Startup caches refreshed"
|
||||||
|
else
|
||||||
|
echo -e "${GREEN}${ICON_SUCCESS}${NC} Startup caches refreshed (sealed system volume)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
echo -e "${BLUE}${ICON_ARROW}${NC} Rebuilding kext caches..."
|
echo -e "${BLUE}${ICON_ARROW}${NC} Rebuilding kext caches..."
|
||||||
if sudo kextcache -i / > /dev/null 2>&1; then
|
if sudo kextcache -i / > /dev/null 2>&1; then
|
||||||
echo -e "${GREEN}${ICON_SUCCESS}${NC} Kernel/kext caches rebuilt"
|
echo -e "${GREEN}${ICON_SUCCESS}${NC} Kernel/kext caches rebuilt"
|
||||||
@@ -391,6 +387,7 @@ execute_optimization() {
|
|||||||
sudo rm -rf /System/Library/PrelinkedKernels/* > /dev/null 2>&1 || true
|
sudo rm -rf /System/Library/PrelinkedKernels/* > /dev/null 2>&1 || true
|
||||||
sudo kextcache -system-prelinked-kernel > /dev/null 2>&1 || true
|
sudo kextcache -system-prelinked-kernel > /dev/null 2>&1 || true
|
||||||
echo -e "${GREEN}${ICON_SUCCESS}${NC} Startup caches refreshed"
|
echo -e "${GREEN}${ICON_SUCCESS}${NC} Startup caches refreshed"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
local_snapshots)
|
local_snapshots)
|
||||||
@@ -422,7 +419,6 @@ execute_optimization() {
|
|||||||
developer_cleanup)
|
developer_cleanup)
|
||||||
local -a dev_targets=(
|
local -a dev_targets=(
|
||||||
"$HOME/Library/Developer/Xcode/DerivedData|Xcode DerivedData"
|
"$HOME/Library/Developer/Xcode/DerivedData|Xcode DerivedData"
|
||||||
"$HOME/Library/Developer/Xcode/Archives|Build archives"
|
|
||||||
"$HOME/Library/Developer/Xcode/iOS DeviceSupport|iOS Device support files"
|
"$HOME/Library/Developer/Xcode/iOS DeviceSupport|iOS Device support files"
|
||||||
"$HOME/Library/Developer/CoreSimulator/Caches|CoreSimulator caches"
|
"$HOME/Library/Developer/CoreSimulator/Caches|CoreSimulator caches"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user