Mac Setup
Setup a MacOS based computer to seamlessly access homelab services, both remotely and locally. Also optimizes the Terminal app to access VM hosts and work on homelab code.
Dependencies
- Install xcode, homebrew, pip, git and other dependencies
xcode-select --install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
git --version
Terminal
- Install Iterm2, zsh, oh-my-zsh, powerlevel10k (src)
brew install zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
vim ~/.zshrc
ZSH_THEME="powerlevel10k/powerlevel10k"
plugins=(zsh-autosuggestions zsh-syntax-highlighting git)
- Install color scheme and fonts
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
wget https://raw.githubusercontent.com/mbadolato/iTerm2-Color-Schemes/master/schemes/Solarized%20Dark%20Higher%20Contrast.itermcolors
brew tap homebrew/cask-fonts
brew install --cask font-meslo-lg-nerd-font
wget -O .vimrc https://raw.githubusercontent.com/amix/vimrc/master/vimrcs/basic.vim
- Configure iTerm (src)
Source code
- Install tools
brew install fd yq yamllint
pip3 install jinjanator jinjanator-plugin-ansible passlib
- Render source
cd ~/Documents
git clone https://github.com/babraham123/homelab homelab
cd homelab
# Fill in personal details based on vars.template.yml
vim vars.yml
tools/render_src.sh ~/Documents/homelab-rendered
cd ~/Documents/homelab-rendered/src
cp macos/aliases.zsh ~/.oh-my-zsh/custom
cp macos/functions.zsh ~/.oh-my-zsh/custom
Auto-switch DNS
ref - Create network location
networksetup -createlocation Home populate
networksetup -switchtolocation Home
- Configure the desired DNS settings
- Go To System Settings >> Wi-Fi >> Details >> DNS
- Under DNS Servers, add 192.168.1.1 and delete other IPs
- Under Search Domains, add janedoe.com
- Setup watcher
networksetup -switchtolocation Automatic
cp macos/vpn.sh /usr/local/bin
cp macos/detect_wifi_change.sh /usr/local/bin
cp macos/com.my.detect.wifi.change.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/com.my.detect.wifi.change.plist
- Test by switching WiFi networks, confirm location changes
networksetup -getcurrentlocation