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.
mandaye-meyzieu/debian/postinst

66 lines
2.0 KiB
Bash

#!/bin/sh
#
# Postinst script for mandaye-meyzieu
#
set -e
NAME=mandaye-meyzieu
USER=$NAME
GROUP=$NAME
HOME=/var/lib/$NAME
case "$1" in
configure)
if ! getent group $GROUP > /dev/null 2>&1; then
echo -n "Adding group $GROUP.."
addgroup --quiet --system $GROUP
echo "..done"
fi
if ! getent passwd $USER > /dev/null 2>&1; then
echo -n "Adding user $USER.."
adduser --quiet --system --gecos "Mandaye Meyzieu daemon" \
--ingroup $GROUP \
--no-create-home --home $HOME \
$USER
echo "..done"
fi
if [ ! -f /etc/mandaye-meyzieu/certs/saml.crt -a ! -f /etc/mandaye-meyzieu/certs/saml.key ]; then
echo -n "Generating key material..." >&2
openssl genpkey -algorithm rsa -pkeyopt rsa_keygen_bits:2048 -out /etc/mandaye-meyzieu/certs/saml.key >&2
openssl req -x509 -new -out /etc/mandaye-meyzieu/certs/saml.crt -subj '/CN=whocares' -key /etc/mandaye-meyzieu/certs/saml.key -days 3650 >&2
chown root:$GROUP /etc/mandaye-meyzieu/certs/saml.crt /etc/mandaye-meyzieu/certs/saml.key
chmod 640 /etc/mandaye-meyzieu/certs/saml.crt /etc/mandaye-meyzieu/certs/saml.key
echo "..done" >&2
fi
echo -n "Fixing permissions.."
chown $USER:$GROUP /var/lib/$NAME /var/run/$NAME /var/log/$NAME
chown $USER:$GROUP /var/lib/$NAME/data /var/lib/$NAME/sessions
echo "..done"
if [ -z "$2" ]; then
echo "Please create your database :"
echo "su $USER -p -c '/usr/bin/mandaye_meyzieu_manager --createdb'"
fi
;;
reconfigure)
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0