diff options
author | Victor Näslund <victor@sunet.se> | 2022-11-13 04:12:47 +0100 |
---|---|---|
committer | Victor Näslund <victor@sunet.se> | 2022-11-13 04:12:47 +0100 |
commit | f7a40b9e13d242968db83acaac13660224eb0143 (patch) | |
tree | d8f0cdf5d93cc1aebc83343aea6615bc2ee9bc55 /data/mongodb_entrypoint.sh | |
parent | 8baecf339e8061160bee519e87ffe837d1525c18 (diff) |
new direction
Diffstat (limited to 'data/mongodb_entrypoint.sh')
-rwxr-xr-x | data/mongodb_entrypoint.sh | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/data/mongodb_entrypoint.sh b/data/mongodb_entrypoint.sh new file mode 100755 index 0000000..3db507a --- /dev/null +++ b/data/mongodb_entrypoint.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +if [ ! -f /data/db/user_exist ] +then + # Another port to prevent 'address already in use' + /usr/bin/mongod --port 27015 --nounixsocket & + sleep 1 + cp /init-mongodb.js /data/db/init-mongodb.js + sed -i "s/REPLACE_USERNAME/$MONGODB_USERNAME/g" /data/db/init-mongodb.js + sed -i "s/REPLACE_PASSWORD/$MONGODB_PASSWORD/g" /data/db/init-mongodb.js + + /usr/bin/mongosh localhost:27015/production /data/db/init-mongodb.js + sleep 1 # Allow DB to shutdown + /usr/bin/touch /data/db/user_exist + rm /data/db/init-mongodb.js +fi + +# Startup normally now with our user +exec /usr/bin/mongod --nounixsocket --bind_ip_all --auth |