diff --git a/Dockerfile b/Dockerfile index 9080f1d..573887b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,7 @@ RUN \ echo "**** install packages ****" && \ apt-get update && \ apt-get install --no-install-recommends -y \ + gettext \ jsvc \ logrotate \ openjdk-17-jre-headless \ diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 2909319..ca22a47 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -17,6 +17,7 @@ RUN \ echo "**** install packages ****" && \ apt-get update && \ apt-get install --no-install-recommends -y \ + gettext \ jsvc \ logrotate \ openjdk-17-jre-headless \ diff --git a/README.md b/README.md index e001a28..6e63be9 100644 --- a/README.md +++ b/README.md @@ -204,10 +204,8 @@ docker run -d \ -e PUID=1000 \ -e PGID=1000 \ -e TZ=Etc/UTC \ - -e MONGO_USER=unifi \ - -e MONGO_PASS= \ - -e MONGO_HOST=unifi-db \ - -e MONGO_PORT=27017 \ + -e MONGO_URI=mongodb+srv://unifi:password@unifi.mongodb.net/?retryWrites=true&w=majority&appName=unifi \ + -e STAT_MONGO_URI=mongodb+srv://unifi:password@unifi.mongodb.net/?retryWrites=true&w=majority&appName=unifi \ -e MONGO_DBNAME=unifi \ -e MONGO_AUTHSOURCE=admin \ -e MEM_LIMIT=1024 `#optional` \ diff --git a/readme-vars.yml b/readme-vars.yml index 33c50d3..07f1af1 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -176,6 +176,7 @@ init_diagram: | "unifi-network-application:latest" <- Base Images # changelog changelogs: + - {date: "23.12.24:", desc: "Change environment variables" } - {date: "11.08.24:", desc: "**Important**: The mongodb init instructions have been updated to enable auth ([RBAC](https://www.mongodb.com/docs/manual/core/authorization/#role-based-access-control)). We have been notified that if RBAC is not enabled, the official mongodb container allows remote access to the db contents over port 27017 without credentials. If you set up the mongodb container with the old instructions we provided, you should not map or expose port 27017. If you would like to enable auth, the easiest way is to create new instances of both unifi and mongodb with the new instructions and restore unifi from a backup."} - {date: "11.08.24:", desc: "Rebase to Ubuntu Noble."} - {date: "04.03.24:", desc: "Install from zip package instead of deb."} diff --git a/root/defaults/system.properties b/root/defaults/system.properties index 709e574..ab0084b 100644 --- a/root/defaults/system.properties +++ b/root/defaults/system.properties @@ -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 diff --git a/root/etc/s6-overlay/s6-rc.d/init-unifi-network-application-config/run b/root/etc/s6-overlay/s6-rc.d/init-unifi-network-application-config/run index fd28c3c..2d14000 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-unifi-network-application-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-unifi-network-application-config/run @@ -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 environment variables 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