summaryrefslogtreecommitdiffstats
path: root/snap-src/bin/mongodb-control
blob: 28e586700f2fc570ced399037b4fec985fe1e6f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash

# get wekan/mongo settings
source $SNAP/bin/wekan-read-settings

if [ "true" == "${DISABLE_MONGODB}" ]; then
    echo "mongodb is disabled. Stop service"
    snapctl stop --disable ${SNAP_NAME}.mongodb
    exit 0
fi

# make sure we have set minimum env variables for locale
if [ -z "$LANG" ]; then
    export LANG=en_US.UTF-8
fi

export LC_ALL=C

if [ -z "$MONGO_URL" ]; then

    # start mongo deamon
    BIND_OPTIONS=""
    if [ "nill" != "$MONGODB_BIND_UNIX_SOCKET" ] && [ "x" != "x${MONGODB_BIND_UNIX_SOCKET}" ]; then
        BIND_OPTIONS+=" --unixSocketPrefix  $MONGODB_BIND_UNIX_SOCKET"
    fi
    if [ "x" != "x${MONGODB_BIND_IP}" ]; then
        BIND_OPTIONS+=" --bind_ip $MONGODB_BIND_IP"
    fi
    if [ "x" != "x${MONGODB_PORT}" ]; then
        BIND_OPTIONS+=" --port $MONGODB_PORT"
    fi
    echo "mongodb bind options: $BIND_OPTIONS"

    mongod --dbpath $SNAP_COMMON --logpath $SNAP_COMMON/mongodb.log --logappend --journal $BIND_OPTIONS --smallfiles

else

    mongod --dbpath $SNAP_COMMON --logpath $SNAP_COMMON/mongodb.log --logappend --journal $MONGO_URL --smallfiles

fi

# Drop indexes on database upgrade, when starting MongoDB
#mongo wekan --eval "db.getCollectionNames().forEach(function(col_name) { var coll = db.getCollection(col_name); coll.dropIndexes(); });" $BIND_OPTIONS