This repository was archived by the owner on Mar 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathready
More file actions
executable file
·255 lines (223 loc) · 9.04 KB
/
ready
File metadata and controls
executable file
·255 lines (223 loc) · 9.04 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# https://raw.githubusercontent.com/Nikhil690/script/main/ready
#!/bin/bash
# Function for error handling
handle_error() {
echo "Error: $1"
exit 1
}
# Function for printing confirmation messages
print_confirmation() {
echo "$1 completed successfully."
}
# Function for updating package manager
update_package_manager() {
sudo apt update || handle_error "Failed to update package manager"
}
# Ensure consistent indentation
set -e
# Function to install Docker
install_docker() {
update_package_manager
if ! command -v docker &> /dev/null; then
sudo apt install -y docker.io || handle_error "Failed to install Docker"
sudo usermod -aG docker $USER || handle_error "Failed to add user to Docker group"
sudo chmod 666 /var/run/docker.sock || handle_error "Failed to set permissions for Docker socket"
print_confirmation "Docker installation"
else
echo "Docker is already installed"
fi
}
# Function to install Docker Compose
install_docker_compose() {
update_package_manager
if ! command -v "docker compose" &> /dev/null; then
while true; do
echo "Do you want to install Docker Compose plugin(p) / Docker compose standalone(s) or skip it? (p/s/any key)"
read answer
case "$answer" in
p)
if ! command docker compose &> /dev/null; then
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose || handle_error "Failed to download Docker Compose plugin"
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose || handle_error "Failed to set execute permission for Docker Compose plugin"
else
echo "Docker Compose plugin is already installed"
fi
print_confirmation "Docker Compose plugin installation"
break
;;
s)
if ! command docker-compose &> /dev/null; then
sudo curl -SL https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose || handle_error "Failed to download Docker Compose standalone"
sudo chmod +x /usr/local/bin/docker-compose || handle_error "Failed to set execute permission for Docker Compose standalone"
else
echo "Docker Compose standalone is already installed"
fi
print_confirmation "Docker Compose standalone installation"
break
;;
*)
echo "Skipping Docker Compose installation."
break
;;
esac
done
else
echo "Docker Compose is already installed"
fi
}
# Function to install Minikube
install_minikube() {
update_package_manager
if ! command -v minikube &> /dev/null; then
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 || handle_error "Failed to download Minikube"
sudo install minikube-linux-amd64 /usr/local/bin/minikube || handle_error "Failed to install Minikube"
rm -rf minikube* || handle_error "Failed to clean up Minikube installation files"
print_confirmation "Minikube installation"
else
echo "Minikube is already installed"
fi
}
# Function to install kubectl
install_kubectl() {
update_package_manager
if ! command -v kubectl &> /dev/null; then
sudo snap install kubectl --classic || handle_error "Failed to install kubectl"
print_confirmation "kubectl installation"
else
echo "kubectl is already installed"
fi
}
# Function to install net-tools
install_net_tools() {
update_package_manager
if ! command -v ifconfig &> /dev/null; then
sudo apt install -y net-tools || handle_error "Failed to install net-tools"
print_confirmation "net-tools installation"
else
echo "net-tools is already installed"
fi
}
# Function to install programming languages and tools
install_programming_languages() {
update_package_manager
sudo apt install -y golang clang llvm gcc-multilib libbpf-dev || handle_error "Failed to install programming languages and tools"
print_confirmation "Programming languages and tools installation"
}
# Function to install required tools
install_required_tools() {
update_package_manager
sudo apt install -y make || handle_error "Failed to install make"
sudo snap install cmake --classic || handle_error "Failed to install cmake"
print_confirmation "make installation"
}
# Function to install bpftool
install_bpftool() {
update_package_manager
kernel_version=$(uname -r)
sudo apt install -y linux-tools-$kernel_version || {
echo "Warning: Failed to install bpftool for kernel version $kernel_version"
return
}
print_confirmation "bpftool installation for kernel version $kernel_version"
}
# Function to install Zsh
install_zsh() {
update_package_manager
while true; do
echo "Do you want to continue zsh installation? (y/n)"
read answer
case "$answer" in
y)
sudo apt install -y zsh
sudo apt install -y curl wget git
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
echo "Installing Zsh"
echo '' > ~/.zshrc
echo "ZSH_THEME=\"avit\"" >> ~/.zshrc
echo "DEFAULT_USER=$USER" >> ~/.zshrc
echo "plugins=(git zsh-autosuggestions zsh-syntax-highlighting)" >> ~/.zshrc
# echo "source $ZSH/oh-my-zsh.sh" >> ~/.zshrc this is creating error
sudo apt install command-not-found -y
cd ~/.oh-my-zsh/plugins/
# Prompt user for plugin installation
echo "Which plugin(s) do you want to install? (syntax-highlighting(s)/both(b))"
read plugin_answer
case "$plugin_answer" in
s)
echo "Installing zsh-syntax-highlighting"
sudo apt install command-not-found -y
[ ! -d ~/.oh-my-zsh/plugins/zsh-syntax-highlighting ] && sudo git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/plugins/zsh-syntax-highlighting
;;
b)
echo "Installing zsh-autosuggestions and zsh-syntax-highlighting"
sudo apt install command-not-found -y
[ ! -d ~/.oh-my-zsh/plugins/zsh-autosuggestions ] && sudo git clone https://github.com/zsh-users/zsh-autosuggestions.git ~/.oh-my-zsh/plugins/zsh-autosuggestions
[ ! -d ~/.oh-my-zsh/plugins/zsh-syntax-highlighting ] && sudo git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/plugins/zsh-syntax-highlighting
;;
*)
echo "Invalid choice. Please enter 'a' or 'b'."
continue # Restart the loop
;;
esac
echo "source ~/.oh-my-zsh/oh-my-zsh.sh" >> ~/.zshrc
source ~/.zshrc
cd
break # Exit the loop
;;
n)
echo "Aborted"
break # Exit the loop
;;
*)
echo "Are you dumb! enter 'yes' or 'no'."
;;
esac
done
}
# Function to display help message
display_help() {
echo "Usage: $0 [-a] [-d] [-c] [-k] [-p] [-n] [-b] [-z] [-h]"
echo "Options:"
echo " -a Install all (Docker, Docker Compose, Minikube, kubectl, net-tools, programming languages, required tools, bpftool, Zsh)"
echo " -d Install Docker"
echo " -c Install Docker Compose"
echo " -k Install Minikube"
echo " -p Install kubectl"
echo " -n Install net-tools"
echo " -b Install bpftool"
echo " -z Install Zsh"
echo " -h Display this help message"
}
# Process flags
while getopts ":adckpnbzh" opt; do
case ${opt} in
a) install_docker
install_docker_compose
install_minikube
install_kubectl
install_net_tools
install_programming_languages
install_required_tools
install_bpftool
install_zsh
;;
d) install_docker ;;
c) install_docker_compose ;;
k) install_minikube ;;
p) install_kubectl ;;
n) install_net_tools ;;
b) install_bpftool ;;
z) install_zsh ;;
h) display_help ;;
\?) echo "Invalid option: -$OPTARG. Use -h for help." >&2
exit 1 ;;
esac
done
trap 'handle_error "An error occurred"' ERR
# Display help message if no flags are provided
if [[ $# -eq 0 ]]; then
display_help
fi
echo "All installations completed successfully."