Skip to content

Commit

Permalink
Chown.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 committed Feb 6, 2024
1 parent 3cd686e commit 7b4ee55
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/internal/database/postgres/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,24 @@ func (db *Postgres) Upgrade(ctx context.Context) error {
if err != nil {
return err
}
gid, err := strconv.Atoi(pgUser.Gid)
if err != nil {
return err
}

// remove /data/postgres-new if present
newDataDirTemp := path.Join("/data", "postgres-new")
newDataDirTemp := path.Join("/data", "postgres-new") // TODO: /data should not be hardcoded
err = os.RemoveAll(newDataDirTemp)
if err != nil {
db.log.Errorw("unable to remove new datadir, skipping upgrade", "error", err)
return nil
}

err = os.Chown("/data", uid, gid)
if err != nil {
return err
}

// initdb -D /data/postgres-new
cmd := exec.Command(postgresInitDBCmd, "-D", newDataDirTemp)
cmd.Stdout = os.Stdout
Expand Down

0 comments on commit 7b4ee55

Please sign in to comment.