Skip to content

Commit a567724

Browse files
refactored, added sql client, error checking, faster checks for already installed
1 parent 089d79c commit a567724

10 files changed

Lines changed: 180 additions & 102 deletions

scriptlets/setup-brew-casks.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#! /bin/bash
2+
brewCasks=( "$@" )
3+
echo "--- brew casks ---"
4+
HOMEBREW_NO_AUTO_UPDATE=1
5+
installedBrews=$(brew list)
6+
7+
containsElement () {
8+
local e match="$1"
9+
shift
10+
for e; do [[ "$e" == "$match" ]] && return 0; done
11+
return 1
12+
}
13+
14+
for i in ${brewCasks[@]}; do
15+
echo -n "installing $i... "
16+
containsElement $i ${installedBrews[@]}
17+
contains=$?
18+
if [ $contains -ne 0 ]; then
19+
echo -n "downloading... "
20+
output=$(brew install --cask $i >/dev/null)
21+
failed=$?
22+
if [ $failed -ne 0 ]; then
23+
echo -n "$output"
24+
exit 1
25+
fi
26+
fi
27+
echo "done"
28+
done

scriptlets/setup-brew.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#! /bin/bash
2+
# Install Brew
3+
echo -n "installing brew... "
4+
HOMEBREW_NO_AUTO_UPDATE=1
5+
command -v brew >/dev/null 2>&1 || { echo >&2 "Installing Homebrew Now"; \
6+
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"; }
7+
brew tap homebrew/cask-drivers
8+
echo "done"

scriptlets/setup-brews.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#! /bin/bash
2+
brews=( "$@" )
3+
echo "--- brew brews ---"
4+
HOMEBREW_NO_AUTO_UPDATE=1
5+
installedBrews=$(brew list)
6+
7+
containsElement () {
8+
local e match="$1"
9+
shift
10+
for e; do [[ "$e" == "$match" ]] && return 0; done
11+
return 1
12+
}
13+
14+
for i in ${brews[@]}; do
15+
echo -n "installing $i... "
16+
containsElement $i ${installedBrews[@]}
17+
contains=$?
18+
if [ $contains -ne 0 ]; then
19+
echo -n " downloading... "
20+
output=$(brew install $i >/dev/null)
21+
failed=$?
22+
if [ $failed -ne 0 ]; then
23+
echo -n "$output"
24+
exit 1
25+
fi
26+
fi
27+
echo "done"
28+
done
29+

scriptlets/setup-git.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#! /bin/bash
2+
3+
email=$(git config --global user.email)
4+
username=$(git config --global user.name)
5+
echo -n "setting up git... "
6+
if [ "$username" == "" ]; then
7+
echo ""
8+
echo "enter username:"
9+
read gitUsername
10+
git config --global user.name "$gitUsername"
11+
fi
12+
if [ "$email" == "" ]; then
13+
echo ""
14+
echo "enter email:"
15+
read email
16+
git config --global user.email "$email"
17+
fi
18+
19+
git config --global pager.branch false
20+
21+
if [ ! -f ~/.ssh/id_rsa ]; then
22+
echo ""
23+
echo "generating public private key pair with email $email"
24+
ssh-keygen -t rsa -b 4096 -C "$email" -q -N "" -f ~/.ssh/id_rsa
25+
fi
26+
27+
echo "done"

scriptlets/setup-go.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#! /bin/bash
2+
3+
# Go paths
4+
echo 'export GOPATH="${HOME}/.go"' >> ~/.zshrc-ext
5+
echo 'export GOROOT="$(brew --prefix golang)/libexec"' >> ~/.zshrc-ext
6+
echo 'export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"' >> ~/.zshrc-ext

scriptlets/setup-macos-defaults.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#! /bin/bash
2+
# Annoying macos stuff
3+
echo -n "setting key repeat... "
4+
defaults write -g InitialKeyRepeat -int 13 # normal minimum is 15 (225 ms)
5+
defaults write -g KeyRepeat -int 2 # normal minimum is 2 (30 ms)
6+
echo "done"
7+
echo -n "cleaning toolbar... "
8+
defaults write com.apple.dock persistent-apps -array
9+
echo "done"

scriptlets/setup-npm-globals.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#! /bin/bash
2+
npmGlobals=( "$@" )
3+
for i in ${npmGlobals[@]}; do
4+
echo -n "installing $i... "
5+
npm list -g $i >/dev/null 2>&1
6+
contains=$?
7+
if [ $contains -ne 0 ]; then
8+
echo -n "downloading... "
9+
output=$(npm install -g $i 2>&1 )
10+
failed=$?
11+
if [ $failed -ne 0 ]; then
12+
echo -n "$output"
13+
exit 1
14+
fi
15+
fi
16+
echo "done"
17+
done

scriptlets/setup-nvm.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#! /bin/bash
2+
echo -n "installing nvm... "
3+
if [ ! -d "$HOME/.nvm" ]; then
4+
NVM_DIR=""
5+
nvmLatest=$(curl -sL https://github.com/nvm-sh/nvm/releases/latest | egrep -so "[0-9]*\.[0-9]*\.[0-9]*" | head -n 1 | tr -s " ")
6+
nodeLatest=$(curl -sL https://github.com/nodejs/node/releases/latest | egrep -so "[0-9]*\.[0-9]*\.[0-9]*" | head -n 1 | tr -s " ")
7+
echo -n " nvm: $nvmLatest node: $nodeLatest "
8+
curl -s -o- "https://raw.githubusercontent.com/nvm-sh/nvm/v${nvmLatest}/install.sh" | bash >/dev/null 2>&1
9+
NVM_DIR="$HOME/.nvm"
10+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
11+
nvm install --no-progress $nodeLatest >/dev/null 2>&1
12+
fi
13+
echo "done"

scriptlets/setup-oh-my-zsh.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#! /bin/bash
2+
# Oh My Zsh
3+
echo -n "installing zsh / oh my zsh..."
4+
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" >/dev/null 2>&1
5+
if grep -q "zshrc-ext" ~/.zshrc; then
6+
echo -n ""
7+
else
8+
echo "source ~/.zshrc-ext" >> ~/.zshrc
9+
chsh -s /usr/local/bin/zsh
10+
fi
11+
echo "done"
12+
13+
echo "plugins=(git colored-man colorize pip python brew osx zsh-syntax-highlighting)" > ~/.zshrc-ext
14+
echo ". `brew --prefix`/etc/profile.d/z.sh" >> ~/.zshrc-ext
15+
echo "disable r functions" >> ~/.zshrc-ext

setup.sh

Lines changed: 28 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,30 @@
11
#!/bin/bash
22

3-
4-
brewCask=("brave-browser" "1password" "iterm2" "slack" "expressvpn" "visual-studio-code" "steam" "vlc" "qbittorrent" "zoomus" "goland" "ngrok" "adoptopenjdk/openjdk/adoptopenjdk8" "docker" "dbeaver-community")
5-
brew=("go" "git" "bat" "zsh" "z" "vim" "wget" "curl" "htop" "pipenv" "gcc" "tree" "jq" "postgres" "coreutils" "r" "rsync" "tmux" "maven" "watch" "gdrive" "go-task/tap/go-task" "goreleaser" "pandoc" "rename" "hub" "sqlite")
6-
npmGlobals=("vercel" "http-server" "npm-check-updates")
7-
8-
# Annoying macos stuff
9-
echo -n "setting key repeat..."
10-
defaults write -g InitialKeyRepeat -int 13 # normal minimum is 15 (225 ms)
11-
defaults write -g KeyRepeat -int 2 # normal minimum is 2 (30 ms)
12-
echo "done"
13-
echo -n "cleaning toolbar..."
14-
defaults write com.apple.dock persistent-apps -array
15-
echo "done"
16-
17-
# Install Brew
18-
echo -n "installing brew..."
19-
command -v brew >/dev/null 2>&1 || { echo >&2 "Installing Homebrew Now"; \
20-
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"; }
21-
brew tap homebrew/cask-drivers
22-
echo "done"
23-
24-
for i in ${brewCask[@]}; do
25-
echo -n "installing $i..."
26-
brew list --cask $i >/dev/null 2>&1 || brew install --cask $i
27-
echo "done"
28-
done
29-
30-
for i in ${brew[@]}; do
31-
echo -n "installing $i..."
32-
brew list $i >/dev/null 2>&1 || brew install $i
33-
echo "done"
34-
done
35-
36-
37-
# Oh My Zsh
38-
echo -n "installing zsh / oh my zsh..."
39-
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" >/dev/null 2>&1
40-
if grep -q "zshrc-ext" ~/.zshrc; then
41-
echo -n ""
42-
else
43-
echo "source ~/.zshrc-ext" >> ~/.zshrc
44-
chsh -s /usr/local/bin/zsh
45-
fi
46-
echo "done"
47-
48-
echo "plugins=(git colored-man colorize pip python brew osx zsh-syntax-highlighting)" > ~/.zshrc-ext
49-
echo ". `brew --prefix`/etc/profile.d/z.sh" >> ~/.zshrc-ext
50-
echo "disable r functions" >> ~/.zshrc-ext
51-
52-
# Miro
53-
echo -n "installing miro..."
54-
mdfind "kMDItemKind == 'Application'" | grep Miro >/dev/null 2>&1
55-
res=$?
56-
if [ $res -ne 0 ]; then
57-
wget -O /tmp/miro.dmg "https://desktop.realtimeboard.com/platforms/darwin/Miro%20-%20formerly%20RealtimeBoard.dmg"
58-
hdiutil mount /tmp/miro.dmg
59-
sudo cp -R "/Volumes/Miro - formerly RealtimeBoard/Miro - formerly RealtimeBoard.app" /Applications/Miro.app
60-
hdiutil unmount "/Volumes/Miro - formerly RealtimeBoard/"
61-
fi
62-
echo "done"
63-
64-
65-
echo "setting up git"
66-
echo "username:"
67-
read gitUsername
68-
echo "email:"
69-
read gitEmail
70-
71-
git config --global user.email "$gitEmail"
72-
git config --global user.name "$gitUsername"
73-
git config --global pager.branch false
74-
75-
echo "configuring ssh"
76-
ssh-keygen -t rsa -b 4096 -C "$gitEmail" -q -N "" -f ~/.ssh/id_rsa
77-
78-
# Node
79-
echo "installing nvm..."
80-
command -v nvm >/dev/null 2>&1
81-
nvmExists=$?
82-
if [ $nvmExists -ne 0 ]; then
83-
NVM_DIR=""
84-
nvmLatest=$(curl https://github.com/nvm-sh/nvm/releases/latest | egrep -so "[0-9]*\.[0-9]*\.[0-9]*")
85-
nodeLatest=$(curl https://github.com/nodejs/node/releases/latest | egrep -so "[0-9]*\.[0-9]*\.[0-9]*")
86-
echo -n " nvm: $nvmLatest node: $nodeLatest"
87-
curl -s -o- "https://raw.githubusercontent.com/nvm-sh/nvm/v${nvmLatest}/install.sh" | bash
88-
NVM_DIR="$HOME/.nvm"
89-
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
90-
nvm install $nodeLatest
91-
fi
92-
93-
for i in ${npmGlobals[@]}; do
94-
echo -n "installing $i..."
95-
npm install -g $i
96-
echo "done"
97-
done
98-
99-
echo "done"
100-
101-
# Go paths
102-
echo 'export GOPATH="${HOME}/.go"' >> ~/.zshrc-ext
103-
echo 'export GOROOT="$(brew --prefix golang)/libexec"' >> ~/.zshrc-ext
104-
echo 'export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"' >> ~/.zshrc-ext
3+
brewCasks="brave-browser 1password iterm2 slack expressvpn
4+
visual-studio-code steam vlc qbittorrent zoom
5+
goland ngrok docker dbeaver-community"
6+
7+
brews="go git bat zsh z vim wget curl htop pipenv gcc tree
8+
jq postgresql coreutils r rsync tmux maven watch
9+
gdrive go-task goreleaser pandoc rename
10+
hub sqlite mysql-client openjdk@8"
11+
12+
npmGlobals="vercel http-server npm-check-updates"
13+
14+
# exit if anything fails
15+
set -e
16+
17+
# ask for sudo up front so we don't need to ask for passwords later
18+
sudo -v
19+
20+
./scriptlets/setup-macos-defaults.sh
21+
./scriptlets/setup-brew.sh
22+
./scriptlets/setup-brew-casks.sh $brewCasks
23+
./scriptlets/setup-brews.sh $brews
24+
./scriptlets/setup-oh-my-zsh.sh
25+
./scriptlets/setup-git.sh
26+
./scriptlets/setup-nvm.sh
27+
./scriptlets/setup-npm-globals.sh $npmGlobals
28+
./scriptlets/setup-go.sh
29+
echo ""
30+
echo "complete"

0 commit comments

Comments
 (0)