mongodb-control 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. # get wekan/mongo settings
  3. source $SNAP/bin/wekan-read-settings
  4. if [ "true" == "${DISABLE_MONGODB}" ]; then
  5. echo "mongodb is disabled. Stop service"
  6. snapctl stop --disable ${SNAP_NAME}.mongodb
  7. exit 0
  8. fi
  9. # make sure we have set minimum env variables for locale
  10. if [ -z "$LANG" ]; then
  11. export LANG=en_US.UTF-8
  12. fi
  13. export LC_ALL=C
  14. # start mongo deamon
  15. BIND_OPTIONS=""
  16. if [ "nill" != "$MONGODB_BIND_UNIX_SOCKET" ] && [ "x" != "x${MONGODB_BIND_UNIX_SOCKET}" ]; then
  17. BIND_OPTIONS+=" --unixSocketPrefix $MONGODB_BIND_UNIX_SOCKET"
  18. fi
  19. if [ "x" != "x${MONGODB_BIND_IP}" ]; then
  20. BIND_OPTIONS+=" --bind_ip $MONGODB_BIND_IP"
  21. fi
  22. if [ "x" != "x${MONGODB_PORT}" ]; then
  23. BIND_OPTIONS+=" --port $MONGODB_PORT"
  24. fi
  25. echo "mongodb bind options: $BIND_OPTIONS"
  26. mongod --dbpath $SNAP_COMMON --logpath $SNAP_COMMON/mongodb.log --logappend --journal $BIND_OPTIONS --smallfiles
  27. # Drop indexes on database upgrade, when starting MongoDB
  28. mongo wekan --eval "db.getCollectionNames().forEach(function(col_name) { var coll = db.getCollection(col_name); coll.dropIndexes(); });" $BIND_OPTIONS