-
Notifications
You must be signed in to change notification settings - Fork 132
/
copy-config.sh
executable file
·43 lines (35 loc) · 1.33 KB
/
copy-config.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
#!/bin/bash
CONFIG_PATH=${1:-}
if [[ ${CURDIR:-} == "" ]]; then
export CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
fi
source $CURDIR/set-env.sh
config_dir="$PROJECT_ROOT/scripts/stack/connectors-config"
script_config="$config_dir/config.yml"
if [ -f "$script_config" ]; then
echo "config.yml already exists in $config_dir. Not overwriting."
return 0
fi
is_example_config=false
if [[ "${CONFIG_PATH:-}" == "" ]]; then
cp -n "$PROJECT_ROOT/config.yml.example" "$PROJECT_ROOT/config.yml"
CONFIG_PATH="$PROJECT_ROOT/config.yml"
is_example_config=true
fi
mkdir -p "$config_dir"
cp "$CONFIG_PATH" "$script_config"
echo "copied config from $CONFIG_PATH to $config_dir"
if [[ "$is_example_config" == true ]]; then
export CONFIG_FILE="$script_config"
sed_cmd="sed -i"
if [[ "$MACHINE_OS" == "MacOS" || "$MACHINE_OS" == "FreeBSD" ]]; then
sed_cmd="sed -i -e"
fi
$sed_cmd '/connectors:/s/^#//g' "$script_config"
$sed_cmd '/elasticsearch.host/s/^#//g' "$script_config"
$sed_cmd '/elasticsearch.username/s/^#//g' "$script_config"
$sed_cmd '/elasticsearch.password/s/^#//g' "$script_config"
if [[ "${ELASTIC_PASSWORD:-}" != "" ]]; then
$sed_cmd "s/elasticsearch.password:\ changeme/elasticsearch.password:\ \"$ELASTIC_PASSWORD\"/g" "$script_config"
fi
fi