-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-operator-cli-testnet
111 lines (86 loc) · 2.6 KB
/
install-operator-cli-testnet
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
#!/bin/bash
RELEASE_URL="https://github.com/witnesschain-com/operator-cli/releases/download/v0.3.1"
APP_NAME="watchtower-operator"
print_hr() {
local length=${1:-30} # Default length of the horizontal line
local char=${2:-"-"} # Default character for the line
for ((i=1; i<=$length; i++)); do
printf "%s" "$char"
done
printf "\n"
}
print_title() {
local title="$1"
local length=${#title}
print_hr $length "="
echo "$title"
print_hr $length "="
}
print_error() {
local message="$@"
printf "%s" "$(tput setaf 1)$message$(tput sgr0)" >&2
}
print_info() {
local message="$@"
printf "%s" "$(tput setaf 3)$message$(tput sgr0)"
}
print_success() {
local message="$@"
printf "%s" "$(tput setaf 2)$message$(tput sgr0)"
}
print_hr 40
printf "\n"
print_title "Setting up WitnessChain Operator CLI | TESTNET"
printf "\n- 🔍 Detecting platform...\n"
PLATFORM=$(uname)
ARCH=$(uname -m)
if [ "$PLATFORM" = "Linux" ] && [ "$ARCH" = "x86_64" ]; then
print_success " 🐧 Detected linux x86_64"
BINARY_NAME="watchtower-operator_linux_x86_64"
elif [ "$PLATFORM" = "Darwin" ] && [ "$ARCH" = "arm64" ]; then
print_success " 🍎 Detected apple silicon"
BINARY_NAME="watchtower-operator_apple_silicon"
else
print_error " 🕵️ Unable to identify platform for the binaries, please setup manually"
printf "\n"
print_hr 40
exit 1
fi
printf "\n- 🛠️ Setting up workspace..\n"
mkdir -p ~/.witnesschain/cli
if [ $? = 0 ]; then
PATH_TO_CLI="$HOME/.witnesschain/cli"
print_success " 🏡 Setup completed - CLI will reside in "
printf "%s\n\n" "$PATH_TO_CLI"
else
print_info " 🟡 Unable to create .witnesschain directory at home, going forward with current directory\n\n"
PATH_TO_CLI="."
fi
cd "$PATH_TO_CLI" || exit
printf "\n"
printf "\n\n- 🏃 Getting the binaries...\n"
curl -# -fSL -o "$APP_NAME" "$RELEASE_URL/$BINARY_NAME"
if [ $? = 0 ]; then
print_success " ✅ CLI downloaded "
else
print_error " ❌ Error downloading the binaries. exiting.."
printf "\n"
print_hr 40
exit 1
fi
printf "\n\n- 👮 Setting executable permissions for operator-cli..\n"
chmod -R +x "."
if [ $? = 0 ]; then
print_success " ✅ Permissions set successfully "
else
print_error " ❌ Error setting permissions "
printf "\n"
print_hr 40
exit 1
fi
printf "\n\n\n"
echo "you can add the following in your shell profile (.zprofile, .bashrc, etc..) to be able to use witnesschain CLI(s) from anywhere!"
printf "\n\n"
print_info "export PATH=\$PATH:$PATH_TO_CLI"
printf "\n\n"
print_hr 40