29 lines
829 B
Plaintext
29 lines
829 B
Plaintext
post_install() {
|
|
if [ ! -d '/var/lib/postgres' ]; then
|
|
mkdir -p '/var/lib/postgres'
|
|
fi
|
|
if ! getent group postgres >/dev/null; then
|
|
groupadd -g 88 postgres
|
|
fi
|
|
if ! getent passwd postgres >/dev/null; then
|
|
useradd -c 'PostgreSQL user' -u 88 -g postgres -d '/var/lib/postgres' -s /bin/bash postgres
|
|
passwd -l postgres >/dev/null
|
|
fi
|
|
if [ ! -d '/var/lib/postgres/data' ]; then
|
|
mkdir -p '/var/lib/postgres/data'
|
|
chown postgres:postgres '/var/lib/postgres/data'
|
|
fi
|
|
local datadir="/var/lib/postgres/data"
|
|
echo " ==> requires datadir $datadir"
|
|
echo " ==> run as user postgres: 'initdb -D $datadir'"
|
|
|
|
postgres_shell=$(getent passwd postgres | cut -d: -f7)
|
|
if [ "$postgres_shell" != '/bin/bash' ]; then
|
|
chsh -s /bin/bash postgres &>/dev/null
|
|
fi
|
|
}
|
|
|
|
post_upgrade() {
|
|
post_install $1
|
|
}
|