File: connect

package info (click to toggle)
pgagroal 2.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,396 kB
  • sloc: ansic: 39,212; sh: 687; python: 272; makefile: 36; sql: 13
file content (31 lines) | stat: -rwxr-xr-x 832 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/sh

set -eux

bailout () {
  if test -d /run/systemd/system; then
    systemctl stop pgagroal pgagroal.socket
  else
    pkill pgagroal
  fi
}
trap bailout EXIT

if [ -z "$(pg_lsclusters -h)" ]; then
  version=$(ls /usr/lib/postgresql -v | tail -1)
  pg_createcluster $version main
fi

service postgresql start
if test -d /run/systemd/system; then
  systemctl stop pgagroal pgagroal.socket
  # socket activation is broken (https://github.com/pgagroal/pgagroal/issues/736), test only the .service for now:
  systemctl start pgagroal.service
else
  su -c 'pgagroal' postgres &
fi

PW=agroalpass
su -c "dropuser --if-exists agroaltestuser" postgres
su -c "( echo $PW; echo $PW ) | createuser --pwprompt agroaltestuser" postgres
PGPASSWORD=$PW psql -h /run/postgresql -p 2345 -U agroaltestuser -c 'select 6*7' postgres | grep 42