-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkers
More file actions
executable file
·59 lines (51 loc) · 1.42 KB
/
workers
File metadata and controls
executable file
·59 lines (51 loc) · 1.42 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
#!/usr/bin/env bash
set -e
usage() {
printf "%s usage:\n" "$(basename "$0")"
printf "\t-i SSH key path\n"
printf "\t-u SSH user\n"
printf "\t-f Local coordinator certificate file path\n"
printf "\t-H Trino worker hostnames or IPs\n\n\n"
printf "Make sure to check trino-setup for additional arguments and\n"
printf "keep all JDK and password configs the same as the coordinator setup\n"
}
# This is the Coordinator certificate
LOCAL_CERT="trino-coordinator.crt"
SSH_USER="acceldata"
while getopts "u:i:f:H:h" arg; do
case $arg in
i) SSH_KEY=${OPTARG} ;;
u) SSH_USER=${OPTARG} ;;
H) HOSTS=${OPTARG} ;;
f) LOCAL_CERT=${OPTARG} ;;
h)
usage
exit 0
;;
*)
usage
exit 1
;;
esac
done
shift $((OPTIND - 1))
if [ -z "$HOSTS" ] || [ -z "$SSH_USER" ]; then
usage
exit 1
fi
IFS=', ' read -r -a hosts <<<"$HOSTS"
if [ ! -f "$LOCAL_CERT" ]; then
echo >&2 "Local certificate file $LOCAL_CERT not found. Try running the 'coordinator' script to obtain the coordinator certificate."
exit 1
fi
for HOST in "${hosts[@]}"; do
echo "Setting up Trino worker on host: $HOST"
if [ -n "$SSH_KEY" ]; then
scp -i "$SSH_KEY" "$LOCAL_CERT" "$SSH_USER@$HOST:/tmp/trino-coordinator.crt"
ssh -i "$SSH_KEY" "$SSH_USER@$HOST" bash -s -- "$@" <trino-setup
else
scp "$LOCAL_CERT" "$SSH_USER@$HOST:/tmp/trino-coordinator.crt"
ssh "$SSH_USER@$HOST" bash -s -- "$@" <trino-setup
fi
done
rm "$LOCAL_CERT"