Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace placeholers in properties with envsubst #72

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
fb1bd16
Use `envsubst` to replace placeholders in system.properties
sturman Feb 24, 2024
1146ec4
Install `envsubst`
sturman Feb 24, 2024
62dab7b
Install `envsubst` alternative (Go version)
sturman Feb 24, 2024
a1b59c2
Set `DEBIAN_FRONTEND` environment variable
sturman Feb 24, 2024
3be04fb
Fix log message
sturman Feb 24, 2024
36abd4e
Revert "Install `envsubst` alternative (Go version)"
sturman Feb 24, 2024
27594b9
Sort dependencies
sturman Feb 24, 2024
41b3671
Merge remote-tracking branch 'origin/main' into replace-placeholers-i…
sturman Mar 20, 2024
1a53803
Add new environment variables to README.md
sturman Mar 20, 2024
9f8030f
Merge remote-tracking branch 'origin/main' into replace-placeholers-i…
sturman Apr 29, 2024
96d3003
Merge remote-tracking branch 'origin/main' into replace-placeholers-i…
sturman May 21, 2024
4ea124f
Merge remote-tracking branch 'origin/main' into replace-placeholers-i…
sturman Jun 4, 2024
76bcaf3
Merge remote-tracking branch 'origin/main' into replace-placeholers-i…
sturman Jul 17, 2024
61c4b50
Merge remote-tracking branch 'origin/main' into replace-placeholers-i…
sturman Aug 17, 2024
a60a8bd
Merge remote-tracking branch 'origin/main' into replace-placeholers-i…
sturman Aug 27, 2024
7654109
Merge branch 'linuxserver:main' into replace-placeholers-in-proeprties
sturman Sep 27, 2024
3c43dd6
Merge remote-tracking branch 'origin/main' into replace-placeholers-i…
sturman Oct 10, 2024
0aa4543
Merge remote-tracking branch 'origin/main' into replace-placeholers-i…
sturman Nov 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.aarch64
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,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:[email protected]/?retryWrites=true&w=majority&appName=unifi \
-e STAT_MONGO_URI=mongodb+srv://unifi:[email protected]/?retryWrites=true&w=majority&appName=unifi \
-e MONGO_DBNAME=unifi \
-e MONGO_AUTHSOURCE=admin \
-e MEM_LIMIT=1024 `#optional` \
Expand Down
1 change: 1 addition & 0 deletions readme-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ app_setup_block: |

# changelog
changelogs:
- { date: "17.08.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." }
Expand Down
6 changes: 3 additions & 3 deletions root/defaults/system.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down