-
Notifications
You must be signed in to change notification settings - Fork 112
/
install.sh
executable file
·234 lines (200 loc) · 10.6 KB
/
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
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
#!/usr/bin/env bash
# set -e
# set -o pipefail
# trap 'echo "An error occurred during installation. Exiting..."; exit 1; echo "Please forward relevant error logs to the Agentcloud team."' ERR SIGINT
# set -e
# set -o pipefail
# trap 'echo "An error occurred during installation. Exiting..."; exit 1; echo "Please forward relevant error logs to the Agentcloud team."' ERR SIGINT
# Get the width of the terminal
terminal_width=$(tput cols)
if ! command -v docker-compose >/dev/null 2>&1 && ! docker compose version >/dev/null 2>&1; then
echo >&2 "docker compose is required but it's not installed. Aborting."
fi
command -v git >/dev/null 2>&1 || { echo >&2 "git is required but it's not installed. Aborting."; exit 1; }
command -v jq >/dev/null 2>&1 || { echo >&2 "jq is required but it's not installed. Aborting."; exit 1; }
command -v curl >/dev/null 2>&1 || { echo >&2 "curl is required but it's not installed. Aborting."; exit 1; }
command -v sed >/dev/null 2>&1 || { echo >&2 "sed is required but it's not installed. Aborting."; exit 1; }
if ! docker info &> /dev/null; then
echo "Docker daemon is not running. Aborting."
exit 1
fi
print_logo() {
clear
if [ "$terminal_width" -gt 120 ]; then
echo -e """
\033[34m ▓▓▓▓▓▓\033[97m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒
\033[34m ▓▓▓▓▓▓\033[97m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
\033[34m ▓▓▓▓▓▓\033[97m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
\033[34m ▓▓▓▓▓ \033[97m ▒▒▒▒ ▒▒▒
\033[34m ▓▓▓▓▓▓\033[97m ▒▒▒▒ ▒▒▒
\033[34m ▓▓▓▓▓▓\033[97m ▒▒▒▒ ▒▒▒▒
\033[34m ▓▓▓▓▓ \033[97m ▒▒▒▒ ▒▒▒▒
\033[34m ▓▓▓▓▓▓\033[97m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒
\033[34m ▓▓▓▓▓▓\033[97m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
\033[34m ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\033[97m ▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒
\033[34m ▓▓▓▓▓▓▓▓▓▓▓▓▓▓\033[97m ▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒▒
\033[34m ▓▓▓▓▓▓▓▓▓▓▓▓▓▓ \033[97m ▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒
\033[34m ▓▓▓▓▓▓ \033[97m ▒▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒
\033[34m ▓▓▓▓▓ \033[97m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒
\033[34m ▓▓▓▓▓▓\033[97m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒
\033[34m ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓\033[97m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
\033[34m▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ \033[97m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
\033[34m▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ \033[97m ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒\033[0m
$1
"""
else
echo """-= AgentCloud =-
$1"""
fi
}
# Function to show usage
usage() {
echo """Usage: $0 [options]
Options:
-h, --help Display this help message.
--kill-webapp-next Kill webapp after startup (for developers)
--kill-vector-db-proxy Kill vector-db-proxy after startup (for developers)
--kill-agent-backend Kill agent-backend after startup (for developers)
--minimal Don't run the agent-backend, vector-db-proxy, webapp or webapp-syncserver in docker (for developers)
"""
}
docker_up() {
if [ $# -eq 1 ]; then
local service_name=$1
docker compose up "$service_name" --build -d
if [ $? -ne 0 ]; then
echo "Couldn't start docker services, ensure the docker daemon is running then try again"
exit 1
# We could start the docke rservice but then we have to cater to multiple init systems
# docker_up $1
fi
else
echo "Usage: docker_up <service_name>"
fi
}
print_logo
echo
# get git hash of current repo for footer
export SHORT_COMMIT_HASH=$(git rev-parse --short HEAD)
echo "=> Welcome to Agentcloud! (rev-$SHORT_COMMIT_HASH)"
# Initialize variables
PROJECT_ID=""
SERVICE_ACCOUNT_JSON_PATH=""
GCS_BUCKET_NAME=""
GCS_BUCKET_LOCATION=""
STRIPE_PRICING_TABLE_ID=""
STRIPE_PUBLISHABLE_KEY=""
export AIRBYTE_RABBITMQ_HOST=$(ip address | grep -v 127.0.0.1 | grep -F "inet " | awk '{print $2}' | cut -d'/' -f1 | head -n 1)
echo "Airbyte RabbitMQ Host: ${AIRBYTE_RABBITMQ_HOST}"
# Initialize variables to indicate whether to kill specific containers
KILL_WEBAPP_NEXT=0
KILL_VECTOR_DB_PROXY=0
KILL_AGENT_BACKEND=0
# Function to kill a Docker container by service name (remains the same)
kill_container_by_service_name() {
local service_name=$1
local container_id=$(docker ps -q -f name="$service_name")
if [ -n "$container_id" ]; then
echo "Killing container $container_id of service $service_name..."
docker kill "$container_id"
if [ $? -eq 0 ]; then
echo "$service_name container killed successfully."
else
echo "Failed to kill $service_name container."
fi
else
echo "No running container found for service $service_name."
fi
}
# Parse command line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
--kill-webapp-next) KILL_WEBAPP_NEXT=1 ;;
--kill-vector-db-proxy) KILL_VECTOR_DB_PROXY=1 ;;
--kill-agent-backend) KILL_AGENT_BACKEND=1 ;;
--minimal) MINIMAL=1 ;;
-h|--help) usage; exit 0 ;;
*) echo "Unknown parameter passed: $1"; usage; exit 1 ;;
esac
shift
done
echo "=> Starting airbyte"
# env to disable airbyte telemetry
DO_NOT_TRACK=1
if ! command -v abctl &> /dev/null; then
echo "'abctl' command not found. Installing Airbyte..."
curl -LsfS https://get.airbyte.com | bash -
else
echo "'abctl' command is already installed."
fi
# Define the chart version to use
ABCTL_CHART_VERSION=
get_airbyte_creds() {
# Process the output: remove color codes and use grep/awk to extract values
ABCTL_CREDENTIALS=$(abctl local credentials 2>/dev/null | sed -r 's/\x1B\[[0-9;]*[mK]//g')
# Extract password, client-id, and client-secret using grep and awk
export AIRBYTE_USERNAME=$(echo "$ABCTL_CREDENTIALS" | grep -i 'Email:' | awk '{print $2}')
export AIRBYTE_PASSWORD=$(echo "$ABCTL_CREDENTIALS" | grep -i 'Password:' | awk '{print $2}')
export AIRBYTE_CLIENT_ID=$(echo "$ABCTL_CREDENTIALS" | grep -i 'Client-Id:' | awk '{print $2}')
export AIRBYTE_CLIENT_SECRET=$(echo "$ABCTL_CREDENTIALS" | grep -i 'Client-Secret:' | awk '{print $2}')
# Output for verification
echo "Airbyte Email: $AIRBYTE_USERNAME"
echo "Airbyte Password: $AIRBYTE_PASSWORD"
echo "Airbyte Client ID: $AIRBYTE_CLIENT_ID"
echo "Airbyte Client Secret: $AIRBYTE_CLIENT_SECRET"
}
get_airbyte_creds
# Check if the 'password' field is present
if [[ -z "$AIRBYTE_PASSWORD" || "$AIRBYTE_PASSWORD" == "null" ]]; then
echo "'password' field is missing. Running 'abctl local install'..."
if [[ -z "$ABCTL_CHART_VERSION" || "$ABCTL_CHART_VERSION" == "" ]]; then
abctl local install
else
abctl local install --chart-version $ABCTL_CHART_VERSION
fi
else
echo "'password' field found. Running 'abctl local status'..."
abctl local status
fi
retry_curl() {
local url=$1
local data=$2
while true; do
curl "$url" -X POST -H 'content-type: application/json' --data-raw "$data" && break
echo "Curl request failed. Retrying in 3 seconds..."
sleep 3
done
}
retry_curl 'http://localhost:8000/api/v1/instance_configuration/setup' '{"email":"[email protected]","anonymousDataCollection":true,"securityCheck":"skipped","organizationName":"example-org","initialSetupComplete":true,"displaySetupWizard":false}'
get_airbyte_creds
echo "=> Starting agentcloud backend..."
docker pull downloads.unstructured.io/unstructured-io/unstructured-api:latest || {
clear
echo "⚠️ Warning: Failed to pull the 'unstructured-api' image from the remote repository."
echo " Proceeding without the latest 'unstructured-api' image. Please check your network or the repository URL."
sleep 1
}
docker tag downloads.unstructured.io/unstructured-io/unstructured-api:latest localhost:5000/unstructured-api || {
clear
echo "⚠️ Warning: Failed to tag the 'unstructured-api' image for local use."
echo " Proceeding without updating the image tag. Please ensure the image was pulled correctly."
sleep 1
}
if [ "$MINIMAL" -eq 1 ]; then
docker compose -f docker-compose.minimal.yml up --build -d
else
docker compose up -d
fi
# At the end of the script, check the variables and kill containers if requested
if [ "$KILL_WEBAPP_NEXT" -eq 1 ]; then
kill_container_by_service_name "webapp_next"
fi
if [ "$KILL_WEBAPP_NEXT" -eq 1 ]; then
kill_container_by_service_name "webapp_syncserver"
fi
if [ "$KILL_VECTOR_DB_PROXY" -eq 1 ]; then
kill_container_by_service_name "vector_db_proxy"
fi
if [ "$KILL_AGENT_BACKEND" -eq 1 ]; then
kill_container_by_service_name "agent_backend"
fi