install.fairie/home/.chezmoiscripts/universal/run_onchange_after_01-auto-update.sh.tmpl

28 lines
1.3 KiB
Cheetah
Raw Normal View History

2023-07-17 00:28:38 -07:00
#!/usr/bin/env bash
# @file Ensure Auto-Update
# @brief Configures macOS to automatically check for system updates
# @description
# This script adds a macOS LaunchDaemon for the root user that checks for updates and automatically
# applies them. It will run if the file is available at `$HOME/Library/LaunchDaemons/com.apple.automatedupdates.plist`.
{{ includeTemplate "universal/profile" }}
{{ includeTemplate "universal/logg" }}
### Enable automated updates on macOS
if [ -d /Applications ] && [ -d /System ]; then
if [ -f "$HOME/Library/LaunchDaemons/com.apple.automatedupdates.plist" ] && [ ! -f "/Library/LaunchDaemons/com.apple.automatedupdates.plist" ]; then
logg info 'Configuring macOS to automatically apply system updates'
sudo mkdir -p /Library/LaunchDaemons
sudo cp -f "$HOME/Library/LaunchDaemons/com.apple.automatedupdates.plist" "/Library/LaunchDaemons/com.apple.automatedupdates.plist"
2023-11-04 18:46:18 -07:00
logg info 'Loading /Library/LaunchDaemons/com.apple.automatedupdates.plist'
2023-07-17 00:28:38 -07:00
sudo launchctl load "/Library/LaunchDaemons/com.apple.automatedupdates.plist" && logg success 'launchctl load successful'
fi
fi
2023-12-06 23:32:20 -08:00
### Ensure gem is updated
if command -v gem > /dev/null; then
logg info 'Ensuring system gem is updated' && gem update --system
else
logg info 'Could not find gem in PATH so skipping gem system update'
fi