-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart.sh
executable file
·120 lines (108 loc) · 7.67 KB
/
start.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
#!/usr/bin/env bash
# Regular Colors
BLACK='\033[0;30m' # Black
RED='\033[0;31m' # Red
GREEN='\033[0;32m' # Green
ORANGE='\033[0;33m' # Orange/Brown
BLUE='\033[0;34m' # Blue
PURPLE='\033[0;35m' # Purple
CYAN='\033[0;36m' # Cyan
LIGHTGRAY='\033[0;37m' # Light Gray
# Bold (Bright) Colors
DARKGRAY='\033[1;30m' # Dark Gray
LIGHTRED='\033[1;31m' # Light Red
LIGHTGREEN='\033[1;32m' # Light Green
YELLOW='\033[1;33m' # Yellow
LIGHTBLUE='\033[1;34m' # Light Blue
LIGHTPURPLE='\033[1;35m' # Light Purple
LIGHTCYAN='\033[1;36m' # Light Cyan
WHITE='\033[1;37m' # White
# No Color
NC='\033[0m' # No Color
CHECK='\xE2\x9C\x94' # Check mark
CROSS='\xE2\x9D\x8C' # Cross mark
KCOLOR=$LIGHTCYAN
BCOLOR=$LIGHTPURPLE
SHADOWCOLOR=$YELLOW
BGCOLOR=$BLACK
printf "
${BGCOLOR}░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
░░${BCOLOR}██████${SHADOWCOLOR}╗${BGCOLOR}░${BCOLOR}██${SHADOWCOLOR}╗${BGCOLOR}░░░░░░${BCOLOR}█████${SHADOWCOLOR}╗${BGCOLOR}░░${BCOLOR}█████${SHADOWCOLOR}╗${BGCOLOR}░${BCOLOR}██${SHADOWCOLOR}╗${BGCOLOR}░░${BCOLOR}██${SHADOWCOLOR}╗${KCOLOR}██${SHADOWCOLOR}╗${BGCOLOR}░░${KCOLOR}██${SHADOWCOLOR}╗${KCOLOR}██${SHADOWCOLOR}╗${BGCOLOR}░░░${KCOLOR}██${SHADOWCOLOR}╗${KCOLOR}██████${SHADOWCOLOR}╗${BGCOLOR}░${KCOLOR}███████${SHADOWCOLOR}╗${BGCOLOR}░░
░░${BCOLOR}██${SHADOWCOLOR}╔══${BCOLOR}██${SHADOWCOLOR}╗${BCOLOR}██${SHADOWCOLOR}║${BGCOLOR}░░░░░${BCOLOR}██${SHADOWCOLOR}╔══${BCOLOR}██${SHADOWCOLOR}╗${BCOLOR}██${SHADOWCOLOR}╔══${BCOLOR}██${SHADOWCOLOR}╗${BCOLOR}██${SHADOWCOLOR}║${BGCOLOR}░${BCOLOR}██${SHADOWCOLOR}╔╝${KCOLOR}██${SHADOWCOLOR}║${BGCOLOR}░${KCOLOR}██${SHADOWCOLOR}╔╝${KCOLOR}██${SHADOWCOLOR}║${BGCOLOR}░░░${KCOLOR}██${SHADOWCOLOR}║${KCOLOR}██${SHADOWCOLOR}╔══${KCOLOR}██${SHADOWCOLOR}╗${KCOLOR}██${SHADOWCOLOR}╔════╝${BGCOLOR}░░
░░${BCOLOR}██████${SHADOWCOLOR}╦╝${BCOLOR}██${SHADOWCOLOR}║${BGCOLOR}░░░░░${BCOLOR}██${SHADOWCOLOR}║${BGCOLOR}░░${BCOLOR}██${SHADOWCOLOR}║${BCOLOR}██${SHADOWCOLOR}║${BGCOLOR}░░${SHADOWCOLOR}╚═╝${BCOLOR}█████${SHADOWCOLOR}═╝${BGCOLOR}░${KCOLOR}█████${SHADOWCOLOR}═╝${BGCOLOR}░${KCOLOR}██${SHADOWCOLOR}║${BGCOLOR}░░░${KCOLOR}██${SHADOWCOLOR}║${KCOLOR}██████${SHADOWCOLOR}╦╝${KCOLOR}█████${SHADOWCOLOR}╗${BGCOLOR}░░░░
░░${BCOLOR}██${SHADOWCOLOR}╔══${BCOLOR}██${SHADOWCOLOR}╗${BCOLOR}██${SHADOWCOLOR}║${BGCOLOR}░░░░░${BCOLOR}██${SHADOWCOLOR}║${BGCOLOR}░░${BCOLOR}██${SHADOWCOLOR}║${BCOLOR}██${SHADOWCOLOR}║${BGCOLOR}░░${BCOLOR}██${SHADOWCOLOR}╗${BCOLOR}██${SHADOWCOLOR}╔═${BCOLOR}██${SHADOWCOLOR}╗${BGCOLOR}░${KCOLOR}██${SHADOWCOLOR}╔═${KCOLOR}██${SHADOWCOLOR}╗${BGCOLOR}░${KCOLOR}██${SHADOWCOLOR}║${BGCOLOR}░░░${KCOLOR}██${SHADOWCOLOR}║${KCOLOR}██${SHADOWCOLOR}╔══${KCOLOR}██${SHADOWCOLOR}╗${KCOLOR}██${SHADOWCOLOR}╔══╝${BGCOLOR}░░░░
░░${BCOLOR}██████${SHADOWCOLOR}╦╝${BCOLOR}███████${SHADOWCOLOR}╗${SHADOWCOLOR}╚${BCOLOR}█████${SHADOWCOLOR}╔╝${BCOLOR}╚█████${SHADOWCOLOR}╔╝${BCOLOR}██${SHADOWCOLOR}║${BGCOLOR}░${SHADOWCOLOR}╚${BCOLOR}██${SHADOWCOLOR}╗${KCOLOR}██${SHADOWCOLOR}║${BGCOLOR}░${SHADOWCOLOR}╚${KCOLOR}██${SHADOWCOLOR}╗╚${KCOLOR}██████${SHADOWCOLOR}╔╝${KCOLOR}██████${SHADOWCOLOR}╦╝${KCOLOR}███████${SHADOWCOLOR}╗${BGCOLOR}░░
░░${SHADOWCOLOR}╚═════╝${BGCOLOR}░${SHADOWCOLOR}╚══════╝${BGCOLOR}░${SHADOWCOLOR}╚════╝${BGCOLOR}░░${SHADOWCOLOR}╚════╝${BGCOLOR}░${SHADOWCOLOR}╚═╝${BGCOLOR}░░${SHADOWCOLOR}╚═╝╚═╝${BGCOLOR}░░${SHADOWCOLOR}╚═╝${BGCOLOR}░░${SHADOWCOLOR}╚════╝${BGCOLOR}░░${SHADOWCOLOR}╚════╝${BGCOLOR}░░${SHADOWCOLOR}╚═════╝${BGCOLOR}░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
"
# Welcome message with the user's name
USERNAME=$(whoami)
echo -e "${GREEN}Welcome, ${YELLOW}${USERNAME}${GREEN}, to ${BCOLOR}Block${KCOLOR}Kube${NC}"
# Check for Docker, Node.js, and Minikube installation
echo "Checking system requirements..."
echo -e "Docker: $( [ -x "$(command -v docker)" ] && echo -e "${GREEN}${CHECK}${NC}" || echo -e "${RED}${CROSS}${NC}" )"
echo -e "Node.js: $( [ -x "$(command -v node)" ] && echo -e "${GREEN}${CHECK}${NC}" || echo -e "${RED}${CROSS}${NC}" )"
echo -e "Minikube: $( [ -x "$(command -v minikube)" ] && echo -e "${GREEN}${CHECK}${NC}" || echo -e "${RED}${CROSS}${NC}" )"
# Menu loop
while true; do
# Show menu options
echo -e "\n${ORANGE}Choose an option to proceed:"
echo -e "${ORANGE}A${NC} - Auto: Run everything ${ORANGE}R${NC} - Reset configurations to default"
echo -e "${ORANGE}K${NC} - Apply Kubernetes configuration ${ORANGE}C${NC} - Check configurations (environment.yaml)"
echo -e "${ORANGE}I${NC} - Install all packages ${RED}E${NC} - Exit\n"
# Read user choice
read -p "Enter your choice (A/R/K/C/E): " choice
# Handle user choice
case $choice in
A|a)
printf "\n${YELLOW}Do you want to start minikube? Y/n\n${NC}"
read -p "Y/n: " input
if [ "$input" = "Y" ]; then
echo "Starting minikube"
minikube start --cpus 4 --memory 4096
fi
printf "\n${YELLOW}Running BlockKube script"
cd kubernetes
node blockkube.js
cd ..
printf "\n${YELLOW}Applying Kubernetes configuration\n\n"
kubectl apply -f kubernetes/yaml/00_claims.yaml
kubectl apply -f kubernetes/yaml/01_common-config.yaml
kubectl apply -f kubernetes/yaml/02_bootnodes.yaml
sleep 12
kubectl apply -f kubernetes/yaml/03_nodes.yaml
sleep 12
kubectl apply -f kubernetes/yaml/04_fullnodes.yaml
sleep 12
kubectl apply -f kubernetes/yaml/05_monitor.yaml
kubectl apply -f kubernetes/yaml/06_explorer.yaml
;;
R|r)
printf "\n${YELLOW}Resetting configurations..."
cd kubernetes
node blockkube.js
cd ..
printf "\n${GREEN}Configurations Reseted.\n\n"
;;
K|k)
printf "\n${YELLOW}Applying Kubernetes configuration"
kubectl apply -f kubernetes/yaml/
;;
C|c)
printf "\n${YELLOW}Current environment configurations:\n\n"
cat kubernetes/environment.yaml
;;
I|i)
printf "\n${YELLOW}Installing all packages..."
npm i
printf "\n${GREEN}Packages instalation done.\n\n"
;;
E|e)
echo "Exiting..."
break
;;
*)
echo -e "${RED}Invalid choice. Please try again.${NC}"
;;
esac
done