@@ -28,39 +28,11 @@ if [[ ! -L "/usr/lib/unifi/run" ]]; then
2828fi
2929
3030if [[ ! -e /config/data/system.properties ]]; then
31- if [[ -z "${MONGO_HOST }" ]]; then
32- echo "*** No MONGO_HOST set, cannot configure database settings. ***"
31+ if [[ -z "${MONGO_URI}" || -z "${STAT_MONGO_URI}" || -z "${MONGO_DBNAME }" ]]; then
32+ echo "*** Required environments are not set, cannot configure database settings. ***"
3333 sleep infinity
3434 else
35- echo "*** Waiting for MONGO_HOST ${MONGO_HOST} to be reachable. ***"
36- DBCOUNT=0
37- while true; do
38- if nc -w1 "${MONGO_HOST}" "${MONGO_PORT}" >/dev/null 2>&1; then
39- break
40- fi
41- DBCOUNT=$((DBCOUNT+1))
42- if [[ ${DBCOUNT} -gt 6 ]]; then
43- echo "*** Defined MONGO_HOST ${MONGO_HOST} is not reachable, cannot proceed. ***"
44- sleep infinity
45- fi
46- sleep 5
47- done
48- sed -i "s/~MONGO_USER~/${MONGO_USER}/" /defaults/system.properties
49- sed -i "s/~MONGO_HOST~/${MONGO_HOST}/" /defaults/system.properties
50- sed -i "s/~MONGO_PORT~/${MONGO_PORT}/" /defaults/system.properties
51- sed -i "s/~MONGO_DBNAME~/${MONGO_DBNAME}/" /defaults/system.properties
52- sed -i "s/~MONGO_PASS~/${MONGO_PASS}/" /defaults/system.properties
53- if [[ "${MONGO_TLS,,}" = "true" ]]; then
54- sed -i "s/~MONGO_TLS~/true/" /defaults/system.properties
55- else
56- sed -i "s/~MONGO_TLS~/false/" /defaults/system.properties
57- fi
58- if [[ -z "${MONGO_AUTHSOURCE}" ]]; then
59- sed -i "s/~MONGO_AUTHSOURCE~//" /defaults/system.properties
60- else
61- sed -i "s/~MONGO_AUTHSOURCE~/\&authSource=${MONGO_AUTHSOURCE}/" /defaults/system.properties
62- fi
63- cp /defaults/system.properties /config/data
35+ envsubst < /defaults/system.properties > /config/data/system.properties
6436 fi
6537fi
6638
0 commit comments