Skip to content

Instantly share code, notes, and snippets.

@sidarta-luizalabs
Last active September 17, 2018 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sidarta-luizalabs/e4e110d6b0173fb618864624d7a03b5a to your computer and use it in GitHub Desktop.
Save sidarta-luizalabs/e4e110d6b0173fb618864624d7a03b5a to your computer and use it in GitHub Desktop.
#!/bin/bash
function install_packages() {
packages=( $@ )
sudo apt update
sudo apt install --no-install-recommends -y ${packages[@]}
}
function create_dir() {
dir_list=( $@ )
for dir in ${dir_list[@]};
do
if ! [[ -d ${dir} ]]; then
mkdir ${dir};
fi;
done;
}
function clone_repos() {
repo_list=( $@ )
for repo in ${repo_list[@]};
do
if ! [[ -d ~/repo/`basename ${repo%%.git}` ]]; then
git clone https://github.com/${repo} ~/repo/`basename ${repo%%.git}`
fi;
done
}
function create_bin_link() {
links=( $@ )
for lnk in ${links[@]};
do
if ! [[ -e ~/bin/`basename ${lnk}` ]]; then
ln -s ${lnk} ~/bin/`basename ${lnk}`
fi;
done
}
function install_kubectl() {
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo touch /etc/apt/sources.list.d/kubernetes.list
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl
}
# initial dir
create_dir ~/repo/ ~/bin/ ~/tmp/ ~/.kube/
# install some packages
install_packages apt-transport-https gnupg2 zsh htop git vim tcpdump strace tmux make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev
# useful toos
clone_repos "heptiolabs/ktx.git" \
"ahmetb/kubectx.git" \
"jonmosco/kube-ps1.git" \
"junegunn/fzf.git" \
"pyenv/pyenv.git"
# zsh
export ZSH="$HOME/repo/oh-my-zsh"; sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# fixing PATH var
sed -i '/^# export PATH=*/s/^#//' .zshrc
# kube-ps1
echo -e "source ~/repo/kube-ps1/kube-ps1.sh\nPROMPT='\$(kube_ps1)'\$PROMPT" >> .zshrc
# fzf
~/repo/fzf/install --all
# installing kubectl
install_kubectl
# symlinks
create_bin_link ~/repo/ktx/ktx ~/repo/kubectx/kubens
# reloading configs
sudo chsh -s /bin/zsh ${USER}
zsh
@sidarta-luizalabs
Copy link
Author

sidarta-luizalabs commented Sep 17, 2018

TODO

change this shell to a ansible playbook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment