summaryrefslogtreecommitdiffstats
path: root/debian/knot.postinst
blob: 7a69d85a176f0a9d0ec81d0f8a344d6eadef2754 (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
#!/bin/sh
set -e

if [ "$1" = "configure" ]; then
    if ! getent passwd knot > /dev/null; then
        adduser --quiet --system --group --no-create-home --home /var/lib/knot knot
    fi

    dpkg-statoverride --list /var/lib/knot > /dev/null || dpkg-statoverride --update --add knot knot 0755 /var/lib/knot
    dpkg-statoverride --list /etc/knot/knot.conf > /dev/null || dpkg-statoverride --update --add knot knot 0640 /etc/knot/knot.conf
    dpkg-statoverride --list /etc/knot > /dev/null || dpkg-statoverride --update --add knot knot 0750 /etc/knot    
fi

if [ "$1" = "configure" ] && [ -n "$2" ] && dpkg --compare-versions "$2" lt "2.5.0-1~"; then
    KNOT_USER=$(/usr/lib/knot/get_user 2>/dev/null || echo "knot")

    /usr/lib/knot/get_kaspdb | while read KASPDB; do
	if [ ! -f "${KASPDB}/data.mdb" ]; then
	    runuser -u "${KNOT_USER}" -- /usr/lib/knot/kasp_json2lmdb -i "${KASPDB}"
	fi
    done
fi

#DEBHELPER#

exit 0