2
0
Эх сурвалжийг харах

Fix apparmor denied in syslog at Snap Candidate.

Thanks to webenefits and xet7 !

Fixes #4855
Lauri Ojansivu 9 сар өмнө
parent
commit
c3909edc5e

+ 12 - 15
snap-src/bin/mongodb-control

@@ -80,17 +80,14 @@ if [ -z "$MONGO_URL" ]; then
 
 
     # start mongo deamon
     # start mongo deamon
     BIND_OPTIONS=""
     BIND_OPTIONS=""
-    SH_BIND_OPTIONS=""
     if [ "nill" != "$MONGODB_BIND_UNIX_SOCKET" ] && [ "x" != "x${MONGODB_BIND_UNIX_SOCKET}" ]; then
     if [ "nill" != "$MONGODB_BIND_UNIX_SOCKET" ] && [ "x" != "x${MONGODB_BIND_UNIX_SOCKET}" ]; then
         BIND_OPTIONS+=" --unixSocketPrefix  $MONGODB_BIND_UNIX_SOCKET"
         BIND_OPTIONS+=" --unixSocketPrefix  $MONGODB_BIND_UNIX_SOCKET"
     fi
     fi
     if [ "x" != "x${MONGODB_BIND_IP}" ]; then
     if [ "x" != "x${MONGODB_BIND_IP}" ]; then
         BIND_OPTIONS+=" --bind_ip $MONGODB_BIND_IP"
         BIND_OPTIONS+=" --bind_ip $MONGODB_BIND_IP"
-        SH_BIND_OPTIONS+=" --host $MONGODB_BIND_IP"
     fi
     fi
     if [ "x" != "x${MONGODB_PORT}" ]; then
     if [ "x" != "x${MONGODB_PORT}" ]; then
         BIND_OPTIONS+=" --port $MONGODB_PORT"
         BIND_OPTIONS+=" --port $MONGODB_PORT"
-        SH_BIND_OPTIONS+=" --port $MONGODB_PORT"
     fi
     fi
     echo "mongodb bind options: $BIND_OPTIONS"
     echo "mongodb bind options: $BIND_OPTIONS"
 
 
@@ -112,16 +109,16 @@ if [ -z "$MONGO_URL" ]; then
 
 
 
 
     # Disable MongoDB telemetry and free monitoring
     # Disable MongoDB telemetry and free monitoring
-    mongosh wekan --eval 'disableTelemetry();' $SH_BIND_OPTIONS
-    mongosh wekan --eval 'db.disableFreeMonitoring();' $SH_BIND_OPTIONS
+    mongosh wekan --eval 'disableTelemetry();' $BIND_OPTIONS
+    mongosh wekan --eval 'db.disableFreeMonitoring();' $BIND_OPTIONS
     # Snap: Disable apparmor="DENIED" at syslog
     # Snap: Disable apparmor="DENIED" at syslog
     # https://github.com/wekan/wekan/issues/4855
     # https://github.com/wekan/wekan/issues/4855
-    mongosh wekan --eval 'db.adminCommand({ setParameter: 1, diagnosticDataCollectionEnabled: false});' $SH_BIND_OPTIONS
+    mongosh wekan --eval 'db.adminCommand({ setParameter: 1, diagnosticDataCollectionEnabled: false});' $BIND_OPTIONS
     # Drop indexes on database upgrade, when starting MongoDB
     # Drop indexes on database upgrade, when starting MongoDB
-    #mongosh wekan --eval "db.getCollectionNames().forEach(function(col_name) { var coll = db.getCollection(col_name); coll.dropIndexes(); });" $SH_BIND_OPTIONS
-    mongosh wekan --eval 'db.adminCommand({ setFeatureCompatibilityVersion: "4.4" });' $SH_BIND_OPTIONS
+    #mongosh wekan --eval "db.getCollectionNames().forEach(function(col_name) { var coll = db.getCollection(col_name); coll.dropIndexes(); });" $BIND_OPTIONS
+    mongosh wekan --eval 'db.adminCommand({ setFeatureCompatibilityVersion: "4.4" });' $BIND_OPTIONS
     # Delete incomplete uploads so that they would not prevent starting WeKan
     # Delete incomplete uploads so that they would not prevent starting WeKan
-    mongosh wekan --eval 'db.getCollection("cfs.attachments.filerecord").find( { "uploadedAt": { "$exists": true }, "copies.attachments" : null,"failures.copies.attachments.doneTrying" : {"$ne" : true}});' $SH_BIND_OPTIONS
+    mongosh wekan --eval 'db.getCollection("cfs.attachments.filerecord").find( { "uploadedAt": { "$exists": true }, "copies.attachments" : null,"failures.copies.attachments.doneTrying" : {"$ne" : true}});' $BIND_OPTIONS
 
 
 else
 else
 
 
@@ -141,15 +138,15 @@ else
     fi
     fi
 
 
     # Disable MongoDB telemetry and free monitoring
     # Disable MongoDB telemetry and free monitoring
-    mongosh wekan --eval 'disableTelemetry();' $SH_BIND_OPTIONS
-    mongosh wekan --eval 'db.disableFreeMonitoring();' $SH_BIND_OPTIONS
+    mongosh wekan --eval 'disableTelemetry();' $BIND_OPTIONS
+    mongosh wekan --eval 'db.disableFreeMonitoring();' $BIND_OPTIONS
     # Snap: Disable apparmor="DENIED" at syslog
     # Snap: Disable apparmor="DENIED" at syslog
     # https://github.com/wekan/wekan/issues/4855
     # https://github.com/wekan/wekan/issues/4855
-    mongosh wekan --eval 'db.adminCommand({ setParameter: 1, diagnosticDataCollectionEnabled: false});' $SH_BIND_OPTIONS
+    mongosh wekan --eval 'db.adminCommand({ setParameter: 1, diagnosticDataCollectionEnabled: false});' $BIND_OPTIONS
     # Drop indexes on database upgrade, when starting MongoDB
     # Drop indexes on database upgrade, when starting MongoDB
-    #mongosh wekan --eval "db.getCollectionNames().forEach(function(col_name) { var coll = db.getCollection(col_name); coll.dropIndexes(); });" $SH_BIND_OPTIONS
-    mongosh wekan --eval 'db.adminCommand({ setFeatureCompatibilityVersion: "4.2" });' $SH_BIND_OPTIONS
+    #mongosh wekan --eval "db.getCollectionNames().forEach(function(col_name) { var coll = db.getCollection(col_name); coll.dropIndexes(); });" $BIND_OPTIONS
+    mongosh wekan --eval 'db.adminCommand({ setFeatureCompatibilityVersion: "4.2" });' $BIND_OPTIONS
    # Delete incomplete uploads so that they would not prevent starting WeKan
    # Delete incomplete uploads so that they would not prevent starting WeKan
-    mongosh wekan --eval 'db.getCollection("cfs.attachments.filerecord").find( { "uploadedAt": { "$exists": true }, "copies.attachments" : null,"failures.copies.attachments.doneTrying" : {"$ne" : true}});' $SH_BIND_OPTIONS
+    mongosh wekan --eval 'db.getCollection("cfs.attachments.filerecord").find( { "uploadedAt": { "$exists": true }, "copies.attachments" : null,"failures.copies.attachments.doneTrying" : {"$ne" : true}});' $BIND_OPTIONS
 
 
 fi
 fi