68 lines
1.9 KiB
Bash
68 lines
1.9 KiB
Bash
#!/bin/sh
|
|
#
|
|
# Postinst script for mandaye-cam
|
|
#
|
|
|
|
set -e
|
|
|
|
NAME=mandaye-cam
|
|
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 CAM daemon" \
|
|
--ingroup $GROUP \
|
|
--no-create-home --home $HOME \
|
|
$USER
|
|
echo "..done"
|
|
fi
|
|
|
|
if [ ! -f /etc/$NAME/certs/saml.crt -a ! -f /etc/$NAME/certs/saml.key ]; then
|
|
echo -n "Generating key material..." >&2
|
|
openssl genpkey -algorithm rsa -pkeyopt rsa_keygen_bits:2048 -out /etc/$NAME/certs/saml.key >&2
|
|
openssl req -x509 -new -out /etc/$NAME/certs/saml.crt -subj '/CN=whocares' -key /etc/$NAME/certs/saml.key -days 3650 >&2
|
|
chown root:$GROUP /etc/$NAME/certs/saml.crt /etc/$NAME/certs/saml.key
|
|
chmod 640 /etc/$NAME/certs/saml.crt /etc/$NAME/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_cam_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
|