taler-auditor.postinst (2658B)
1 #!/bin/sh 2 3 set -e 4 5 TOKEN_CONF="/etc/taler-auditor/secrets/auditor-access-token.secret.conf" 6 7 case "${1}" in 8 configure) 9 if ! getent group taler-auditor-httpd >/dev/null; 10 then 11 addgroup --quiet --system taler-auditor-httpd 12 fi 13 if ! getent passwd taler-auditor-httpd >/dev/null; 14 then 15 adduser --quiet \ 16 --system \ 17 --ingroup taler-auditor-httpd \ 18 --no-create-home \ 19 --home /var/lib/taler-auditor \ 20 taler-auditor-httpd 21 fi 22 23 if ! dpkg-statoverride --list /etc/taler-auditor/secrets/auditor-db.secret.conf >/dev/null 2>&1; 24 then 25 dpkg-statoverride --add \ 26 --update \ 27 taler-auditor-httpd taler-auditor-httpd \ 28 640 \ 29 /etc/taler-auditor/secrets/auditor-db.secret.conf 30 fi 31 if ! dpkg-statoverride --list /etc/taler-auditor/secrets/exchange-accountcredentials-1.secret.conf >/dev/null 2>&1; 32 then 33 dpkg-statoverride --add \ 34 --update \ 35 taler-auditor-httpd taler-auditor-httpd \ 36 640 \ 37 /etc/taler-auditor/secrets/exchange-accountcredentials-1.secret.conf 38 fi 39 if ! dpkg-statoverride --list ${TOKEN_CONF} >/dev/null 2>&1; 40 then 41 dpkg-statoverride --add \ 42 --update \ 43 taler-auditor-httpd taler-auditor-httpd \ 44 640 \ 45 ${TOKEN_CONF} 46 fi 47 48 # taler-auditor-httpd refuses to start without an access token, so 49 # generate one on installation. Only done while the shipped 50 # placeholder is still in place and no token is configured anywhere 51 # else, so an existing token is never overwritten. The file is 52 # already 0640 (above) when the token is written. 53 if [ -f ${TOKEN_CONF} ] \ 54 && grep -q '^# ACCESS_TOKEN = CHANGE-ME$' ${TOKEN_CONF} \ 55 && [ -z "$(taler-auditor-config -c /etc/taler-auditor/taler-auditor.conf -s auditor -o ACCESS_TOKEN 2>/dev/null || true)" ]; 56 then 57 TOKEN="secret-token:$(head -c 32 /dev/urandom | od -An -tx1 | tr -d ' \n')" 58 sed -i "s|^# ACCESS_TOKEN = CHANGE-ME$|ACCESS_TOKEN = ${TOKEN}|" ${TOKEN_CONF} 59 TOKEN="" 60 echo "taler-auditor: generated a random ACCESS_TOKEN in ${TOKEN_CONF}." >&2 61 fi 62 63 ;; 64 65 abort-upgrade | abort-remove | abort-deconfigure) ;; 66 *) 67 echo "postinst called with unknown argument \`${1}'" >&2 68 exit 1 69 ;; 70 esac 71 72 # Scripts generated by dh_installdeb are inserted below 73 74 #DEBHELPER# 75 76 exit 0