This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
wcsinst/debian/wcsinstd.postinst

78 lines
2.1 KiB
Bash

#!/bin/sh
#
# Postinst script for wcsinstd
#
set -e
NAME=wcsinstd
WCSINSTD_USER=wcs-au-quotidien
WCSINSTD_GROUP=wcs-au-quotidien
WCSINSTD_HOME=/var/lib/$NAME
WCSINSTD_INIT=/etc/init.d/$NAME
case "$1" in
configure)
if ! getent group $WCSINSTD_GROUP > /dev/null 2>&1; then
echo -n "Adding group $WCSINSTD_GROUP.."
addgroup --quiet --system $WCSINSTD_GROUP
echo "..done"
fi
if ! getent passwd $WCSINSTD_USER > /dev/null 2>&1; then
echo -n "Adding user $WCSINSTD_USER.."
adduser --quiet --system --gecos "wcsinst daemon" \
--ingroup $WCSINSTD_GROUP \
--no-create-home --home $WCSINSTD_HOME \
$WCSINSTD_USER
echo "..done"
fi
chown -R $WCSINSTD_USER:$WCSINSTD_GROUP $WCSINSTD_HOME /var/run/$NAME /var/log/$NAME
chown -R $WCSINSTD_USER:$WCSINSTD_GROUP $WCSINSTD_HOME/static $WCSINSTD_HOME/extra-static
chown -R $WCSINSTD_USER:$WCSINSTD_GROUP $WCSINSTD_HOME/media $WCSINSTD_HOME/templates
# echo -n "Initializing sqlite database.."
# $WCSINSTD_INIT manage syncdb --migrate
if [ ! -f /etc/$NAME/secret ]; then
echo -n "Generating secret.."
dd if=/dev/random ibs=1 count=32 2>/dev/null >/etc/$NAME/secret
echo "..done"
fi
echo -n "Generating static files.."
$WCSINSTD_INIT manage collectstatic --noinput --link
echo "..done"
;;
reconfigure)
echo -n "Generating static files.."
$WCSINSTD_INIT manage collectstatic --noinput --link
echo "..done"
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
case "$1" in
configure)
if [ -z "$2" ]; then
# echo -n "Initializing sqlite database.."
# $WCSINSTD_INIT manage syncdb --migrate
true
fi
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0