forked from lavanet/lava
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit_install.sh
executable file
·102 lines (87 loc) · 3.04 KB
/
init_install.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
#!/bin/bash
__dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source $__dir/useful_commands.sh
############################## JQ INSTALLATION ######################################
# Flag to track if jq installation is successful
jq_installed=false
# Check if jq is not installed
if ! command_exists jq; then
# Try to install jq using apt (for Debian/Ubuntu)
if command_exists apt; then
echo "Installing jq using apt..."
sudo apt update
sudo apt install -y jq
if command_exists jq; then
echo "jq has been successfully installed."
jq_installed=true
fi
fi
# Try to install jq using brew (for macOS)
if ! $jq_installed && command_exists brew; then
echo "Installing jq using brew..."
brew install jq
if command_exists jq; then
echo "jq has been successfully installed."
jq_installed=true
fi
fi
else
echo "jq is already installed"
jq_installed=true
fi
# if jq is still not installed, exit
if ! $jq_installed; then
echo "Unable to install jq using apt or brew. Please install jq manually."
fi
############################# BUF INSTALLATION ######################################
if ! command_exists buf; then
if [[ "$OSTYPE" == "darwin"* ]]; then
# If the operating system is MacOS, use brew to install buf
brew install buf
else
# Define the version of buf to install
BUF_VERSION="1.25.0" # Update this to the latest version if needed
# Define the installation directory
INSTALL_DIR="/usr/local/bin" # You might need to adjust this based on your preferences
# Download and install buf
echo "Downloading buf version $BUF_VERSION..."
curl -sSL "https://github.com/bufbuild/buf/releases/download/v${BUF_VERSION}/buf-$(uname -s)-$(uname -m)" -o "${INSTALL_DIR}/buf"
# Add execute permissions to the buf binary
chmod +x "${INSTALL_DIR}/buf"
# Check if the installation was successful
if [ $? -eq 0 ]; then
echo "buf version $BUF_VERSION has been installed to $INSTALL_DIR."
exit 0
else
echo "An error occurred during the buf installation process. Please install buf manually."
exit 1
fi
fi
else
echo "buf is already installed"
fi
if ! command_exists protoc-gen-gocosmos; then
git clone https://github.com/cosmos/gogoproto.git
cd gogoproto
go mod download
make install
cd ..
rm -rf gogoproto
fi
if ! command_exists yq; then
if ! check_go_version; then
echo "Go 1.21 is not installed. Installing..."
sudo apt install -y golang-1.21
fi
go install github.com/mikefarah/yq/v4@latest
# Check if the installation was successful
if [ $? -eq 0 ]; then
echo "yq version has been installed "
exit 0
else
echo "An error occurred during the yq installation process. Please install buf manually."
exit 1
fi
else
echo "yq is already installed"
fi