2021-09-25 19:12:05 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-03-05 11:20:04 +01:00
|
|
|
source setup.env
|
|
|
|
|
2022-05-22 18:53:47 +02:00
|
|
|
if [[ "x-$NETBIRD_DOMAIN" == "x-" ]]
|
2022-03-05 11:20:04 +01:00
|
|
|
then
|
2022-05-22 18:53:47 +02:00
|
|
|
echo NETBIRD_DOMAIN is not set, please update your setup.env file
|
2022-03-05 11:20:04 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# local development or tests
|
2022-05-22 18:53:47 +02:00
|
|
|
if [[ $NETBIRD_DOMAIN == "localhost" || $NETBIRD_DOMAIN == "127.0.0.1" ]]
|
2022-03-05 11:20:04 +01:00
|
|
|
then
|
2022-05-22 18:53:47 +02:00
|
|
|
export NETBIRD_MGMT_API_ENDPOINT=http://$NETBIRD_DOMAIN:$NETBIRD_MGMT_API_PORT
|
|
|
|
unset NETBIRD_MGMT_API_CERT_FILE
|
|
|
|
unset NETBIRD_MGMT_API_CERT_KEY_FILE
|
2022-03-05 11:20:04 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# if not provided, we generate a turn password
|
|
|
|
if [[ "x-$TURN_PASSWORD" == "x-" ]]
|
|
|
|
then
|
|
|
|
export TURN_PASSWORD=$(openssl rand -base64 32|sed 's/=//g')
|
|
|
|
fi
|
2021-09-25 19:12:05 +02:00
|
|
|
|
2022-05-20 10:53:56 +02:00
|
|
|
MGMT_VOLUMENAME="${VOLUME_PREFIX}${MGMT_VOLUMESUFFIX}"
|
|
|
|
SIGNAL_VOLUMENAME="${VOLUME_PREFIX}${SIGNAL_VOLUMESUFFIX}"
|
|
|
|
LETSENCRYPT_VOLUMENAME="${VOLUME_PREFIX}${LETSENCRYPT_VOLUMESUFFIX}"
|
2022-05-13 21:51:41 +02:00
|
|
|
# if volume with wiretrustee- prefix already exists, use it, else create new with netbird-
|
2022-05-13 14:11:21 +02:00
|
|
|
OLD_PREFIX='wiretrustee-'
|
2022-05-13 21:51:41 +02:00
|
|
|
if docker volume ls | grep -q "${OLD_PREFIX}${MGMT_VOLUMESUFFIX}"; then
|
2022-05-22 18:53:47 +02:00
|
|
|
MGMT_VOLUMENAME="${OLD_PREFIX}${MGMT_VOLUMESUFFIX}"
|
2022-05-13 21:51:41 +02:00
|
|
|
fi
|
|
|
|
if docker volume ls | grep -q "${OLD_PREFIX}${SIGNAL_VOLUMESUFFIX}"; then
|
2022-05-22 18:53:47 +02:00
|
|
|
SIGNAL_VOLUMENAME="${OLD_PREFIX}${SIGNAL_VOLUMESUFFIX}"
|
2022-05-13 21:51:41 +02:00
|
|
|
fi
|
|
|
|
if docker volume ls | grep -q "${OLD_PREFIX}${LETSENCRYPT_VOLUMESUFFIX}"; then
|
2022-05-22 18:53:47 +02:00
|
|
|
LETSENCRYPT_VOLUMENAME="${OLD_PREFIX}${LETSENCRYPT_VOLUMESUFFIX}"
|
2022-05-13 14:11:21 +02:00
|
|
|
fi
|
|
|
|
|
2022-05-13 21:51:41 +02:00
|
|
|
export MGMT_VOLUMENAME
|
|
|
|
export SIGNAL_VOLUMENAME
|
|
|
|
export LETSENCRYPT_VOLUMENAME
|
2022-05-13 14:11:21 +02:00
|
|
|
|
2021-09-25 19:12:05 +02:00
|
|
|
envsubst < docker-compose.yml.tmpl > docker-compose.yml
|
|
|
|
envsubst < management.json.tmpl > management.json
|
2022-05-13 14:11:21 +02:00
|
|
|
envsubst < turnserver.conf.tmpl > turnserver.conf
|