conf_server/install_postgresql_service.sh

43 lines
1.0 KiB
Bash
Raw Normal View History

2023-01-11 01:03:34 +01:00
#!/bin/sh
install_postresql_packages()
{
2023-05-15 23:16:25 +02:00
pkg_add postgresql-client-15.2 postgresql-server-15.2
2023-01-11 01:03:34 +01:00
}
configure_postgresql_service()
{
2023-05-15 23:16:25 +02:00
cp -v default_configuration/postgresql/pg_hba.conf my_configuration/postgresql/pg_hba.conf
}
2023-01-11 01:03:34 +01:00
2023-05-15 23:16:25 +02:00
make_data_directory()
{
2023-01-11 01:03:34 +01:00
su -m _postgresql -c "mkdir /var/postgresql/data"
echo $postgresql_root_password > /tmp/passwordpsql.txt
2023-05-15 23:16:25 +02:00
[ ! -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
2023-01-11 01:03:34 +01:00
}
2023-05-15 23:16:25 +02:00
install_postgresql_configurations_files()
{
2023-01-11 01:03:34 +01:00
cp -v my_configuration/postgresql/pg_hba.conf /var/postgresql/data/pg_hba.conf
}
2023-05-15 23:16:25 +02:00
start_postgresql_service()
{
2023-01-11 01:03:34 +01:00
rcctl start postgresql
}
2023-05-15 23:16:25 +02:00
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