Skip to content

Instantly share code, notes, and snippets.

@kuznero
Last active September 26, 2022 07:42
Show Gist options
  • Save kuznero/03a741b40304abc4a2fe7d3d44ea079a to your computer and use it in GitHub Desktop.
Save kuznero/03a741b40304abc4a2fe7d3d44ea079a to your computer and use it in GitHub Desktop.
Install Tools
#!/usr/bin/env bash
TARGET_PATH=/usr/local/bin
function report() {
NAME=$1
VERSION=$2
VERSION=$(tr -d v <<< "${VERSION}")
printf "$(tput setaf 2)%12s$(tput sgr0) :: $(tput setaf 3)%s$(tput sgr0)\n" "${NAME}" "${VERSION}"
}
function update_apt_packages() {
sudo apt update
sudo apt upgrade -y
sudo apt list --upgradable 2>/dev/null | \
grep -v Listing | \
awk -F'/' '{print $1}' | \
xargs -I {} sudo apt install -y {}
sudo apt auto-remove -y
}
function update_snap_packages() {
sudo snap refresh
}
function install_common() {
sudo apt install -y \
build-essential \
curl \
neovim \
zsh \
tmux \
jq \
openssl \
unzip
# sudo chsh -s /usr/bin/zsh
# chsh -s /usr/bin/zsh
}
function install_bitwarden() {
sudo snap install bitwarden
}
function install_pcloud() {
sudo add-apt-repository -y universe
sudo apt install -y libfuse2
PCLOUD_URL=$(curl -s $(curl -s https://www.pcloud.com/release-notes/linux.html | grep Download | grep '<div clas="vers">' | head -n 1 | awk -F'href="' '{print $2}' | awk -F'"' '{print $1}') | grep downloadlink | awk -F'"' '{print $4}' | sed 's/\\\//\//g')
curl -sSL "${PCLOUD_URL}" -o /tmp/pcloud
chmod 0755 /tmp/pcloud
sudo mv -v /tmp/pcloud "${TARGET_PATH}/pcloud"
report "pcloud" ""
}
function install_chrome() {
curl -sSL https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -o /tmp/google-chrome-stable_current_amd64.deb
sudo dpkg -i /tmp/google-chrome-stable_current_amd64.deb
rm -f /tmp/google-chrome-stable_current_amd64.deb
report "chrome" ""
}
function install_bcompare() {
curl -sSL https://www.scootersoftware.com/bcompare-4.4.3.26655_amd64.deb -o /tmp/bcompare.deb
sudo dpkg -i /tmp/bcompare.deb
rm -f /tmp/bcompare.deb
report "bcompare" ""
}
function install_golang() {
TGZ_FILE=$(curl -sl https://go.dev/dl/ | grep "linux-amd64.tar.gz" | head -n 1 | awk -F'/' '{print $NF}' | tr -d '">')
curl -sSL "https://go.dev/dl/${TGZ_FILE}" -o "/tmp/${TGZ_FILE}"
pushd /tmp 2>&1 >/dev/null
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf "${TGZ_FILE}"
popd 2>&1 >/dev/null
rm -f "/tmp/${TGZ_FILE}"
[ "$(grep -c "/usr/local/go/bin" /etc/profile)" == "0" ] && bash -c 'echo "export PATH=\$PATH:/usr/local/go/bin" | sudo tee --append /etc/profile'
report "golang" ""
}
function install_dotnet() {
sudo apt install -y \
dotnet6 dotnet-sdk-6.0 \
dotnet-runtime-6.0 aspnetcore-runtime-6.0
report "dotnet" ""
}
function install_vscode() {
sudo apt install -y software-properties-common apt-transport-https wget
wget -O- https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor | sudo tee /usr/share/keyrings/vscode.gpg
echo deb [arch=amd64 signed-by=/usr/share/keyrings/vscode.gpg] https://packages.microsoft.com/repos/vscode stable main | sudo tee /etc/apt/sources.list.d/vscode.list
sudo apt update
sudo apt install -y code
code --install-extension DavidAnson.vscode-markdownlint
code --install-extension EditorConfig.EditorConfig
code --install-extension alefragnani.Bookmarks
code --install-extension bierner.markdown-mermaid
code --install-extension dbaeumer.vscode-eslint
code --install-extension emmanuelbeziat.vscode-great-icons
code --install-extension esbenp.prettier-vscode
code --install-extension golang.go
code --install-extension humao.rest-client
code --install-extension mhutchie.git-graph
code --install-extension mikestead.dotenv
code --install-extension ms-azuretools.vscode-docker
code --install-extension ms-kubernetes-tools.vscode-kubernetes-tools
code --install-extension mutantdino.resourcemonitor
code --install-extension paulosouza.matrix-revolution-color-theme
code --install-extension redhat.vscode-tekton-pipelines
code --install-extension redhat.vscode-yaml
code --install-extension shardulm94.trailing-spaces
code --install-extension tamasfe.even-better-toml
code --install-extension timonwong.shellcheck
code --install-extension vscodevim.vim
mkdir -p ~/.config/Code/User
cat <<'EOF' > ~/.config/Code/User/keybindings.json
[
{
"key": "alt+-",
"command": "workbench.action.terminal.toggleTerminal"
},
{
"key": "ctrl+`",
"command": "-workbench.action.terminal.toggleTerminal"
},
{
"key": "alt+=",
"command": "workbench.action.toggleMaximizedPanel"
},
{
"key": "alt+d",
"command": "editor.action.addSelectionToNextFindMatch",
"when": "editorFocus"
},
{
"key": "ctrl+d",
"command": "-editor.action.addSelectionToNextFindMatch",
"when": "editorFocus"
},
{
"key": "ctrl+alt+.",
"command": "bookmarks.listFromAllFiles"
},
{
"key": "alt+/",
"command": "workbench.action.toggleSidebarVisibility"
},
{
"key": "ctrl+b",
"command": "-workbench.action.toggleSidebarVisibility"
},
{
"key": "alt+e",
"command": "workbench.view.explorer"
},
{
"key": "ctrl+shift+e",
"command": "-workbench.view.explorer"
},
{
"key": "ctrl+shift+/",
"command": "workbench.files.action.collapseExplorerFolders"
},
{
"key": "ctrl+alt+f",
"command": "explorer.newFile"
},
{
"key": "ctrl+alt+d",
"command": "explorer.newFolder"
},
{
"key": "ctrl+shift+0",
"command": "prettier.forceFormatDocument"
}
]
EOF
mkdir -p ~/.config/Code/User
cat <<'EOF' > ~/.config/Code/User/settings.json
{
"editor.cursorBlinking": "smooth",
"editor.cursorSmoothCaretAnimation": true,
"editor.cursorStyle": "line",
"editor.fontFamily": "'MesloLGS NF', Iosevka, 'Source Code Pro', 'Cascadia Mono', 'JetBrains Mono', monospace",
"editor.fontLigatures": true,
"editor.fontSize": 14,
"editor.fontWeight": "400",
"editor.formatOnSave": false,
"editor.lineNumbers": "relative",
"editor.minimap.enabled": false,
"editor.renderLineHighlight": "gutter",
"editor.tabSize": 2,
"editor.wordSeparators": "/\\()\"':,.;<>~!@#$%^&*|+=[]{}`?-",
"editor.wordWrap": "off",
"explorer.confirmDragAndDrop": false,
"extensions.ignoreRecommendations": true,
"extensions.autoCheckUpdates": true,
"redhat.telemetry.enabled": false,
"telemetry.telemetryLevel": "off",
"terminal.integrated.fontFamily": "'MesloLGS NF', Iosevka, 'Source Code Pro', 'Cascadia Mono', 'JetBrains Mono', monospace",
"terminal.integrated.fontSize": 14,
"terminal.integrated.fontWeight": "400",
"terminal.integrated.fontWeightBold": "400",
"terminal.integrated.tabs.enabled": true,
"todo-tree.general.tags": [
"BUG",
"HACK",
"FIXME",
"TODO",
"XXX",
"[ ]",
"[x]"
],
"todo-tree.regex.regex": "(//|#|<!--|;|/\\*|^|^\\s*(-|\\d+.))\\s*($TAGS)",
"vsicons.dontShowNewVersionMessage": true,
"window.menuBarVisibility": "toggle",
"workbench.colorTheme": "Matrix Revolution Color Theme",
"workbench.editor.enablePreview": false,
"workbench.iconTheme": "vscode-great-icons",
"workbench.startupEditor": "none",
"[yaml]": {
"editor.defaultFormatter": "redhat.vscode-yaml"
},
"go.toolsManagement.autoUpdate": true,
"markdown.preview.fontSize": 14,
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true
},
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"window.zoomLevel": 1
}
EOF
report "vscode" ""
}
function install_rider() {
sudo snap install rider --classic
report "rider" ""
}
function install_docker() {
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
apt-cache policy docker-ce
sudo apt install -y docker-ce
sudo usermod -aG docker ${USER}
report "docker" ""
}
function install_slack() {
sudo snap install slack
report "slack" ""
}
function install_telegram() {
sudo snap install telegram-desktop
report "telegram" ""
}
function install_azure_cli() {
sudo apt update
sudo apt install -y ca-certificates curl apt-transport-https lsb-release gnupg
curl -sL https://packages.microsoft.com/keys/microsoft.asc | \
gpg --dearmor | \
sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null
AZ_REPO=$(lsb_release -cs)
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | \
sudo tee /etc/apt/sources.list.d/azure-cli.list
sudo apt update
sudo apt install -y azure-cli
report "az" ""
}
function update_kubectl() {
KUBECTL_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
curl -sSL "https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl" -o /tmp/kubectl
chmod 0755 /tmp/kubectl
sudo mv -v /tmp/kubectl "${TARGET_PATH}/kubectl" 2>&1 >/dev/null
report kubectl "${KUBECTL_VERSION}"
}
function update_helm() {
HELM_VERSION=$(curl -vs https://github.com/helm/helm/releases/latest 2>&1 | grep -i 'location:' | awk -F'tag/' '{print $NF}' | tr -d "\r")
curl -sSL "https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz" -o /tmp/helm.tar.gz
tar --directory /tmp/ -xzf /tmp/helm.tar.gz --strip-components 1 --add-file linux-amd64/helm
rm -f /tmp/helm.tar.gz 2>&1 >/dev/null
chmod 0755 /tmp/helm
sudo mv -v /tmp/helm "${TARGET_PATH}/helm" 2>&1 >/dev/null
report helm "${HELM_VERSION}"
}
function update_k9s() {
K9S_VERSION=$(curl -vs https://github.com/derailed/k9s/releases/latest 2>&1 | grep -i 'location:' | awk -F'tag/' '{print $2}' | tr -d "\r")
curl -sSL "https://github.com/derailed/k9s/releases/download/${K9S_VERSION}/k9s_Linux_x86_64.tar.gz" -o /tmp/k9s.tar.gz
tar --directory /tmp/ -xzf /tmp/k9s.tar.gz --add-file k9s
rm -f /tmp/k9s.tar.gz 2>&1 >/dev/null
chmod 0755 /tmp/k9s
sudo mv -v /tmp/k9s "${TARGET_PATH}/k9s" 2>&1 >/dev/null
report k9s "${K9S_VERSION}"
}
function update_popeye() {
POPEYE_VERSION=$(curl -vs https://github.com/derailed/popeye/releases/latest 2>&1 | grep -i 'location:' | awk -F'tag/' '{print $2}' | tr -d "\r")
curl -sSL "https://github.com/derailed/popeye/releases/download/${POPEYE_VERSION}/popeye_Linux_x86_64.tar.gz" -o /tmp/popeye.tar.gz
tar --directory /tmp/ -xzf /tmp/popeye.tar.gz --add-file popeye
rm -f /tmp/popeye.tar.gz 2>&1 >/dev/null
chmod 0755 /tmp/popeye
sudo mv -v /tmp/popeye "${TARGET_PATH}/popeye" 2>&1 >/dev/null
report popeye "${POPEYE_VERSION}"
}
function update_kubelogin() {
KUBELOGIN_VERSION=$(curl -vs https://github.com/Azure/kubelogin/releases/latest 2>&1 | grep -i 'location:' | awk -F'tag/' '{print $2}' | tr -d "\r")
curl -sSL "https://github.com/Azure/kubelogin/releases/download/${KUBELOGIN_VERSION}/kubelogin-linux-amd64.zip" -o /tmp/kubelogin-linux-amd64.zip
unzip -j /tmp/kubelogin-linux-amd64.zip bin/linux_amd64/kubelogin -d /tmp 2>&1 >/dev/null
rm -f /tmp/kubelogin-linux-amd64.zip 2>&1 >/dev/null
chmod 0755 /tmp/kubelogin
sudo mv -v /tmp/kubelogin "${TARGET_PATH}/kubelogin" 2>&1 >/dev/null
report kubelogin "${KUBELOGIN_VERSION}"
}
function update_kind() {
KIND_VERSION=$(curl -vs https://github.com/kubernetes-sigs/kind/releases/latest 2>&1 | grep -i 'location:' | awk -F'tag/' '{print $2}' | tr -d "\r")
curl -sSL "https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-linux-amd64" -o /tmp/kind
chmod 0755 /tmp/kind
sudo mv -v /tmp/kind "${TARGET_PATH}/kind" 2>&1 >/dev/null
report kind "${KIND_VERSION}"
}
function update_tkn() {
TKN_VERSION=$(curl -vs https://github.com/tektoncd/cli/releases/latest 2>&1 | grep -i 'location:' | awk -F'tag/' '{print $2}' | awk -F'v' '{print $2}' | tr -d "\r")
curl -sSL "https://github.com/tektoncd/cli/releases/download/v${TKN_VERSION}/tkn_${TKN_VERSION}_Linux_x86_64.tar.gz" -o /tmp/tkn.tar.gz
tar --directory /tmp/ -xzf /tmp/tkn.tar.gz --add-file tkn
rm -f /tmp/tkn.tar.gz 2>&1 >/dev/null
chmod 0755 /tmp/tkn
sudo mv -v /tmp/tkn "${TARGET_PATH}/tkn" 2>&1 >/dev/null
report tkn "${TKN_VERSION}"
}
function update_linkerd() {
LINKERD_VERSION=$(curl -s https://github.com/linkerd/linkerd2/tags | grep '\/tag\/stable-.*"' | grep -v '\-rc' | head -n 1 | awk -F'/' '{print $NF}' | awk -F'"' '{print $1}')
curl -sSL "https://github.com/linkerd/linkerd2/releases/download/${LINKERD_VERSION}/linkerd2-cli-${LINKERD_VERSION}-linux-amd64" -o /tmp/linkerd
chmod 0755 /tmp/linkerd
sudo mv -v /tmp/linkerd "${TARGET_PATH}/linkerd" 2>&1 >/dev/null
report linkerd "${LINKERD_VERSION}"
}
function update_flux() {
FLUX_VERSION=$(curl -vs https://github.com/fluxcd/flux2/releases/latest 2>&1 | grep -i 'location:' | awk -F'tag/' '{print $2}' | awk -F'v' '{print $2}' | tr -d "\r")
curl -sSL "https://github.com/fluxcd/flux2/releases/download/v${FLUX_VERSION}/flux_${FLUX_VERSION}_linux_amd64.tar.gz" -o /tmp/flux.tar.gz
tar --directory /tmp/ -xzf /tmp/flux.tar.gz --add-file flux
rm -f /tmp/flux.tar.gz 2>&1 >/dev/null
chmod 0755 /tmp/flux
sudo mv -v /tmp/flux "${TARGET_PATH}/flux" 2>&1 >/dev/null
report flux "${FLUX_VERSION}"
}
function update_cilium() {
CILIUM_VERSION=$(curl -vs https://github.com/cilium/cilium-cli/releases/latest 2>&1 | grep -i 'location:' | awk -F'tag/' '{print $2}' | awk -F'v' '{print $2}' | tr -d "\r")
curl -sSL "https://github.com/cilium/cilium-cli/releases/download/v${CILIUM_VERSION}/cilium-linux-amd64.tar.gz" -o /tmp/cilium.tar.gz
tar --directory /tmp/ -xzf /tmp/cilium.tar.gz --add-file cilium
rm -f /tmp/cilium.tar.gz 2>&1 >/dev/null
chmod 0755 /tmp/cilium
sudo mv -v /tmp/cilium "${TARGET_PATH}/cilium" 2>&1 >/dev/null
report cilium "${CILIUM_VERSION}"
}
function update_hubble() {
HUBBLE_VERSION=$(curl -vs https://github.com/cilium/hubble/releases/latest 2>&1 | grep -i 'location:' | awk -F'tag/' '{print $2}' | awk -F'v' '{print $2}' | tr -d "\r")
curl -sSL "https://github.com/cilium/hubble/releases/download/v${HUBBLE_VERSION}/hubble-linux-amd64.tar.gz" -o /tmp/hubble.tar.gz
tar --directory /tmp/ -xzf /tmp/hubble.tar.gz --add-file hubble
rm -f /tmp/hubble.tar.gz 2>&1 >/dev/null
chmod 0755 /tmp/hubble
sudo mv -v /tmp/hubble "${TARGET_PATH}/hubble" 2>&1 >/dev/null
report hubble "${HUBBLE_VERSION}"
}
function update_dive() {
DIVE_VERSION=$(curl -vs https://github.com/wagoodman/dive/releases/latest 2>&1 | grep -i 'location:' | awk -F'tag/' '{print $2}' | awk -F'v' '{print $2}' | tr -d "\r" | tr -d "v")
curl -sSL "https://github.com/wagoodman/dive/releases/download/v${DIVE_VERSION}/dive_${DIVE_VERSION}_linux_amd64.tar.gz" -o /tmp/dive.tar.gz
tar --directory /tmp/ -xzf /tmp/dive.tar.gz --add-file dive
rm -f /tmp/dive.tar.gz 2>&1 >/dev/null
chmod 0755 /tmp/dive
sudo mv -v /tmp/dive "${TARGET_PATH}/dive" 2>&1 >/dev/null
report dive "${DIVE_VERSION}"
}
function update_pulumi() {
PULUMI_VERSION=$(curl -vs https://github.com/pulumi/pulumi/releases/latest 2>&1 | grep -i 'location:' | awk -F'tag/' '{print $2}' | awk -F'v' '{print $2}' | tr -d "\r")
curl -sSL "https://github.com/pulumi/pulumi/releases/download/v${PULUMI_VERSION}/pulumi-v${PULUMI_VERSION}-linux-x64.tar.gz" -o /tmp/pulumi.tar.gz
tar --directory /tmp/ -xzf /tmp/pulumi.tar.gz --strip-components 1
rm -f /tmp/pulumi.tar.gz 2>&1 >/dev/null
chmod 0755 /tmp/pulumi*
sudo mv -v /tmp/pulumi* "${TARGET_PATH}/" 2>&1 >/dev/null
report pulumi "${PULUMI_VERSION}"
}
function update_trivy() {
TRIVY_VERSION=$(curl -vs https://github.com/aquasecurity/trivy/releases/latest 2>&1 | grep -i 'location:' | awk -F'tag/' '{print $2}' | tr -d "\r" | tr -d "v")
curl -sSL "https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz" -o /tmp/trivy.tar.gz
tar --directory /tmp/ -xzf /tmp/trivy.tar.gz --add-file trivy
rm -f /tmp/trivy.tar.gz 2>&1 >/dev/null
chmod 0755 /tmp/trivy
sudo mv -v /tmp/trivy "${TARGET_PATH}/trivy" 2>&1 >/dev/null
report trivy "${TRIVY_VERSION}"
}
update_apt_packages
update_snap_packages
install_common
[ ! $(command -v bitwarden) ] && install_bitwarden
[ ! $(command -v pcloud) ] && install_pcloud
[ ! $(command -v google-chrome) ] && install_chrome
[ ! $(command -v bcompare) ] && install_bcompare
[ ! -d /usr/local/go/bin ] && install_golang
[ ! $(command -v dotnet) ] && install_dotnet
[ ! $(command -v rider) ] && install_rider
[ ! $(command -v docker) ] && install_docker
[ ! $(command -v slack) ] && install_slack
[ ! $(command -v telegram-desktop) ] && install_telegram
[ ! $(command -v code) ] && install_vscode
[ ! $(command -v az) ] && install_azure_cli
update_kubectl
update_helm
update_k9s
update_popeye
update_kubelogin
update_kind
update_tkn
update_linkerd
update_flux
update_cilium
update_hubble
update_dive
update_pulumi
update_trivy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment