-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixxxer.sh
executable file
·63 lines (50 loc) · 1.92 KB
/
fixxxer.sh
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
#!/bin/bash -v
loggedInUser=$( /bin/stat -f%Su "/dev/console" )
# Define the user name and directory paths
USERNAME="$loggedInUser"
echo $USERNAME
HOME_DIR="/Users/$loggedInUser"
# Function to reset network settings
# reset_network_settings() {
# echo "Resetting network settings..."
# Remove network preferences
# rm -rf /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist
# rm -rf /Library/Preferences/SystemConfiguration/com.apple.network.identification.plist
# rm -rf /Library/Preferences/SystemConfiguration/com.apple.wifi.message-tracer.plist
# rm -rf /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist
# rm -rf /Library/Preferences/SystemConfiguration/preferences.plist
# Restart network services
# echo "Restarting network services..."
# networksetup -detectnewhardware
# }
# Function to clear caches
clear_caches() {
echo "Clearing caches..."
# Clear user caches
rm -rf $HOME_DIR/Library/Caches/*
rm -rf $HOME_DIR/Library/Containers/com.apple.systempreferences/Data/Library/Caches/*
# Clear system caches
rm -rf /Library/Caches/*
rm -rf /System/Library/Caches/*
}
# Function to reset home directory permissions
reset_home_permissions() {
echo "Resetting home permissions..."
# Reset ownership of the home directory
chown -R admin:staff $HOME_DIR
# Set proper permissions for the home directory and subdirectories
find $HOME_DIR -type d -exec chmod 755 {} \;
# Set proper permissions for files in the home directory
find $HOME_DIR -type f -exec chmod 644 {} \;
# Special handling for specific directories which require differing permissions
chmod 700 $HOME_DIR/Library
chmod 700 $HOME_DIR/.ssh
chmod 700 $HOME_DIR/.gnupg
}
# Run the functions
# reset_network_settings
clear_caches
reset_home_permissions
# Inform the user
echo "Network settings reset, caches cleared, and hom directory permssions reset."
echo "Please restart your MacBook and try logging in with the primary user account again."