Files
dotfiles/update_mac.sh
T
2026-07-21 13:17:15 +02:00

97 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
ARCH=`uname -m`
if [[ $ARCH == "arm64" ]]; then
PREFIX="/opt/homebrew/"
else
PREFIX="/usr/local/"
fi
function set_permissions {
echo "----------"
echo "Disabling Quarantine for Casks ..."
echo "----------"
sudo find $PREFIX/Caskroom -name *.app -exec bash -c "xattr -d com.apple.quarantine {} 2> /dev/null" \;
sudo find $PREFIX/Caskroom -type f -perm +111 -exec bash -c "xattr -d com.apple.quarantine {} 2> /dev/null" \;
sudo find /Applications/ -name *.app -exec bash -c 'xattr -d com.apple.quarantine "{}" 2> /dev/null' \;
sudo find /Applications/ -type f -perm +111 -exec bash -c 'xattr -d com.apple.quarantine "{}" 2> /dev/null' \;
}
function software_update {
echo "----------"
echo "Running software update"
echo "----------"
softwareupdate --all --install --force
}
function update_brew {
echo "----------"
echo "Updating brew software"
echo "----------"
brew update
sudo -u $USER brew upgrade
echo "----------"
echo "Updating casks"
echo "----------"
sudo -u $USER brew upgrade --cask --greedy --verbose
}
function cleanup {
echo "----------"
echo "Running cleanup"
echo "----------"
sudo -u $USER brew cleanup -s
}
function diagnostics {
echo "----------"
echo "Running diagnostics"
echo "----------"
brew doctor
brew missing
}
function update_others {
echo "----------"
echo "Update other stuff"
echo "----------"
if [ -x "$(command -v claude)" ]; then
echo "-- CLAUDE"
claude --update
fi
if [ -x "$(command -v codex)" ]; then
echo "-- CODEX"
codex update
fi
}
if [[ $* == *--help* ]]; then
echo "Usage: $0 [option]"
echo "Default options: --brew-update --update-others --cleanup --diagnostics"
echo -e "Options:\n\t--brew-update\n\t--update-others\n\t--cleanup\n\t--diagnostics\n\t--permission-fix\n\t--system-update"
fi
if [[ -z $* ]]; then
set -- "$*" "--brew-update --cleanup --diagnostics --update-others"
fi
if [[ $* == *--system-update* ]]; then
software_update
fi
if [[ $* == *--brew-update* ]]; then
update_brew
fi
if [[ $* == *--update-others* ]]; then
update_others
fi
if [[ $* == *--cleanup* ]]; then
cleanup
fi
if [[ $* == *--diagnostics* ]]; then
diagnostics
fi
if [[ $* == *--permission-fix* ]]; then
set_permissions
fi