summaryrefslogtreecommitdiff
path: root/testing/postgresql/postgresql.install
blob: 263bccb2557907484928b54e20060c65df2842d6 (plain)
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
32
33
34
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
}

post_upgrade() {
  post_install $1
  # FS#23858, fix postgres user shell issue
  postgres_shell=$(getent passwd postgres | cut -d: -f7)
  if [ "$postgres_shell" = "/sbin/nologin" ]; then
    chsh -s /bin/bash postgres
  fi
  if [ $(vercmp $2 '9.2.1-2') -lt 0 ]; then
    echo "Note: The Unix domain socket location has changed; be sure to"
    echo "      restart any local applications using libpq.so."
  fi
}

post_remove() {
  if getent passwd postgres >/dev/null; then
    userdel postgres
  fi
  if getent group postgres >/dev/null; then
    groupdel postgres
  fi
}