Skip to content

Commit

Permalink
chore: Fix PATH getting reset by su (#34286)
Browse files Browse the repository at this point in the history
The `PATH` env variable gets reset to it's original value by `su`,
because its a "secure" env variable, and is _never_ preserved across
user-switches.

Because of this, the Postgres commands like `initdb` are not found on
the `PATH`. This PR fixes this by setting the `PATH` in the command
passed to `su` itself, so that `initdb` can now be found.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Improved the initialization process for local Postgres data folder to
ensure compatibility with environment variables.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
sharat87 committed Jun 17, 2024
1 parent 842ac10 commit a638c47
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion deploy/docker/fs/opt/appsmith/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ init_postgres() {

if [[ ! -e "$POSTGRES_DB_PATH/PG_VERSION" ]]; then
tlog "Initializing local Postgres data folder"
su postgres -c "initdb -D $POSTGRES_DB_PATH"
su postgres -c "env PATH='$PATH' initdb -D $POSTGRES_DB_PATH"
fi
else
runEmbeddedPostgres=0
Expand Down

0 comments on commit a638c47

Please sign in to comment.