-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·134 lines (105 loc) · 4.64 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/env bash
# Elevate to sudo and run commands as current user
if [[ "$EUID" != 0 ]]; then
sudo "$0" "$@" --user="$(whoami)" --set-home
exit $?
fi
user="$SUDO_USER"
setupDir=""
configDir="$(realpath $(dirname $0))/configurations"
scriptsDir="$(realpath $(dirname $0))/scripts"
green='\033[0;32m'
noColor='\033[0m'
action () {
echo -e "${green}TOOLS SETUP:${noColor} $1..."
}
cleanup () {
action "Removing unused packages"
apt autoremove -f -y
action "Removing temporary folder for setting up tools"
rm -rfv "$setupDir"
}
setup () {
setupDir="$(mktemp -d)"
action "Created temporary folder for setting up tools at $setupDir"
action "Running apt-get update"
apt-get -y update
action "Installing curl, wget, python3, and vim"
apt-get -y install curl wget python3 vim
action "Installing zsh and oh-my-zsh"
apt-get -y install zsh
RUNZSH=no sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
action "Symlinking zsh configurations"
ln -fs "$configDir"/.zshrc ~/.zshrc
action "Symlinking vim configurations"
ln -fs "$configDir"/.vimrc ~/.vimrc
ln -fs "$configDir"/.vim/* ~/.vim/
action "Symlinking tmux configurations"
ln -fs "$configDir"/.tmux.conf ~/.tmux.conf
action "Symlinking git configurations"
ln -fs "$configDir"/.gitconfig ~/.gitconfig
ln -fs "$configDir"/.gitignore-global ~/.gitignore-global
git config --global core.excludesfile ~/.gitignore-global
action "Installing fuzzy finder"
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
pushd ~
.fzf/install --all
popd
action "Installing The Silver Searcher"
apt-get -y install silversearcher-ag
action "Installing Golang 1.13.8"
wget -O "$setupDir/golang.tar.gz" https://dl.google.com/go/go1.13.8.linux-amd64.tar.gz
tar -xzf "$setupDir/golang.tar.gz" -C /usr/local/
action "Installing latest NodeJS"
pushd "$setupDir"
"$scriptsDir/install-latest-node.sh"
popd
action "Configuring NPM"
mkdir "$HOME/.npm-packages"
npm config set prefix "$HOME/.npm-packages"
action "Installing Java 13.0.2"
wget -O "$setupDir/jdk.tar.gz" https://github.com/AdoptOpenJDK/openjdk13-binaries/releases/download/jdk-13.0.2+8/OpenJDK13U-jdk_x64_linux_hotspot_13.0.2_8.tar.gz
mkdir -p /usr/local/jdk
tar -xzf "$setupDir/jdk.tar.gz" -C /usr/local/jdk --strip-components 1
action "Installing python3-distutils" # Need this to get pip
apt-get install -y python3-distutils
action "Installing latest Pip"
curl https://bootstrap.pypa.io/get-pip.py -o "$setupDir/get-pip.py"
python3 "$setupDir/get-pip.py"
action "Installing pynvim" # Makes deoplete plugin for vim work
pip3 install --user pynvim
action "Installing vim-plug"
curl -fLo "$HOME/.vim/autoload/plug.vim" --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
action "Installing vim plugins"
vim +PlugInstall +qa
action "Ensuring all home files are owned by $user"
find "$HOME" -maxdepth 1 -name ".*" | xargs -I {} chown -R "$user:$user" {}
if [[ ! -x "$(command -v docker)" ]]; then
action "docker not present. Installing docker"
# Ensure clean installation
apt-get -y remove docker docker-engine docker.io containerd runc
apt-get -y install apt-transport-https ca-certificates gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get -y update
apt-get -y install docker-ce docker-ce-cli containerd.io
fi
if [[ ! -x "$(command -v k3d)" ]]; then
action "k3d not present. Installing k3d"
wget -q -O - https://raw.githubusercontent.com/rancher/k3d/master/install.sh | bash
fi
if [[ ! -x "$(command -v kubectl)" ]]; then
action "kubectl not present. Installing kubectl"
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
fi
if [[ ! -x "$(command -v helm)" ]]; then
action "helm not present. Installing helm"
wget -O "$setupDir/helm.tar.gz" https://get.helm.sh/helm-v3.2.1-linux-amd64.tar.gz
mkdir "$setupDir/helm-contents"
tar -xzf "$setupDir/helm.tar.gz" -C "$setupDir/helm-contents" --strip-components 1
cp -v "$setupDir/helm-contents/helm" "/usr/local/bin/helm"
fi
}
################## Script execution ##################
setup
cleanup