336 lines
9.9 KiB
Bash
Executable File
336 lines
9.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# shellcheck disable=2010,2045,2086,2155
|
|
|
|
# Path to the zsh folder
|
|
ZSHFOLDER=$HOME/.config/zsh
|
|
CONFIG="$HOME/.config"
|
|
|
|
# Colours
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;0;32m'
|
|
NC='\033[0m'
|
|
|
|
# Stable version
|
|
TERRAFORM_VERSION="1.5.7"
|
|
|
|
# Python
|
|
export PYTHONVERSION=$(ls -la /opt/homebrew/opt/ |
|
|
grep -iEo 'python@.* ->' |
|
|
sed 's/ ->//g' |
|
|
sort |
|
|
tail -n1 |
|
|
sed 's/python@//g')
|
|
python="/opt/homebrew/bin/python$PYTHONVERSION"
|
|
pip="/opt/homebrew/bin/pip$PYTHONVERSION"
|
|
|
|
PIPEXT="--user --force --quiet --break-system-packages --no-warn-script-location"
|
|
PIPEXTPRE="--pre $PIPEXT"
|
|
|
|
# Gentoo release
|
|
GENTOO="/etc/gentoo-release"
|
|
|
|
# if [[ "$(uname -r)" =~ "gentoo" || "$(uname -r)" =~ "WSL2" ]]; then
|
|
# PIPEXT="$PIPEXT --break-system-packages"
|
|
# PIPEXTPRE="$PIPEXTPRE --break-system-packages"
|
|
# fi
|
|
|
|
function timestamp() {
|
|
echo -e "${GREEN}[+]${NC} $(date +'%F %T') [INFO] $*"
|
|
}
|
|
|
|
function err() {
|
|
echo -e "${RED}[-] $(date +'%F %T') [ERROR] $*${NC}" >&2
|
|
}
|
|
|
|
function command_start() {
|
|
timestamp "Command $* has been started."
|
|
if ! "$*"; then
|
|
err "Command $* went wrong."
|
|
exit
|
|
fi
|
|
timestamp "Command $* has been ended."
|
|
}
|
|
|
|
function command_exists() {
|
|
if which "$1" > /dev/null 2>&1; then
|
|
timestamp "Command $1 has been found"
|
|
else
|
|
err "Command $1 has been NOT found"
|
|
exit 0
|
|
fi
|
|
}
|
|
|
|
function update_pip() {
|
|
# Update the pip
|
|
if [[ "$(uname)" == "Darwin" ]]; then
|
|
$python -m pip install --upgrade pip --user --break-system-packages
|
|
elif [[ -f $GENTOO ]]; then
|
|
sudo emerge dev-python/pip
|
|
fi
|
|
}
|
|
|
|
function install_neovim_module_for_python() {
|
|
# Python module in neovim
|
|
$pip install pynvim neovim imps $PIPEXTPRE
|
|
}
|
|
|
|
function install_pyright() {
|
|
# Install pyright
|
|
sudo npm -s -g i pyright --force
|
|
$pip install black $PIPEXTPRE
|
|
}
|
|
|
|
function install_bash-language-server() {
|
|
# Install bash-language-server
|
|
sudo npm -s -g i bash-language-server --force
|
|
}
|
|
|
|
function install_yaml-language-server() {
|
|
# Install yaml-language-server
|
|
sudo npm -s -g i yaml-language-server --force
|
|
}
|
|
|
|
function install_shfmt() {
|
|
# Install shfmt
|
|
GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt@latest
|
|
}
|
|
|
|
function install_lazy() {
|
|
# Install shfmt
|
|
GO111MODULE=on go install github.com/jesseduffield/lazygit@latest
|
|
GO111MODULE=on go install github.com/jesseduffield/lazydocker@latest
|
|
}
|
|
|
|
function install_terraform_stable() {
|
|
# Install terraform and terraform-ls
|
|
GO111MODULE=on go install github.com/hashicorp/terraform-ls@latest
|
|
|
|
if [[ "$(uname)" == "Darwin" ]]; then
|
|
brew install tflint -q
|
|
brew install tfenv -q
|
|
TFENV_ARCH=amd64 tfenv install "$TERRAFORM_VERSION"
|
|
tfenv use "$TERRAFORM_VERSION"
|
|
else
|
|
GO111MODULE=on go install github.com/hashicorp/terraform@v"$TERRAFORM_VERSION"
|
|
curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash
|
|
fi
|
|
}
|
|
|
|
function install_terraform() {
|
|
# Install terraform and terraform-ls
|
|
GO111MODULE=on go install github.com/hashicorp/terraform-ls@latest
|
|
if [[ "$(uname)" == "Darwin" ]]; then
|
|
brew install tflint -q
|
|
brew install tfenv -q
|
|
TFENV_ARCH=amd64 tfenv install latest
|
|
mapfile -t TFENV_VER_ARRAY < <(tfenv list | grep -ioE ' [0-9.]+' | sed -e '1,1d')
|
|
if [ "${#TFENV_VER_ARRAY[@]}" -gt "2" ]; then
|
|
for i in "${TFENV_VER_ARRAY[@]}"; do
|
|
tfenv uninstall "$i" && timestamp "Removed - terraform '$i' version"
|
|
done
|
|
fi
|
|
else
|
|
GO111MODULE=on go install github.com/hashicorp/terraform@latest
|
|
curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash
|
|
fi
|
|
}
|
|
|
|
function install_terragrunt() {
|
|
# Install terragrunt
|
|
if [[ "$(uname)" == "Darwin" ]]; then
|
|
brew install terragrunt -q
|
|
else
|
|
wget https://github.com/gruntwork-io/terragrunt/releases/latest/download/terragrunt_linux_amd64 -O $HOME/.local/bin/terragrunt
|
|
chmod +x $HOME/.local/bin/terragrunt
|
|
fi
|
|
}
|
|
|
|
function install_shellcheck() {
|
|
# Install shellcheck
|
|
if [[ "$(uname)" == "Darwin" ]]; then
|
|
brew install shellcheck -q
|
|
else
|
|
curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash
|
|
fi
|
|
}
|
|
|
|
function install_marksman() {
|
|
if [[ "$(uname)" == "Darwin" ]]; then
|
|
brew install marksman -q
|
|
else
|
|
wget https://github.com/artempyanykh/marksman/releases/latest/download/marksman-linux-x64 -O $HOME/.local/bin/marksman
|
|
chmod +x $HOME/.local/bin/marksman
|
|
fi
|
|
|
|
}
|
|
|
|
function install_go() {
|
|
# Install the golang
|
|
if [[ "$(uname)" == "Darwin" ]]; then
|
|
brew install golang -q
|
|
elif [[ -f $GENTOO ]]; then
|
|
sudo emerge dev-lang/go
|
|
fi
|
|
}
|
|
|
|
function install_gopls() {
|
|
# Install gopls
|
|
GO111MODULE=on go install golang.org/x/tools/gopls@latest
|
|
}
|
|
|
|
function install_black() {
|
|
# Install black
|
|
$pip install black $PIPEXTPRE
|
|
}
|
|
|
|
function install_ansible() {
|
|
# Install Ansible
|
|
$pip install ansible ansible-lint ansible-core $PIPEXTPRE
|
|
$pip install ansible-parallel $PIPEXTPRE
|
|
}
|
|
|
|
function install_ansible-language-server() {
|
|
# Install ansible-language-server
|
|
sudo npm -s -g i @ansible/ansible-language-server --force
|
|
sudo npm -s -g i yaml-language-server --force
|
|
}
|
|
|
|
function install_meraki_ansible() {
|
|
# Install python, ansible module for meraki
|
|
ansible-galaxy collection install cisco.meraki --force
|
|
$pip install meraki $PIPEXT
|
|
}
|
|
|
|
function install_azure_cli() {
|
|
# Install azure_cli
|
|
$pip install azure-cli $PIPEXTPRE
|
|
}
|
|
|
|
function install_awscli() {
|
|
# Install awscli
|
|
$pip install awscli $PIPEXTPRE
|
|
}
|
|
|
|
function install_aws_adfs() {
|
|
# Install aws-adfs
|
|
$pip install aws-adfs $PIPEXTPRE
|
|
}
|
|
|
|
function install_ytdlp() {
|
|
# Install yt-dlp
|
|
$pip install yt-dlp $PIPEXTPRE
|
|
}
|
|
|
|
function install_spotifydl() {
|
|
# Install spotify_dl
|
|
$pip install spotify_dl $PIPEXTPRE
|
|
}
|
|
|
|
function update() {
|
|
if [ -d $CONFIG/fzf ]; then
|
|
FOLDER="$CONFIG/fzf"
|
|
cd $FOLDER || err "Folder $FOLDER has been NOT found"
|
|
git pull -q && timestamp "Pulling the $FOLDER configuration"
|
|
else
|
|
FOLDER="$CONFIG/fzf"
|
|
git clone https://github.com/junegunn/fzf.git $FOLDER && timestamp "Cloning the FZF"
|
|
git pull -q && timestamp "Pulling the $FOLDER configuration"
|
|
fi
|
|
|
|
if [ ! -d $ZSHFOLDER/aws ]; then
|
|
curl -s https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/aws/aws.plugin.zsh \
|
|
-o "$ZSHFOLDER"/aws/aws.plugin.zsh &&
|
|
timestamp "Downloaded the newest version of aws plugin for zsh"
|
|
|
|
curl -s https://raw.githubusercontent.com/Azure/azure-cli/dev/az.completion \
|
|
-o "$ZSHFOLDER"/azure-cli/az.completion &&
|
|
timestamp "Downloaded the newest version of az plugin for zsh"
|
|
|
|
mkdir -p "$ZSHFOLDER/azure-cli" "$ZSHFOLDER/aws"
|
|
cd $ZSHFOLDER || err "Folder $ZSHFOLDER has been NOT found"
|
|
git clone https://github.com/popstas/zsh-command-time.git &&
|
|
timestamp "Cloning the zsh-command-time"
|
|
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git &&
|
|
timestamp "Cloning the zsh-syntax-highlighting"
|
|
git clone https://github.com/zsh-users/zsh-autosuggestions.git &&
|
|
timestamp "Cloning the zsh-autosuggestions"
|
|
fi
|
|
|
|
for i in $(ls $ZSHFOLDER); do
|
|
FOLDER="$ZSHFOLDER/$i"
|
|
if [ -d "$FOLDER/.git" ]; then
|
|
cd "$FOLDER" || err "Folder $FOLDER has been NOT found"
|
|
git pull -q && timestamp "Pulling the $FOLDER configuration"
|
|
fi
|
|
done
|
|
|
|
curl -s https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/aws/aws.plugin.zsh -o "$ZSHFOLDER"/aws/aws.plugin.zsh && timestamp "Downloaded the newest version of aws plugin for zsh"
|
|
curl -s https://raw.githubusercontent.com/Azure/azure-cli/dev/az.completion -o "$ZSHFOLDER"/azure-cli/az.completion && timestamp "Downloaded the newest version of az plugin for zsh"
|
|
|
|
}
|
|
|
|
function install_speedtest() {
|
|
# Install speedtest-cli
|
|
$pip install speedtest-cli $PIPEXTPRE
|
|
}
|
|
|
|
function install_gh_cli() {
|
|
if [[ "$(uname)" == "Darwin" ]]; then
|
|
brew install gh
|
|
elif [[ -f $GENTOO ]]; then
|
|
sudo emerge dev-util/github-cli
|
|
fi
|
|
}
|
|
|
|
function install_kubernetes() {
|
|
echo -e "$(uname -r)"
|
|
if [[ "$(uname)" == "Darwin" ]]; then
|
|
wget "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/arm64/kubectl" -O $HOME/.local/bin/kubectl
|
|
chmod +x $HOME/.local/bin/kubectl
|
|
else
|
|
wget "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" -O $HOME/.local/bin/kubectl
|
|
chmod +x $HOME/.local/bin/kubectl
|
|
fi
|
|
}
|
|
|
|
function install_rust() {
|
|
if command_exists rustc; then
|
|
rustup update
|
|
else
|
|
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
|
|
fi
|
|
}
|
|
|
|
function main() {
|
|
command_start update_pip
|
|
command_start install_neovim_module_for_python
|
|
command_start install_go
|
|
command_start install_pyright
|
|
command_start install_lazy
|
|
command_start install_bash-language-server
|
|
command_start install_yaml-language-server
|
|
command_start install_ansible-language-server
|
|
command_start install_marksman
|
|
command_start install_shfmt
|
|
command_start install_shellcheck
|
|
command_start install_gopls
|
|
# command_start install_terraform
|
|
command_start install_terraform_stable
|
|
command_start install_terragrunt
|
|
command_start install_azure_cli
|
|
command_start install_black
|
|
command_start install_ansible
|
|
command_start install_meraki_ansible
|
|
command_start install_ytdlp
|
|
command_start install_spotifydl
|
|
command_start install_awscli
|
|
command_start install_aws_adfs
|
|
command_start install_speedtest
|
|
command_start install_gh_cli
|
|
command_start install_kubernetes
|
|
command_start install_rust
|
|
command_start update
|
|
}
|
|
|
|
main
|