feat(automation): add optimization scripts and update docs for EOD

Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
mw
2026-04-01 17:16:48 +02:00
co-authored by Junie
parent 8af92de50b
commit b4a582af34
6 changed files with 177 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env bash
# scripts/auth-restart.sh
# Performs an authenticated reboot using fdesetup
echo "Enter your Mac password to perform an authenticated restart for FileVault:"
echo "(Typing will be hidden. The Mac will reboot immediately upon success.)"
read -s -p "Password: " PASS
echo ""
if [ -z "$PASS" ]; then
echo "Operation cancelled or no password provided."
exit 1
fi
echo "Verifying password..."
# Verify and cache sudo credentials so we don't have to expect the sudo prompt
echo "$PASS" | sudo -S -v 2>/dev/null
if [ $? -ne 0 ]; then
echo "Incorrect password or sudo authorization failed."
PASS=""
exit 1
fi
echo "Authorization successful. Initiating FileVault authenticated restart..."
# Run fdesetup and feed the password using expect using env variables for safety
export PASS
expect -c '
set timeout 30
spawn sudo fdesetup authrestart
expect {
-re "(?i)(password|recovery key)" {
send "$env(PASS)\r"
exp_continue
}
timeout {
puts "\nError: Timeout waiting for fdesetup prompt."
exit 1
}
eof {
puts "\nAuthenticated restart initiated."
exit 0
}
}
'
PASS=""
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# macOS script to delete unused user accounts
# Removes specified users to optimize machine for dedicated automation tasks
USERS_TO_DELETE=("awsatwareag" "EEsatwareAG" "firebird")
echo "Starting user account deletion..."
for user in "${USERS_TO_DELETE[@]}"; do
# Check if the user exists in Directory Services
if dscl . -read "/Users/$user" > /dev/null 2>&1; then
echo "Deleting user: $user"
sudo sysadminctl -deleteUser "$user"
fi
# Ensure home directory is completely removed
if [ -d "/Users/$user" ]; then
echo "Removing residual home directory: /Users/$user"
sudo rm -rf "/Users/$user"
fi
# Check if neither existed
if ! dscl . -read "/Users/$user" > /dev/null 2>&1 && [ ! -d "/Users/$user" ]; then
echo "Not found or completely removed: $user"
fi
done
echo "User account deletion script complete."
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
# macOS uninstallation script for UI-heavy applications
# Generated to optimize the machine for automation tasks
APPS=(
"/Applications/Adobe Acrobat DC"
"/Applications/Adobe Creative Cloud"
"/Applications/Adobe Media Encoder 2025"
"/Applications/CapCut.app"
"/Applications/Mattermost.app"
"/Applications/Microsoft Teams.app"
"/Applications/WhatsApp.app"
"/Applications/eM Client.app"
"/Applications/Prime Video.app"
"/Applications/wand.app"
"/Applications/UP Studio3.app"
"/Applications/Numbers.app"
)
echo "Starting uninstallation of UI-heavy applications..."
for app in "${APPS[@]}"; do
if [ -e "$app" ]; then
echo "Removing: $app"
sudo rm -rf "$app"
else
echo "Not found (already removed): $app"
fi
done
echo "Uninstallation script complete."
+64
View File
@@ -0,0 +1,64 @@
#!/usr/bin/env bash
echo "Uninstalling Adobe Services, GOG, TeamViewer, Firebird, and Tunnelblick..."
# 1. Kill processes
echo "Killing related processes..."
sudo killall -9 TeamViewer "GOG Galaxy" Tunnelblick "Adobe Desktop Service" CCXProcess CoreSync "Adobe CCXProcess" "Creative Cloud" AdobeIPCBroker "Adobe CEF Helper" fbserver gds_drop 2>/dev/null || true
# 2. Unload Launch Daemons
echo "Unloading System Daemons..."
for daemon in /Library/LaunchDaemons/com.teamviewer.* /Library/LaunchDaemons/com.gog.* /Library/LaunchDaemons/net.tunnelblick.* /Library/LaunchDaemons/org.firebird.* /Library/LaunchDaemons/com.adobe.*; do
if [ -f "$daemon" ]; then
sudo launchctl unload "$daemon" 2>/dev/null || true
sudo rm -f "$daemon"
fi
done
# 3. Unload Launch Agents
echo "Unloading System Agents..."
for agent in /Library/LaunchAgents/com.teamviewer.* /Library/LaunchAgents/com.gog.* /Library/LaunchAgents/com.adobe.*; do
if [ -f "$agent" ]; then
# Try both older unload and newer bootout just in case
sudo launchctl unload "$agent" 2>/dev/null || true
for uid in $(dscl . -list /Users UniqueID | awk '$2 >= 500 {print $2}'); do
sudo launchctl bootout gui/$uid "$agent" 2>/dev/null || true
done
sudo rm -f "$agent"
fi
done
echo "Unloading User Agents..."
for user_agent in ~/Library/LaunchAgents/com.adobe.*; do
if [ -f "$user_agent" ]; then
launchctl unload "$user_agent" 2>/dev/null || true
rm -f "$user_agent"
fi
done
# 4. Remove App Directories
echo "Removing Application Files..."
sudo rm -rf "/Applications/TeamViewer.app"
sudo rm -rf "/Applications/GOG Galaxy.app"
sudo rm -rf "/Applications/Tunnelblick.app"
# Firebird standard manual installation locations
sudo rm -rf "/Library/Frameworks/Firebird.framework"
sudo rm -rf "/opt/firebird"
# Common Adobe paths
sudo rm -rf "/Applications/Adobe"*
sudo rm -rf "/Applications/Utilities/Adobe"*
# Application Support
sudo rm -rf "/Library/Application Support/Adobe"
sudo rm -rf "/Library/Application Support/TeamViewer"
sudo rm -rf "/Library/Application Support/GOG.com"
sudo rm -rf "/Library/Application Support/Tunnelblick"
# Try homebrew just in case some were installed via brew casks
echo "Checking Homebrew casks..."
brew uninstall --cask tunnelblick teamviewer gog-galaxy 2>/dev/null || true
brew uninstall firebird 2>/dev/null || true
echo "Uninstallation finished successfully."