81 lines
2.9 KiB
Bash
81 lines
2.9 KiB
Bash
#!/bin/bash
|
|
# postinst script for jitsi-meet-prosody
|
|
#
|
|
# see: dh_installdeb(1)
|
|
|
|
set -e
|
|
|
|
# summary of how this script can be called:
|
|
# * <postinst> `configure' <most-recently-configured-version>
|
|
# * <old-postinst> `abort-upgrade' <new version>
|
|
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
|
|
# <new-version>
|
|
# * <postinst> `abort-remove'
|
|
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
|
|
# <failed-install-package> <version> `removing'
|
|
# <conflicting-package> <version>
|
|
# for details, see http://www.debian.org/doc/debian-policy/ or
|
|
# the debian-policy package
|
|
|
|
|
|
case "$1" in
|
|
configure)
|
|
|
|
. /etc/jitsi/videobridge/config
|
|
|
|
# loading debconf
|
|
. /usr/share/debconf/confmodule
|
|
|
|
# stores the hostname so we will reuse it later, like in purge
|
|
db_set jitsi-meet-prosody/jvb-hostname $JVB_HOSTNAME
|
|
|
|
# and we're done with debconf
|
|
db_stop
|
|
|
|
PROSODY_CONFIG_PRESENT="true"
|
|
PROSODY_HOST_CONFIG="/etc/prosody/conf.avail/$JVB_HOSTNAME.cfg.lua"
|
|
# if there is no prosody config extract our template
|
|
# check for config in conf.avail or check whether it wasn't already configured in main config
|
|
if [ ! -f $PROSODY_HOST_CONFIG ] && ! grep -q "VirtualHost \"$JVB_HOSTNAME\"" /etc/prosody/prosody.cfg.lua; then
|
|
PROSODY_CONFIG_PRESENT="false"
|
|
cp /usr/share/doc/jitsi-meet-prosody/prosody.cfg.lua-jvb.example $PROSODY_HOST_CONFIG
|
|
sed -i "s/jitmeet.example.com/$JVB_HOSTNAME/g" $PROSODY_HOST_CONFIG
|
|
sed -i "s/jitmeetSecret/$JVB_SECRET/g" $PROSODY_HOST_CONFIG
|
|
if [ ! -f /etc/prosody/conf.d/$JVB_HOSTNAME.cfg.lua ]; then
|
|
ln -s $PROSODY_HOST_CONFIG /etc/prosody/conf.d/$JVB_HOSTNAME.cfg.lua
|
|
fi
|
|
fi
|
|
|
|
if [ ! -f /var/lib/prosody/$JVB_HOSTNAME.crt ]; then
|
|
HOST="$( (hostname -s; echo localhost) | head -n 1)"
|
|
DOMAIN="$( (hostname -d; echo localdomain) | head -n 1)"
|
|
openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj \
|
|
"/O=$DOMAIN/OU=$HOST/CN=$JVB_HOSTNAME/emailAddress=webmaster@$HOST.$DOMAIN" \
|
|
-keyout /var/lib/prosody/$JVB_HOSTNAME.key \
|
|
-out /var/lib/prosody/$JVB_HOSTNAME.crt
|
|
fi
|
|
ln -sf /var/lib/prosody/$JVB_HOSTNAME.key /etc/prosody/certs/$JVB_HOSTNAME.key
|
|
ln -sf /var/lib/prosody/$JVB_HOSTNAME.crt /etc/prosody/certs/$JVB_HOSTNAME.crt
|
|
|
|
if [ "$PROSODY_CONFIG_PRESENT" = "false" ]; then
|
|
invoke-rc.d prosody restart
|
|
invoke-rc.d jitsi-videobridge restart
|
|
fi
|
|
;;
|
|
|
|
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
|