-
Notifications
You must be signed in to change notification settings - Fork 2
/
bootstrap.sh
98 lines (81 loc) · 2.71 KB
/
bootstrap.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
#!/bin/bash
# Bootstrap machine
ENV_HOME="/home/vagrant/"
ENV_BASHRC="${ENV_HOME}.bashrc"
ENV_PROFILE="${ENV_HOME}.profile"
ENV_BIN="${ENV_HOME}bin/"
ENV_KUBELOC="${ENV_HOME}.kube/"
step=1
step() {
echo "Step $step $1"
step=$((step+1))
}
## Update package manager zypper
update_zypper() {
step "===== Updating zypper ====="
sudo zypper ar --refresh https://download.opensuse.org/repositories/devel:/languages:/go/openSUSE_Leap_15.2/ devel # Add repo to install golang
sudo zypper ar --refresh https://download.opensuse.org/repositories/system:/snappy/openSUSE_Leap_15.2 snappy
sudo zypper mr -p 70 devel snappy
sudo zypper --gpg-auto-import-keys refresh
}
install_golang() {
sudo zypper install -y go1.15
}
##Installing docker
install_docker() {
step "===== Installing Docker ====="
sudo zypper install -y docker python3-docker-compose
sudo systemctl enable docker
sudo usermod -G docker -a vagrant
sudo systemctl restart docker
newgrp docker
}
install_go() {
step "===== Installing GO ====="
sudo zypper in -y go1.15
}
install_git() {
step "===== Installing Git ====="
sudo zypper install -y git
}
install_pip_flask(){
step "===== Installing Pip and Flask ====="
sudo zypper install -y python3-pip
sudo pip3 install --upgrade pip
sudo pip install flask
}
modify_bashrc() {
step "===== Updating ~/.bashrc ====="
# Making bin files executable
chmod +x "${ENV_BIN}"/*
# Modifying ~/.bashrc
echo "set -o vi" >> "${ENV_BASHRC}"
echo "source /usr/share/bash-completion/bash_completion && source <(kubectl completion bash)" >> "${ENV_BASHRC}"
echo 'alias k=kubectl' >> "${ENV_BASHRC}"
echo 'complete -F __start_kubectl k' >> "${ENV_BASHRC}"
echo "source /usr/share/bash-completion/bash_completion && source <(helm completion bash)" >> "${ENV_BASHRC}"
echo "source /usr/share/bash-completion/bash_completion && source <(kind completion bash)" >> "${ENV_BASHRC}"
}
# Modify ~/.profile to start kind cluster if my-kubeconfig file does not exist
modify_profile() {
step "===== Updating ~/.profile ===="
echo "if [ ! -f ~/.kube/my-kubeconfig ]; then" >> ${ENV_PROFILE}
echo "kind create cluster --name my-kube-cluster --kubeconfig ${ENV_HOME}.kube/my-kubeconfig" >> "${ENV_PROFILE}"
echo "export KUBECONFIG=${ENV_KUBELOC}my-kubeconfig" >> "${ENV_PROFILE}"
echo "else" >> "${ENV_PROFILE}"
echo "echo '===== Kubernetes Cluster Already Initiated ====='" >> "${ENV_PROFILE}"
echo "fi" >> "${ENV_PROFILE}"
}
main() {
update_zypper
install_docker
install_go
install_git
install_pip_flask
modify_bashrc
modify_profile
echo ==========
echo "All DONE"
echo ==========
}
main