aboutsummaryrefslogtreecommitdiff
path: root/debian/boca-common.postinst
blob: 3ff74f122a76a8f7ec35e3dfa03936e4c6b79ade (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
set -e

chmod 700 /usr/sbin/boca-config-dbhost
chmod 700 /usr/sbin/boca-fixssh

. /usr/share/debconf/confmodule

priority=high

case "$1" in
  configure|reconfigure)
    if [[ -e "/etc/boca.conf" ]]; then
      . /etc/boca.conf
      if [[ "$bdserver" != "" ]]; then
        echo "If you want to reset DB configuration, please unset \"bdserver\" in /etc/boca.conf"
        exit 0
      fi
    fi
    db_input high boca-common/dbhost || true
    db_go || true

    db_get boca-common/dbhost || true
    DBHOST="$RET"

    if [[ "x$DBHOST" == "x" ]]; then
      DBHOST=localhost
    fi

    db_input high boca-common/dbpassword || true
    db_go || true

    db_get boca-common/dbpassword || true
    PASSWORD="$RET"

    if [[ "x$PASSWORD" == "x" ]]; then
      printf "Generating password with makepasswd"
      PASSWORD="$(makepasswd --chars 20)"
      echo .
    fi
    export PASSWD="$PASSWORD"
    boca-config-dbhost $DBHOST
    unset PASSWD
    ;;
  *)
    ;;
esac

chmod 600 /var/www/boca/src/private/conf.php
chown www-data:www-data /var/www/boca/src/private/conf.php

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0