Skip to content

Commit

Permalink
fix bug when /data/configdb or /data/db not exist (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
DevineLiu authored Sep 21, 2021
1 parent 5be6098 commit a80ff54
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
7 changes: 6 additions & 1 deletion percona-server-mongodb-3.4/ps-entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ originalArgOne="$1"
# all mongo* commands should be dropped to the correct user
if [[ "$originalArgOne" == mongo* ]] && [ "$(id -u)" = '0' ]; then
if [ "$originalArgOne" = 'mongod' ]; then
find /data/configdb /data/db \! -user mongodb -exec chown mongodb '{}' +
if [ -d "/data/configdb" ]; then
find /data/configdb \! -user mongodb -exec chown mongodb '{}' +
fi
if [ -d "/data/db" ]; then
find /data/db \! -user mongodb -exec chown mongodb '{}' +
fi
fi

# make sure we can write to stdout and stderr as "mongodb"
Expand Down
7 changes: 6 additions & 1 deletion percona-server-mongodb-3.6/ps-entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ originalArgOne="$1"
# all mongo* commands should be dropped to the correct user
if [[ "$originalArgOne" == mongo* ]] && [ "$(id -u)" = '0' ]; then
if [ "$originalArgOne" = 'mongod' ]; then
find /data/configdb /data/db \! -user mongodb -exec chown mongodb '{}' +
if [ -d "/data/configdb" ]; then
find /data/configdb \! -user mongodb -exec chown mongodb '{}' +
fi
if [ -d "/data/db" ]; then
find /data/db \! -user mongodb -exec chown mongodb '{}' +
fi
fi

# make sure we can write to stdout and stderr as "mongodb"
Expand Down
7 changes: 6 additions & 1 deletion percona-server-mongodb-4.0/ps-entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ originalArgOne="$1"
# all mongo* commands should be dropped to the correct user
if [[ "$originalArgOne" == mongo* ]] && [ "$(id -u)" = '0' ]; then
if [ "$originalArgOne" = 'mongod' ]; then
find /data/configdb /data/db \! -user mongodb -exec chown mongodb '{}' +
if [ -d "/data/configdb" ]; then
find /data/configdb \! -user mongodb -exec chown mongodb '{}' +
fi
if [ -d "/data/db" ]; then
find /data/db \! -user mongodb -exec chown mongodb '{}' +
fi
fi

# make sure we can write to stdout and stderr as "mongodb"
Expand Down
7 changes: 6 additions & 1 deletion percona-server-mongodb-4.2/ps-entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ originalArgOne="$1"
# all mongo* commands should be dropped to the correct user
if [[ "$originalArgOne" == mongo* ]] && [ "$(id -u)" = '0' ]; then
if [ "$originalArgOne" = 'mongod' ]; then
find /data/configdb /data/db \! -user mongodb -exec chown mongodb '{}' +
if [ -d "/data/configdb" ]; then
find /data/configdb \! -user mongodb -exec chown mongodb '{}' +
fi
if [ -d "/data/db" ]; then
find /data/db \! -user mongodb -exec chown mongodb '{}' +
fi
fi

# make sure we can write to stdout and stderr as "mongodb"
Expand Down
7 changes: 6 additions & 1 deletion percona-server-mongodb-4.4/ps-entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ originalArgOne="$1"
# all mongo* commands should be dropped to the correct user
if [[ "$originalArgOne" == mongo* ]] && [ "$(id -u)" = '0' ]; then
if [ "$originalArgOne" = 'mongod' ]; then
find /data/configdb /data/db \! -user mongodb -exec chown mongodb '{}' +
if [ -d "/data/configdb" ]; then
find /data/configdb \! -user mongodb -exec chown mongodb '{}' +
fi
if [ -d "/data/db" ]; then
find /data/db \! -user mongodb -exec chown mongodb '{}' +
fi
fi

# make sure we can write to stdout and stderr as "mongodb"
Expand Down

0 comments on commit a80ff54

Please sign in to comment.