epic-ts
[kivitendo-erp.git] / debian / kivitendo.postinst
1 #!/bin/sh
2 set -e
3
4 # kivitendo postinst
5
6 # check configuration file
7 if [ ! -e /opt/kivitendo-erp/config/kivitendo.conf ]
8 then
9         echo "Type new kivitendo admin and DB password:"
10         read a
11         sed "s/admin123/$a/" /opt/kivitendo-erp/config/kivitendo.conf.default >/opt/kivitendo-erp/config/kivitendo.conf
12 fi
13
14 # test DB login
15 if ! su postgres -c "psql -c '\du'" | grep kivitendo >/dev/null
16 then
17         echo "No user named 'kivitendo' found. It is now created. Use the same password!"
18         su postgres -c "createuser -dPs kivitendo"
19 fi
20 main=$(ls -d /etc/postgresql/*/main/)
21 if ! grep kivitendo $main/pg_hba.conf >/dev/null
22 then
23         echo "local   all   kivitendo   md5" >> $main/pg_hba.conf
24         systemctl reload postgresql
25 fi
26
27 # allow write access to some directories
28 chown www-data /opt/kivitendo-erp/users /opt/kivitendo-erp/templates
29 chgrp www-data /opt/kivitendo-erp/users /opt/kivitendo-erp/templates
30
31 systemctl restart apache2
32
33 # call installation check
34 /opt/kivitendo-erp/scripts/installation_check.pl
35
36 if [ ! -d /opt/kivitendo-erp/webdav ]
37 then
38         mkdir /opt/kivitendo-erp/webdav
39         chown www-data:www-data /opt/kivitendo-erp/webdav
40 fi
41