desktop-ubuntu/postgres/_install.sh

46 lines
958 B
Bash
Raw Permalink Normal View History

2023-06-18 15:34:39 +02:00
#!/usr/bin/zsh
# Postgres
# the `lsb_release` prints linux-mint's codename
# of which pg has no idea, so
U='UBUNTU_CODENAME='
DISTRO=`cat '/etc/os-release' | grep "$U"`
if [ ! -z "$DISTRO" ]; then
DISTRO="${DISTRO/$U/}"
else
DISTRO=`lsb_release -cs`
fi
echo "DISTRO: '$DISTRO'"
SRC="deb http://apt.postgresql.org/pub/repos/apt $DISTRO-pgdg main"
2024-04-23 14:31:53 +02:00
sudo sh -c \
2023-06-18 15:34:39 +02:00
"echo '$SRC' > /etc/apt/sources.list.d/pgdg.list"
curl -sS 'https://www.postgresql.org/media/keys/ACCC4CF8.asc' \
| gpg --dearmor \
| sudo tee /etc/apt/trusted.gpg.d/postgresql.gpg
2024-04-23 14:31:53 +02:00
sudo apt update -y
sudo apt install -y \
2024-01-20 18:10:59 +01:00
postgresql
2023-06-18 15:34:39 +02:00
sudo systemctl start \
2024-04-23 14:31:53 +02:00
postgresql
# postgresql-client
2024-01-20 18:10:59 +01:00
VER=`psql --version | grep -Eo ' [0-9]+\.[0-9]+ ' | grep -Eo ' [0-9]+' | xargs`
2024-04-23 14:31:53 +02:00
echo $VER
2023-06-18 15:34:39 +02:00
2024-01-20 18:10:59 +01:00
sudo nano /etc/postgresql/$VER/main/pg_hba.conf
2023-06-18 15:34:39 +02:00
# `local all all trust`
sudo systemctl restart postgresql.service
2024-04-23 14:31:53 +02:00
sudo psql -U postgres
2023-06-18 15:34:39 +02:00
```
ALTER USER postgres WITH PASSWORD 'postgres';
exit;
```