2019-06-20 21:17:38 +00:00
|
|
|
#!/bin/bash
|
2018-09-28 17:55:39 +00:00
|
|
|
|
|
|
|
if [ -z "$ZT_IDENTITY_PATH" ]; then
|
|
|
|
echo '*** FAILED: ZT_IDENTITY_PATH environment variable is not defined'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "$ZT_DB_HOST" ]; then
|
|
|
|
echo '*** FAILED: ZT_DB_HOST environment variable not defined'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "$ZT_DB_PORT" ]; then
|
|
|
|
echo '*** FAILED: ZT_DB_PORT environment variable not defined'
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-12-10 20:26:20 +00:00
|
|
|
if [ -z "$ZT_DB_NAME" ]; then
|
|
|
|
echo '*** FAILED: ZT_DB_NAME environment variable not defined'
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-09-28 17:55:39 +00:00
|
|
|
if [ -z "$ZT_DB_USER" ]; then
|
|
|
|
echo '*** FAILED: ZT_DB_USER environment variable not defined'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "$ZT_DB_PASSWORD" ]; then
|
|
|
|
echo '*** FAILED: ZT_DB_PASSWORD environment variable not defined'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-03-05 23:47:04 +00:00
|
|
|
RMQ=""
|
|
|
|
if [ "$ZT_USE_RABBITMQ" == "true" ]; then
|
|
|
|
if [ -z "$RABBITMQ_HOST" ]; then
|
|
|
|
echo '*** FAILED: RABBITMQ_HOST environment variable not defined'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "$RABBITMQ_PORT" ]; then
|
|
|
|
echo '*** FAILED: RABBITMQ_PORT environment variable not defined'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "$RABBITMQ_USERNAME" ]; then
|
|
|
|
echo '*** FAILED: RABBITMQ_USERNAME environment variable not defined'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "$RABBITMQ_PASSWORD" ]; then
|
|
|
|
echo '*** FAILED: RABBITMQ_PASSWORD environment variable not defined'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
RMQ=", \"rabbitmq\": {
|
|
|
|
\"host\": \"${RABBITMQ_HOST}\",
|
|
|
|
\"port\": ${RABBITMQ_PORT},
|
|
|
|
\"username\": \"${RABBITMQ_USERNAME}\",
|
|
|
|
\"password\": \"${RABBITMQ_PASSWORD}\"
|
|
|
|
}"
|
|
|
|
fi
|
|
|
|
|
2018-09-28 17:55:39 +00:00
|
|
|
mkdir -p /var/lib/zerotier-one
|
|
|
|
|
|
|
|
pushd /var/lib/zerotier-one
|
|
|
|
ln -s $ZT_IDENTITY_PATH/identity.public identity.public
|
|
|
|
ln -s $ZT_IDENTITY_PATH/identity.secret identity.secret
|
|
|
|
popd
|
|
|
|
|
2018-12-03 23:06:26 +00:00
|
|
|
DEFAULT_PORT=9993
|
|
|
|
|
2018-09-28 17:55:39 +00:00
|
|
|
echo "{
|
|
|
|
\"settings\": {
|
|
|
|
\"portMappingEnabled\": true,
|
|
|
|
\"softwareUpdate\": \"disable\",
|
2018-12-03 23:06:26 +00:00
|
|
|
\"interfacePrefixBlacklist\": [
|
2018-09-28 17:55:39 +00:00
|
|
|
\"inot\",
|
|
|
|
\"nat64\"
|
|
|
|
],
|
2018-12-10 20:26:20 +00:00
|
|
|
\"controllerDbPath\": \"postgres:host=${ZT_DB_HOST} port=${ZT_DB_PORT} dbname=${ZT_DB_NAME} user=${ZT_DB_USER} password=${ZT_DB_PASSWORD} sslmode=prefer sslcert=${DB_CLIENT_CERT} sslkey=${DB_CLIENT_KEY} sslrootcert=${DB_SERVER_CA}\"
|
2019-03-05 23:47:04 +00:00
|
|
|
${RMQ}
|
2018-09-28 17:55:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
" > /var/lib/zerotier-one/local.conf
|
|
|
|
|
2018-10-24 20:36:21 +00:00
|
|
|
export GLIBCXX_FORCE_NEW=1
|
|
|
|
export GLIBCPP_FORCE_NEW=1
|
|
|
|
export LD_PRELOAD="/usr/lib64/libjemalloc.so"
|
2018-12-03 23:06:26 +00:00
|
|
|
exec /usr/local/bin/zerotier-one -p${ZT_CONTROLLER_PORT:-$DEFAULT_PORT} /var/lib/zerotier-one
|