Skip to content

Commit

Permalink
fix: Update secrets file path to use .env extension
Browse files Browse the repository at this point in the history
  • Loading branch information
stephdl committed Jun 20, 2024
1 parent 03630d2 commit d431af8
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pgadmin needs a default credential to login: `[email protected]` `Nethesis,12
psql -h IP_of_Node -U postgres -d postgres -p ${TCP_PORT_PGSQL}
```

The password of postgres user can be found inside a secret file `/home/postgresql1/.config/state/secrets/passwords.secret`
The password of postgres user can be found inside a secret file `/home/postgresql1/.config/state/secrets/passwords.env`

`${TCP_PORT_PGSQL} `is set inside the environment of the module

Expand Down
4 changes: 2 additions & 2 deletions imageroot/bin/create-secrets
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fi
# restict to 400
umask 266

if [[ ! -f ~/.config/state/secrets/passwords.secret ]]; then
if [[ ! -f ~/.config/state/secrets/passwords.env ]]; then
password_postgres=$(/usr/bin/openssl rand -hex 20)
/usr/bin/echo "POSTGRES_PASSWORD=$password_postgres" > ~/.config/state/secrets/passwords.secret
/usr/bin/echo "POSTGRES_PASSWORD=$password_postgres" > ~/.config/state/secrets/passwords.env
fi
1 change: 0 additions & 1 deletion imageroot/systemd/user/pgadmin-app.service
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ After=postgresql.service pgadmin-app.service
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
EnvironmentFile=%S/state/environment
EnvironmentFile=%S/state/secrets/passwords.secret
EnvironmentFile=-%S/state/smarthost.env
WorkingDirectory=%S/state
Restart=always
Expand Down
2 changes: 1 addition & 1 deletion imageroot/systemd/user/postgresql-app.service
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ After=postgresql.service
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
EnvironmentFile=%S/state/environment
EnvironmentFile=%S/state/secrets/passwords.secret
EnvironmentFile=%S/state/secrets/passwords.env
Restart=always
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/postgresql-app.pid %t/postgresql-app.ctr-id
Expand Down
4 changes: 2 additions & 2 deletions imageroot/update-module.d/10upgrade-to-private-secrets
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ exec 1>&2

# we want to migrate from 1.0.5 when the postgres password was default and no secrets were created

if [[ ! -f ~/.config/state/secrets/passwords.secret ]]; then
if [[ ! -f ~/.config/state/secrets/passwords.env ]]; then
../bin/create-secrets
source ~/.config/state/secrets/passwords.secret
source ~/.config/state/secrets/passwords.env
# change the password of the postgres user
podman exec -ti postgresql-app sh -c "PGPASSWORD=${POSTGRES_PASSWORD} psql -U postgres -d postgres -c \"ALTER USER postgres WITH PASSWORD '${POSTGRES_PASSWORD}';\""
fi

0 comments on commit d431af8

Please sign in to comment.