43 lines
1.0 KiB
Bash
Executable File
43 lines
1.0 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
install_postresql_packages()
|
|
{
|
|
pkg_add postgresql-client-15.2 postgresql-server-15.2
|
|
}
|
|
|
|
configure_postgresql_service()
|
|
{
|
|
cp -v default_configuration/postgresql/pg_hba.conf my_configuration/postgresql/pg_hba.conf
|
|
}
|
|
|
|
make_data_directory()
|
|
{
|
|
su -m _postgresql -c "mkdir /var/postgresql/data"
|
|
echo $postgresql_root_password > /tmp/passwordpsql.txt
|
|
[ ! -d "/var/postgresql/data" ] || mv /var/postgresql/data /var/postgresql/data.old
|
|
su -m _postgresql -c "initdb -D /var/postgresql/data -U postgres -A scram-sha-256 -E UTF8 --pwfile=/tmp/passwordpsql.txt"
|
|
rm /tmp/passwordpsql.txt
|
|
}
|
|
|
|
install_postgresql_configurations_files()
|
|
{
|
|
cp -v my_configuration/postgresql/pg_hba.conf /var/postgresql/data/pg_hba.conf
|
|
}
|
|
|
|
start_postgresql_service()
|
|
{
|
|
rcctl start postgresql
|
|
}
|
|
|
|
|
|
if [ "$1" == "gen-config-only" ];
|
|
then
|
|
configure_postgresql_service
|
|
elif [ "$1" == "install" ];
|
|
then
|
|
install_postresql_packages
|
|
configure_postgresql_service
|
|
install_postgresql_configurations_files
|
|
start_postgresql_service
|
|
fi
|