2014-09-04 09:00:12 +00:00
|
|
|
#!/bin/bash
|
2014-08-10 19:29:48 +00:00
|
|
|
# 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/default/jitsi-videobridge
|
|
|
|
|
2014-08-29 09:53:24 +00:00
|
|
|
PROSODY_CONFIG_PRESENT="true"
|
2014-09-04 09:00:12 +00:00
|
|
|
# if there is no prosody config extract our template
|
2014-08-29 09:53:24 +00:00
|
|
|
if [ ! -f /etc/prosody/prosody.cfg.lua ]; then
|
|
|
|
PROSODY_CONFIG_PRESENT="false"
|
2014-09-05 13:11:53 +00:00
|
|
|
gunzip -c /usr/share/doc/jitsi-meet-prosody/prosody.cfg.lua-jvb.example.gz > /etc/prosody/prosody.cfg.lua
|
2014-08-10 19:29:48 +00:00
|
|
|
fi
|
2014-08-29 09:53:24 +00:00
|
|
|
|
2014-09-04 09:00:12 +00:00
|
|
|
# if there is no config for our domain, lets create it
|
|
|
|
if ! grep -q "VirtualHost \"$JVB_HOSTNAME\"" /etc/prosody/prosody.cfg.lua; then
|
|
|
|
|
|
|
|
# if its not our template, save the original and extract our template
|
|
|
|
if ! grep -q "VirtualHost \"jitmeet.example.com\"" /etc/prosody/prosody.cfg.lua; then
|
|
|
|
PROSODY_CONFIG_PRESENT="false"
|
|
|
|
cp /etc/prosody/prosody.cfg.lua /etc/prosody/prosody.cfg.lua.orig
|
2014-09-05 13:11:53 +00:00
|
|
|
gunzip -c /usr/share/doc/jitsi-meet-prosody/prosody.cfg.lua-jvb.example.gz > /etc/prosody/prosody.cfg.lua
|
2014-09-04 09:00:12 +00:00
|
|
|
fi
|
|
|
|
|
2014-08-29 09:53:24 +00:00
|
|
|
if [ "PROSODY_CONFIG_PRESENT" = "true" ]; then
|
2014-09-04 09:00:12 +00:00
|
|
|
cp /etc/prosody/prosody.cfg.lua /etc/prosody/prosody.cfg.lua.orig
|
2014-08-29 09:53:24 +00:00
|
|
|
fi
|
|
|
|
sed -i "s/jitmeet.example.com/$JVB_HOSTNAME/g" /etc/prosody/prosody.cfg.lua
|
|
|
|
sed -i "s/jitmeetSecret/$JVB_SECRET/g" /etc/prosody/prosody.cfg.lua
|
|
|
|
fi
|
|
|
|
|
2014-08-10 19:29:48 +00:00
|
|
|
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" \
|
2014-08-14 07:21:51 +00:00
|
|
|
-keyout /var/lib/prosody/$JVB_HOSTNAME.key \
|
|
|
|
-out /var/lib/prosody/$JVB_HOSTNAME.crt
|
2014-08-10 19:29:48 +00:00
|
|
|
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
|
|
|
|
invoke-rc.d prosody restart
|
|
|
|
;;
|
|
|
|
|
|
|
|
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
|