Add the Perl commands to set the lc_time and lc_messages to English during Postgres installations.
Remove the LC_ALL setting from the macOS setup, as it is no longer required.
Setup a PGDATA variable for the Linux system as this is not set by the current commands
One parameter is specified per line. The equal sign between name and value is optional. Whitespace is insignificant (except within a quoted parameter value) and blank lines are ignored. Hash marks (#) designate the remainder of the line as a comment. Parameter values that are not simple identifiers or numbers must be single-quoted. To embed a single quote in a parameter value, write either two quotes (preferred) or backslash-quote. If the file contains multiple entries for the same parameter, all but the last one are ignored.
~ perl -i -pe 's/^[#\s]*lc_messages\s*=.+$/lc_messages = '\''en_US.UTF-8'\''/' testings/testee.conf
Can't open testings/testee.conf: No such file or directory.
Setting the lc_messages in the postgresql.conf file
macOS
PGDATA is already being set on macOS, and the postgresql.conf file is always inside there
To edit the postgres.conf file and set the `lc_message = 'en_US.UTF-8'. Any of the following commands can be used
sed: sed is available by default in macOS
Sets error message to sed if the wanted file is not found
sed -i -E "/^[[:space:]]*lc_messages[[:space:]]*=/ s/^#*.*$/lc_messages = 'en_US.UTF-8'/" "$PGDATA/postgresql.conf" || echo "File $PGDATA/postgresql.conf does not exist" >&2
Allows sed returns default error message if wanted file is not found
sed -i -E "/^[[:space:]]*lc_messages[[:space:]]*=/ s/^#*.*$/lc_messages = 'en_US.UTF-8'/" "$PGDATA/postgresql.conf"
~ awk '/^[[:space:]]*lc_messages[[:space:]]*=/{gsub(/=.*/, "= '\''en_US.UTF-8'\''")}1' "nothing/postgresql.conf" > temp && mv temp "nothing/postgresql.conf"
awk: can't open file nothing/postgresql.conf
source line number 1
Linux
The PGDATA cannot be set in Linux as the location could change depending on the Linux distribution being run. The path to the postgresql.conf file should be determined dynamically
Closes https://github.com/upleveled/system-setup/issues/73
Add the Perl commands to set the
lc_time
andlc_messages
to English during Postgres installations. Remove theLC_ALL
setting from the macOS setup, as it is no longer required. Setup aPGDATA
variable for the Linux system as this is not set by the current commandsWindows
The current setup doesn't set language
After the PR, the language is set
postgresql.conf
file spechttps://www.postgresql.org/docs/current/config-setting.html#:~:text=Whitespace%20is%20insignificant%20(except%20within%20a%20quoted%20parameter%20value)%20and%20blank%20lines%20are%20ignored
Perl error when file not found
Setting the lc_messages in the
postgresql.conf
filemacOS
PGDATA
is already being set onmacOS
, and thepostgresql.conf
file is always inside thereTo edit the
postgres.conf
file and set the `lc_message = 'en_US.UTF-8'. Any of the following commands can be usedsed
: sed is available by default in macOSSets error message to sed if the wanted file is not found
Allows sed returns default error message if wanted file is not found
If the wanted file is available Before command
After command
Other possible commands on macOS Using
perl
perl error:
Can't open nothing/postgresql.conf: No such file or directory.
Using
awk
awk error:
Linux
The
PGDATA
cannot be set in Linux as the location could change depending on the Linux distribution being run. The path to thepostgresql.conf
file should be determined dynamicallyUsing
sed
Using
perl
Using
awk
Tested with a Linux + PostgreSQL Docker image setup using the progress installation from the system setup
Before command
After command
postgresql.conf
file pathWindows
Using hyper as this will enable us use the same commands we already used for macOS and Linux
Using sed
Using perl
Using awk
Before command
After command
Errors when the file is not found