Skip to content

Commit ea51b26

Browse files
committed
handle PG_DATADIR is empty (or too many files)
Previous implementation passed nothing to `chmod` when PG_DATADIR is empty - this results in `chmod` raises syntax error. We also can see `Argument list too long` error when PG_DATADIR contains too many files / directries (restriction defined by ARG_MAX) Use xargs to avoid errors above
1 parent 0c081e0 commit ea51b26

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

runtime/functions

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ create_datadir() {
2929
echo "Initializing datadir..."
3030
mkdir -p ${PG_HOME}
3131
if [[ -d ${PG_DATADIR} ]]; then
32-
chmod 0600 $( find ${PG_DATADIR} -type f )
33-
chmod 0700 $( find ${PG_DATADIR} -type d )
32+
find ${PG_DATADIR} -type f | xargs chmod 0600
33+
find ${PG_DATADIR} -type d | xargs chmod 0700
3434
fi
3535
chown -R ${PG_USER}:${PG_USER} ${PG_HOME}
3636
}

0 commit comments

Comments
 (0)