diff options
Diffstat (limited to 'debian/postinst')
-rw-r--r-- | debian/postinst | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..ff6d28f --- /dev/null +++ b/debian/postinst @@ -0,0 +1,42 @@ +#!/bin/sh +# Reference: https://salsa.debian.org/sssd-team/sssd/-/blob/experimental/debian/sssd-common.postinst +set -e + +#DEBHELPER# + +OUT=/dev/null +USERNAME=hex-zero +HOME=/var/www/hex-zero + +case "$1" in + configure) + update-rc.d hex-zero defaults + if ! getent passwd ${USERNAME} 1>${OUT} 2>&1 ; + then + echo "Creating ${USERNAME} system user & group..." + adduser --quiet --system --home $HOME \ + --disabled-password --group \ + --gecos "0x0 system user" \ + ${USERNAME} > ${OUT} + fi + if ! test -r /var/www/hex-zero/db.sqlite || test $( stat -c "%s" /var/www/hex-zero/db.sqlite 2>/dev/null ) -lt 50 ; + then + echo "Initializing sqlite database for hex-zero" + su ${USER} -c 'cd /var/www/hex-zero ; /var/www/hex-zero/hex_zero.py db init' 2>/dev/null || : + su ${USER} -c 'cd /var/www/hex-zero ; /var/www/hex-zero/hex_zero.py db upgrade' + fi + chown ${USERNAME}:${USERNAME} \ + ${HOME} ${HOME}/* \ + /var/log/hex-zero /var/log/hex-zero/*log 1>/${OUT} 2>&1 || : + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +exit 0 |