-
-
Notifications
You must be signed in to change notification settings - Fork 50
/
brewup.sh
executable file
·65 lines (53 loc) · 1.75 KB
/
brewup.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
64
65
#!/bin/bash
PATH="/usr/local/bin:/usr/local/sbin:/Users/${USER}/.local/bin:/usr/bin:/usr/sbin:/bin:/sbin"
## M1 Brew PATH Fix
if [ $(arch) = "arm64" ]; then
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"
fi
## Fix for brew doctor warnings if using pyenv
if which pyenv >/dev/null 2>&1; then
brew='env PATH=${PATH//$(pyenv root)\/shims:/} brew'
fi
## checks if mas, terminal-notifier are installed, if not will promt to install
if [ -z $(which mas) ]; then
brew install mas 2>/dev/null
fi
DATE=$(date '+%Y%m%d.%H%M')
red=$(tput setaf 1)
green=$(tput setaf 2)
yellow=$(tput setaf 3)
blue=$(tput setaf 4)
reset=$(tput sgr0)
brewFileName="Brewfile.${HOSTNAME}"
## Sets Working Dir as Real A Script Location
if [ -z $(which realpath) ]; then
brew install coreutils
fi
cd $(dirname "$(realpath "$0")")
echo "${blue}==>${reset} Pulling latest changes from repo..."
git pull 2>&1
## Brew Diagnotic
echo "${yellow}==>${reset} Running Brew Doctor diagnostics..."
brew doctor 2>&1
brew missing 2>&1
echo -e "${green}==>${reset} Brew Doctor diagnotic finished."
## Brew packages update and cleanup
echo "${yellow}==>${reset} Checking for brew updates..."
brew update 2>&1
brew outdated 2>&1
brew upgrade 2>&1
brew cleanup -s 2>&1
echo "${green}==>${reset} Finished brew updates"
## Mac Store Updates
## Disabled due to issues with mas
# echo "${yellow}==>${reset} Checking macOS App Store updates..."
# mas upgrade 2>&1
# echo "${green}==>${reset} Finished macOS App Store updates"
## Creating Dump File with hostname
brew bundle dump --force --file="./${brewFileName}"
## Pushing to Repo
echo "${blue}==>${reset} Pushing changes to repo..."
git add . 2>&1
git commit -m "${DATE}_update" 2>&1
git push 2>&1
echo "${green}==>${reset} Finished updating brew and mas packages"