Files
dotfiles/install.sh
T

255 lines
7.5 KiB
Bash
Raw Normal View History

2021-11-29 08:07:17 +00:00
#!/usr/bin/env bash
2021-12-03 17:12:52 +00:00
export PATH="/home/linuxbrew/.linuxbrew/bin:/opt/homebrew/bin/:$PATH"
2021-11-29 08:07:17 +00:00
[ -d ~/.additional_dotfiles ] || (mkdir -p ~/.additional_dotfiles && touch ~/.additional_dotfiles/credentials)
2021-12-03 18:20:33 +00:00
[ -d /usr/local/share/zsh/site-functions ] || (sudo mkdir -p /usr/local/share/zsh/site-functions && sudo chmod 777 /usr/local/share/zsh/site-functions)
2021-11-29 08:07:17 +00:00
# Install homebrew
2025-09-07 06:19:23 +01:00
echo ""
2025-06-06 09:57:01 +02:00
echo "🔵 Installing homebrew"
2021-11-29 08:07:17 +00:00
which brew >/dev/null || /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
2025-09-07 06:19:23 +01:00
echo "✅"
2021-11-29 08:07:17 +00:00
# Install oh-my-zsh
2025-09-07 06:19:23 +01:00
echo ""
2025-06-06 09:57:01 +02:00
echo "🔵 Setting up zsh"
2021-11-29 08:07:17 +00:00
printf "Cloning oh-my-zsh..."
2021-12-03 17:12:52 +00:00
[ -d ${HOME}/.oh-my-zsh ] || sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
2021-11-29 08:07:17 +00:00
printf " ✅\n"
# Install ZSH plugins
printf "Cloning zsh plugins..."
2021-12-03 17:12:52 +00:00
[ -d ${ZSH_CUSTOM:-${HOME}/.oh-my-zsh/custom}/plugins/zsh-autosuggestions ] || git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-${HOME}/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
[ -d ${ZSH_CUSTOM:-${HOME}/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting ] || git clone https://github.com/zsh-users/zsh-syntax-highlighting ${ZSH_CUSTOM:-${HOME}/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
2021-11-29 08:07:17 +00:00
printf " ✅\n"
2022-09-09 07:31:06 +01:00
# Set correct permissions on compinit dir
sudo chmod -R 755 /usr/local/share/zsh/site-functions
2021-11-29 08:07:17 +00:00
# Install tools
BREW_TOOLS=(
2022-09-10 19:44:22 +01:00
git argocd bandwhich bat danielfoehrkn/switch/switch derailed/k9s/k9s
2025-09-06 17:14:17 +01:00
dive doggo duf dust eza fd fzf git-delta go helm htop jq kind krew curl
2024-02-20 08:50:40 +00:00
kubectl kustomize node procs progress ripgrep rs/tap/curlie rust starship
2025-06-06 09:57:01 +02:00
tektoncd/tools/tektoncd-cli tldr tailscale yq tabby vale jless macchina tz viddy
homeassistant-cli act dnsmasq gh kubebuilder golangci-lint gnu-sed s3cmd
2025-06-10 14:55:14 +01:00
pulumi/tap/pulumi kubeseal fluxcd/tap/flux ical-buddy baobab
2025-06-06 09:57:01 +02:00
watch crane openssh siderolabs/talos/talosctl civo/tools/civo raspberry-pi-imager
gron ssup2/tap/kpexec opentofu visual-studio-code 1password-cli scw smartmontools
firefox signal slack ffmpeg openscad tsh colima docker docker-buildx nordvpn
2025-09-06 18:23:36 +01:00
1password tailscale-app
2021-11-29 08:07:17 +00:00
)
2022-09-09 08:58:02 +01:00
# Brew tools only available / needed on Mac
2022-09-18 11:18:44 +01:00
MAC_BREW_TOOLS=(
2025-09-06 17:14:17 +01:00
pinentry-mac gpg gawk coreutils wget stats font-open-dyslexic-nerd-font
2025-09-07 07:05:44 +01:00
dimentium/autoraise/autoraiseapp the-unarchiver rar mas capcut
2025-09-06 18:24:34 +01:00
mqtt-explorer raycast bettertouchtool calibre kdenlive royal-tsx tableplus
2025-09-07 06:56:58 +01:00
homebrew/cask/todoist ultimaker-cura webtorrent pika pearcleaner spotmenu
2025-12-30 08:57:55 +00:00
jordanbaird-ice utm TheBoredTeam/boring-notch/boring-notch
2022-09-18 11:18:44 +01:00
)
2022-03-04 14:05:47 +00:00
CARGO_TOOLS=( bottom )
2021-11-29 08:07:17 +00:00
NODE_TOOLS=( git-split-diffs )
2025-09-06 17:14:17 +01:00
KREW_TOOLS=( outdated tree stern explore blame access-matrix cert-manager rbac-tool resource-capacity view-secret )
2022-09-09 07:31:06 +01:00
APT_TOOLS=( zsh gcc )
MAS_TOOLS=(
1263070803 # Lungo
1470584107 # Dato
2025-09-07 06:47:16 +01:00
1351639930 # Gifski
)
2021-11-29 08:07:17 +00:00
2025-09-07 06:19:23 +01:00
# Tools removed to be cleaned up
REMOVED_BREW_TOOLS=(
2025-09-07 07:05:44 +01:00
exa karabiner-elements kubectx hiddenbar
2025-09-07 06:19:23 +01:00
)
REMOVED_KREW_TOOLS=( gs )
echo ""
2021-11-29 08:07:17 +00:00
echo "🔵 Installing / updating tools"
2022-09-09 07:31:06 +01:00
# Install Debian/Ubuntu specific packages if apt exists
if command -v apt &>/dev/null; then
2022-09-09 08:40:27 +01:00
echo "'apt' found on system, assuming Ubuntu/Debian and installing pre-requisites..."
2022-09-09 07:31:06 +01:00
sudo apt install -y ${APT_TOOLS}
fi
2021-11-29 08:07:17 +00:00
# Homebrew
2025-09-07 06:19:23 +01:00
echo ""
2025-09-06 17:14:17 +01:00
echo "🔵 Homebrew tools"
2021-11-29 08:07:17 +00:00
export HOMEBREW_NO_INSTALL_CLEANUP=true
for tool in "${BREW_TOOLS[@]}"
do
printf "${tool}..."
brew upgrade ${tool} &>/dev/null || brew install ${tool} &>/dev/null
2022-09-09 07:04:34 +01:00
if [ $? -eq 0 ]; then
printf " ✅\n"
else
printf " ❌\n"
fi
2021-11-29 08:07:17 +00:00
done
# Cargo
2025-09-07 06:19:23 +01:00
echo ""
2025-09-06 17:14:17 +01:00
echo "🔵 Cargo tools"
2021-11-29 08:07:17 +00:00
for tool in "${CARGO_TOOLS[@]}"
do
printf "${tool}..."
cargo install ${tool} &>/dev/null
2022-09-09 07:04:34 +01:00
if [ $? -eq 0 ]; then
printf " ✅\n"
else
printf " ❌\n"
fi
2021-11-29 08:07:17 +00:00
done
# Krew
2025-09-07 06:19:23 +01:00
echo ""
2025-09-06 17:14:17 +01:00
echo "🔵 Krew tools"
2021-11-29 08:07:17 +00:00
kubectl-krew update &>/dev/null
for tool in "${KREW_TOOLS[@]}"
do
printf "${tool}..."
kubectl-krew upgrade ${tool} &>/dev/null || kubectl-krew install ${tool} &>/dev/null
2022-09-09 07:04:34 +01:00
if [ $? -eq 0 ]; then
printf " ✅\n"
else
printf " ❌\n"
fi
2021-11-29 08:07:17 +00:00
done
2021-12-03 17:12:52 +00:00
fulllink() {
if [ ! -z `which greadlink` ]
then
greadlink -f $1
2021-12-03 18:20:33 +00:00
else
2021-12-03 17:12:52 +00:00
readlink -f $1
fi
}
2021-11-29 08:07:17 +00:00
2025-09-07 06:19:23 +01:00
echo ""
2021-11-29 08:07:17 +00:00
echo "🔵 OS Specific setup"
echo "Detected OS type: ${OSTYPE}"
case "${OSTYPE}" in
*linux*)
2022-09-09 07:31:06 +01:00
# Do stuff
2021-11-29 08:07:17 +00:00
;;
*darwin*)
# Mac specific setup
2025-09-07 06:19:23 +01:00
echo ""
echo "Instaling Mac-specific Brew tools..."
2021-11-29 08:07:17 +00:00
for tool in "${MAC_BREW_TOOLS[@]}"
do
printf "${tool}..."
brew upgrade ${tool} &>/dev/null || brew install ${tool} &>/dev/null
2022-09-09 07:04:34 +01:00
if [ $? -eq 0 ]; then
printf " ✅\n"
else
printf " ❌\n"
fi
2021-11-29 08:07:17 +00:00
done
2021-12-03 18:20:33 +00:00
# Mac App Store
2025-09-07 06:19:23 +01:00
echo ""
echo "Instaling Mac-specific App Store tools..."
for tool in "${MAS_TOOLS[@]}"
do
printf "MAS ID: ${tool}..."
mas install ${tool} &>/dev/null
if [ $? -eq 0 ]; then
printf " ✅\n"
else
printf " ❌\n"
fi
done
2021-11-29 08:07:17 +00:00
2025-09-07 06:19:23 +01:00
echo ""
echo "Setting up config files"
2021-12-24 10:29:45 +00:00
FILES=$(/usr/bin/find ./os-specific/darwin/home -maxdepth 1 -mindepth 1 | tr '\n' ' ')
2021-11-29 08:07:17 +00:00
for file in $FILES
do
2021-12-03 17:12:52 +00:00
f=$(fulllink "${file}")
dst="${HOME}/$(basename "./os-specific/darwin/home/${file}")"
printf "Linking ${f}=>${dst}"
ln -sfn ${f} ${dst}
2021-11-29 08:07:17 +00:00
printf " ✅\n"
done
2021-12-03 17:12:52 +00:00
[ -f "/usr/local/bin/pinentry-mac" ] || sudo ln -s `which pinentry-mac` /usr/local/bin/pinentry-mac
gpgconf --kill gpg-agent
if [ $(gpg --list-secret-keys --keyid-format=long 2>/dev/null | wc -l | xargs) -eq 0 ]; then
echo "⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️"
echo "⚠️ You'll need to create a new GPG key ⚠️"
echo "⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️"
fi
2022-01-09 14:28:57 +00:00
# Handle other files outside of the user's home directory
2025-09-07 06:19:23 +01:00
echo ""
2025-09-06 17:14:17 +01:00
echo "🔵 Handiling non-standard files:"
2022-01-09 14:28:57 +00:00
# 1. Tabby config
2025-09-06 17:14:17 +01:00
mkdir -p "/Users/${USER}/Library/Application Support/tabby"
2022-01-09 19:03:45 +00:00
f=$(fulllink "./other-files/tabby/config.yaml")
dst="/Users/${USER}/Library/Application Support/tabby/config.yaml"
2022-01-09 14:28:57 +00:00
printf "Linking ${f}=>${dst}"
2025-09-06 17:14:17 +01:00
ln -sfn "${f}" "${dst}"
2022-01-09 14:28:57 +00:00
printf " ✅\n"
2022-08-15 16:33:30 +01:00
# 2. dnsmasq
f=$(fulllink "./other-files/dnsmasq/dnsmasq.conf")
dst="$(brew --prefix)/etc/dnsmasq.conf"
printf "Copying ${f}=>${dst}"
cp ${f} ${dst}
printf " ✅\n"
printf "Setting DNS server for 'Wi-Fi' interface to use dnsmasq"
sudo networksetup -setdnsservers "Wi-Fi" 127.0.0.1
printf " ✅\n"
2021-11-29 08:07:17 +00:00
;;
esac
2021-12-03 17:12:52 +00:00
2025-09-07 06:19:23 +01:00
echo ""
2021-12-03 17:12:52 +00:00
echo "🔵 Adding configuration"
2021-12-24 10:29:45 +00:00
FILES=$(/usr/bin/find ./home -maxdepth 1 -mindepth 1 | tr '\n' ' ')
2021-12-03 17:12:52 +00:00
for file in $FILES
do
f=$(fulllink "${file}")
dst="${HOME}/$(basename "./home/${file}")"
2021-12-24 10:29:45 +00:00
printf "Linking ${f} => ${dst}"
2021-12-03 17:12:52 +00:00
ln -sfn ${f} ${dst}
printf " ✅\n"
2021-12-03 18:20:33 +00:00
done
2025-09-07 06:19:23 +01:00
echo ""
echo "🔵 Updating installed tools..."
brew upgrade
mas upgrade
echo ""
echo "🔵 Removing old Homebrew tools"
export HOMEBREW_NO_INSTALL_CLEANUP=true
for tool in "${REMOVED_BREW_TOOLS[@]}"
do
printf "${tool}..."
brew uninstall ${tool} &>/dev/null
if [ $? -eq 0 ]; then
printf " ✅\n"
else
printf " ❌\n"
fi
done
echo ""
echo "🔵 Removing old Krew tools"
for tool in "${REMOVED_KREW_TOOLS[@]}"
do
printf "${tool}..."
kubectl-krew uninstall ${tool} &>/dev/null
if [ $? -eq 0 ]; then
printf " ✅\n"
else
printf " ❌\n"
fi
done