mirror of
https://github.com/linuxserver/docker-unifi-network-application.git
synced 2025-03-05 20:59:58 -08:00
Use envsubst
to replace placeholders in system.properties
This commit is contained in:
parent
d74b43762f
commit
fb1bd160e3
|
@ -41,6 +41,6 @@
|
|||
# unifi.throughput.port=6789
|
||||
#
|
||||
db.mongo.local=false
|
||||
db.mongo.uri=mongodb://~MONGO_USER~:~MONGO_PASS~@~MONGO_HOST~:~MONGO_PORT~/~MONGO_DBNAME~?tls=~MONGO_TLS~~MONGO_AUTHSOURCE~
|
||||
statdb.mongo.uri=mongodb://~MONGO_USER~:~MONGO_PASS~@~MONGO_HOST~:~MONGO_PORT~/~MONGO_DBNAME~_stat?tls=~MONGO_TLS~~MONGO_AUTHSOURCE~
|
||||
unifi.db.name=~MONGO_DBNAME~
|
||||
db.mongo.uri=$MONGO_URI
|
||||
statdb.mongo.uri=$STAT_MONGO_URI
|
||||
unifi.db.name=$MONGO_DBNAME
|
||||
|
|
|
@ -28,39 +28,11 @@ if [[ ! -L "/usr/lib/unifi/run" ]]; then
|
|||
fi
|
||||
|
||||
if [[ ! -e /config/data/system.properties ]]; then
|
||||
if [[ -z "${MONGO_HOST}" ]]; then
|
||||
echo "*** No MONGO_HOST set, cannot configure database settings. ***"
|
||||
if [[ -z "${MONGO_URI}" || -z "${STAT_MONGO_URI}" || -z "${MONGO_DBNAME}" ]]; then
|
||||
echo "*** Required environments are not set, cannot configure database settings. ***"
|
||||
sleep infinity
|
||||
else
|
||||
echo "*** Waiting for MONGO_HOST ${MONGO_HOST} to be reachable. ***"
|
||||
DBCOUNT=0
|
||||
while true; do
|
||||
if nc -w1 "${MONGO_HOST}" "${MONGO_PORT}" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
DBCOUNT=$((DBCOUNT+1))
|
||||
if [[ ${DBCOUNT} -gt 6 ]]; then
|
||||
echo "*** Defined MONGO_HOST ${MONGO_HOST} is not reachable, cannot proceed. ***"
|
||||
sleep infinity
|
||||
fi
|
||||
sleep 5
|
||||
done
|
||||
sed -i "s/~MONGO_USER~/${MONGO_USER}/" /defaults/system.properties
|
||||
sed -i "s/~MONGO_HOST~/${MONGO_HOST}/" /defaults/system.properties
|
||||
sed -i "s/~MONGO_PORT~/${MONGO_PORT}/" /defaults/system.properties
|
||||
sed -i "s/~MONGO_DBNAME~/${MONGO_DBNAME}/" /defaults/system.properties
|
||||
sed -i "s/~MONGO_PASS~/${MONGO_PASS}/" /defaults/system.properties
|
||||
if [[ "${MONGO_TLS,,}" = "true" ]]; then
|
||||
sed -i "s/~MONGO_TLS~/true/" /defaults/system.properties
|
||||
else
|
||||
sed -i "s/~MONGO_TLS~/false/" /defaults/system.properties
|
||||
fi
|
||||
if [[ -z "${MONGO_AUTHSOURCE}" ]]; then
|
||||
sed -i "s/~MONGO_AUTHSOURCE~//" /defaults/system.properties
|
||||
else
|
||||
sed -i "s/~MONGO_AUTHSOURCE~/\&authSource=${MONGO_AUTHSOURCE}/" /defaults/system.properties
|
||||
fi
|
||||
cp /defaults/system.properties /config/data
|
||||
envsubst < /defaults/system.properties > /config/data/system.properties
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue