Files
dotfiles/update_mac.sh
T

97 lines
2.3 KiB
Bash
Raw Normal View History

2023-06-01 15:19:30 +02:00
#!/bin/bash
2023-06-02 14:28:50 +02:00
ARCH=`uname -m`
if [[ $ARCH == "arm64" ]]; then
PREFIX="/opt/homebrew/"
else
2023-06-02 15:51:31 +02:00
PREFIX="/usr/local/"
2023-06-02 14:28:50 +02:00
fi
2023-06-01 15:19:30 +02:00
function set_permissions {
echo "----------"
echo "Disabling Quarantine for Casks ..."
echo "----------"
2025-10-27 09:54:18 +01:00
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' \;
2023-06-01 15:19:30 +02:00
}
function software_update {
echo "----------"
echo "Running software update"
echo "----------"
softwareupdate --all --install --force
}
function update_brew {
echo "----------"
echo "Updating brew software"
echo "----------"
brew update
2025-10-27 09:54:18 +01:00
sudo -u $USER brew upgrade
2023-06-01 15:19:30 +02:00
echo "----------"
echo "Updating casks"
echo "----------"
2025-10-27 09:54:18 +01:00
sudo -u $USER brew upgrade --cask --greedy --verbose
2023-06-01 15:19:30 +02:00
}
function cleanup {
echo "----------"
echo "Running cleanup"
echo "----------"
2025-10-27 09:54:18 +01:00
sudo -u $USER brew cleanup -s
2023-06-01 15:19:30 +02:00
}
function diagnostics {
echo "----------"
echo "Running diagnostics"
echo "----------"
brew doctor
brew missing
}
2026-07-05 17:15:51 +02:00
function update_others {
echo "----------"
echo "Update other stuff"
echo "----------"
if [ -x "$(command -v claude)" ]; then
echo "-- CLAUDE"
claude --update
fi
2026-07-21 13:17:15 +02:00
if [ -x "$(command -v codex)" ]; then
echo "-- CODEX"
codex update
fi
2026-07-05 17:15:51 +02:00
}
2023-06-01 15:19:30 +02:00
if [[ $* == *--help* ]]; then
echo "Usage: $0 [option]"
2026-07-05 17:15:51 +02:00
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"
2023-06-01 15:19:30 +02:00
fi
if [[ -z $* ]]; then
2026-07-05 17:15:51 +02:00
set -- "$*" "--brew-update --cleanup --diagnostics --update-others"
2023-06-01 15:19:30 +02:00
fi
if [[ $* == *--system-update* ]]; then
software_update
fi
if [[ $* == *--brew-update* ]]; then
update_brew
fi
2026-07-05 17:15:51 +02:00
if [[ $* == *--update-others* ]]; then
update_others
fi
2023-06-01 15:19:30 +02:00
if [[ $* == *--cleanup* ]]; then
cleanup
fi
if [[ $* == *--diagnostics* ]]; then
diagnostics
fi
if [[ $* == *--permission-fix* ]]; then
set_permissions
fi