fix(installer): set home and login when running as postgres

Remove warnings if the current dir is not writable by postgres
This commit is contained in:
jo 2022-12-08 16:03:36 +01:00 committed by Kyle Robbertze
parent 1f7852d13b
commit 3b8638cd15
1 changed files with 7 additions and 7 deletions

14
install
View File

@ -434,11 +434,11 @@ if $LIBRETIME_SETUP_POSTGRESQL; then
if $is_first_install; then if $is_first_install; then
# TODO: Swap lines when Bionic support is dropped # TODO: Swap lines when Bionic support is dropped
# if ! sudo -u postgres psql --csv --tuples-only --command='\du' | grep -qw "^$LIBRETIME_POSTGRESQL_USER"; then # if ! sudo -iH -u postgres psql --csv --tuples-only --command='\du' | grep -qw "^$LIBRETIME_POSTGRESQL_USER"; then
if ! sudo -u postgres psql --tuples-only --command='\du' | grep -qw "$LIBRETIME_POSTGRESQL_USER"; then if ! sudo -iH -u postgres psql --tuples-only --command='\du' | grep -qw "$LIBRETIME_POSTGRESQL_USER"; then
info "creating PostgreSQL user '$LIBRETIME_POSTGRESQL_USER'" info "creating PostgreSQL user '$LIBRETIME_POSTGRESQL_USER'"
sudo -u postgres createuser "$LIBRETIME_POSTGRESQL_USER" sudo -iH -u postgres createuser "$LIBRETIME_POSTGRESQL_USER"
sudo -u postgres psql -c "ALTER ROLE $LIBRETIME_POSTGRESQL_USER WITH PASSWORD '$LIBRETIME_POSTGRESQL_PASSWORD';" sudo -iH -u postgres psql -c "ALTER ROLE $LIBRETIME_POSTGRESQL_USER WITH PASSWORD '$LIBRETIME_POSTGRESQL_PASSWORD';"
set_config "$LIBRETIME_POSTGRESQL_USER" database user set_config "$LIBRETIME_POSTGRESQL_USER" database user
set_config "$LIBRETIME_POSTGRESQL_PASSWORD" database password set_config "$LIBRETIME_POSTGRESQL_PASSWORD" database password
@ -447,10 +447,10 @@ if $LIBRETIME_SETUP_POSTGRESQL; then
fi fi
# TODO: Swap lines when Bionic support is dropped # TODO: Swap lines when Bionic support is dropped
# if ! sudo -u postgres psql --csv --tuples-only --list | grep -qw "^$LIBRETIME_POSTGRESQL_DATABASE"; then # if ! sudo -iH -u postgres psql --csv --tuples-only --list | grep -qw "^$LIBRETIME_POSTGRESQL_DATABASE"; then
if ! sudo -u postgres psql --tuples-only --list | grep -qw "$LIBRETIME_POSTGRESQL_DATABASE"; then if ! sudo -iH -u postgres psql --tuples-only --list | grep -qw "$LIBRETIME_POSTGRESQL_DATABASE"; then
info "creating PostgreSQL database '$LIBRETIME_POSTGRESQL_DATABASE' with owner '$LIBRETIME_POSTGRESQL_USER'" info "creating PostgreSQL database '$LIBRETIME_POSTGRESQL_DATABASE' with owner '$LIBRETIME_POSTGRESQL_USER'"
sudo -u postgres createdb --template=template0 --encoding=UTF-8 --owner="$LIBRETIME_POSTGRESQL_USER" "$LIBRETIME_POSTGRESQL_DATABASE" sudo -iH -u postgres createdb --template=template0 --encoding=UTF-8 --owner="$LIBRETIME_POSTGRESQL_USER" "$LIBRETIME_POSTGRESQL_DATABASE"
set_config "$LIBRETIME_POSTGRESQL_DATABASE" database name set_config "$LIBRETIME_POSTGRESQL_DATABASE" database name
else else