forked from elastic/connectors
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure-connectors.sh
executable file
·69 lines (57 loc) · 1.97 KB
/
configure-connectors.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
#!/bin/bash
set -o pipefail
if [[ ${CURDIR:-} == "" ]]; then
export CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
fi
source $CURDIR/set-env.sh
PYTHON_EXECUTABLE=""
if which python3 > /dev/null; then
PY_VERSION=`python3 --version`
PYTHON_EXECUTABLE="python3"
elif which python > /dev/null; then
PY_VERSION=`python --version`
PYTHON_EXECUTABLE="python"
fi
pushd $PROJECT_ROOT
if [[ "${CONFIG_FILE:-}" == "" ]]; then
CONFIG_FILE="${PROJECT_ROOT}/scripts/stack/connectors-config/config.yml"
fi
CLI_CONFIG="${PROJECT_ROOT}/scripts/stack/connectors-config/cli_config.yml"
# ensure our Connectors CLI config exists and has the correct information
if [ ! -f "$CLI_CONFIG" ]; then
cliConfigText='
elasticsearch:
host: http://localhost:9200
password: '"${ELASTIC_PASSWORD}"'
username: elastic
'
echo "${cliConfigText}" > "$CLI_CONFIG"
fi
CONNECTORS_EXE="${PROJECT_ROOT}/bin/connectors"
if [ ! -f "$CONNECTORS_EXE" ]; then
echo "Could not find a connectors executable, running 'make clean install'"
if [ $PYTHON_EXECUTABLE == "" ]; then
echo "Could not find a suitable Python 3 executable..."
exit 2
fi
make clean install PYTHON=$PYTHON_EXECUTABLE
fi
keep_configuring=true
while [ $keep_configuring == true ]; do
echo
echo "Currently configured connectors:"
$CONNECTORS_EXE --config "$CLI_CONFIG" connector list
echo
while true; do
read -p "Do you want to set up a new connector? (y/N) " yn
case $yn in
[yY] ) break;;
[nN] ) keep_configuring=false; break;;
* ) keep_configuring=false; break;;
esac
done
if [ $keep_configuring == true ]; then
$CONNECTORS_EXE --config "${CLI_CONFIG}" connector create --connector-service-config "$CONFIG_FILE" --update-config
fi
done
popd