aboutsummaryrefslogtreecommitdiff
path: root/debian/anastasis-httpd.postinst
diff options
context:
space:
mode:
Diffstat (limited to 'debian/anastasis-httpd.postinst')
-rw-r--r--debian/anastasis-httpd.postinst93
1 files changed, 93 insertions, 0 deletions
diff --git a/debian/anastasis-httpd.postinst b/debian/anastasis-httpd.postinst
new file mode 100644
index 0000000..77acf49
--- /dev/null
+++ b/debian/anastasis-httpd.postinst
@@ -0,0 +1,93 @@
1#!/bin/bash
2
3set -e
4
5_USERNAME=anastasis-httpd
6_GROUPNAME=www-data
7
8# Set permissions for sqlite3 file
9# (for when we support sqlite3 in the future)
10dbc_dbfile_owner="${_USERNAME}:${_GROUPNAME}"
11dbc_dbfile_perms="0600"
12
13# 1st argument will be the SECURITYTOKEN to use.
14apache_install() {
15 echo -n "Starting Apache setup..."
16 mkdir -p /etc/apache2/conf-available
17 if [ ! -f /etc/apache2/conf-available/anastasis.conf ]; then
18 echo -n "..."
19 cat /etc/anastasis/apache.conf | sed -e "s/%SECURITYTOKEN%/$1/" >/etc/apache2/conf-available/anastasis.conf
20 fi
21 echo "Done"
22}
23
24# 1st argument will be the SECURITYTOKEN to use.
25nginx_install() {
26 echo -n "Starting Nginx setup..."
27 mkdir -p /etc/nginx/conf-available
28 if [ ! -f /etc/nginx/conf-available/anastasis.conf ]; then
29 echo -n "..."
30 cat /etc/anastasis/nginx.conf | sed -e "s/%SECURITYTOKEN%/$1/" >/etc/nginx/conf-available/anastasis.conf
31 fi
32 echo "Done"
33}
34
35. /usr/share/debconf/confmodule
36
37case "${1}" in
38configure)
39 db_start
40 db_version 2.0
41
42 # Read default values
43 CONFIG_FILE="/etc/default/anastasis"
44 TALER_HOME="/var/lib/taler/"
45
46 echo " User setup"
47 # Creating taler users if needed
48 if ! getent passwd ${_USERNAME} >/dev/null; then
49 adduser --quiet --system --ingroup ${_GROUPNAME} --home ${TALER_HOME} ${_USERNAME}
50 fi
51
52 # Setup postgres database (needs dbconfig-pgsql package)
53 if [ -f /usr/share/dbconfig-common/dpkg/postinst.pgsql ]; then
54 . /usr/share/dbconfig-common/dpkg/postinst.pgsql
55 dbc_pgsql_createdb_encoding="UTF8"
56 dbc_go anastasis "$@"
57 fi
58
59 cat >"/etc/systemd/system/anastasis-httpd.service" <<EOF
60EOF
61
62 # Configure Webserver
63 echo " Configuring Webserver"
64 db_get anastasis/reconfigure-webserver
65 webservers="$RET"
66 for webserver in $webservers; do
67 webserver=${webserver%,}
68 if [ "$webserver" = "nginx" ]; then
69 nginx_install "$SECRET"
70 else
71 apache_install "$SECRET"
72 fi
73 done
74 echo "Done."
75
76 db_stop
77
78 # Cleaning
79 echo "All done."
80
81 ;;
82
83abort-upgrade | abort-remove | abort-deconfigure) ;;
84
85 *)
86 echo "postinst called with unknown argument \`${1}'" >&2
87 exit 1
88 ;;
89esac
90
91#DEBHELPER#
92
93exit 0