Files
upstream-jitsi-videobridge/debian/postinst
upstream-mirror e1257b7a05
Some checks failed
Java CI with Maven / Java 17 (push) Failing after 7m2s
Java CI with Maven / Java 21 (push) Failing after 5m0s
snapshot of https://github.com/jitsi/jitsi-videobridge.git @ fcbf741c646bc237d2ed85a1e86910532532b831 (2026-09-15)
2026-09-15 16:12:38 +05:00

185 lines
6.4 KiB
Bash

#!/bin/bash
# postinst script for jitsi-videobridge
set -e
case "$1" in
configure)
CONFIG="/etc/jitsi/videobridge/config"
# we don't want to regenerate config on upgrade
OLDCONFIG="false"
# migrate any old config found
if [ -f "/etc/default/jitsi-videobridge" ]; then
mv /etc/default/jitsi-videobridge $CONFIG
fi
if [ -f $CONFIG ]; then
. $CONFIG
if [ -n "$JVB_HOSTNAME" ] && [ -n "$JVB_SECRET" ]; then
OLDCONFIG="true"
fi
fi
# debconf hostname question
. /usr/share/debconf/confmodule
# the default vars
db_get jitsi-videobridge/jvb-hostname
JVB_HOSTNAME_IN=$(echo "$RET" | xargs echo -n)
# generate config on new install or when we are reconfiguring
# and all install is different than current one
if [ "$OLDCONFIG" = "false" ] || [ "$JVB_HOSTNAME" != "$JVB_HOSTNAME_IN" ]; then
JVB_HOSTNAME="$JVB_HOSTNAME_IN"
if [ "$OLDCONFIG" = "false" ]; then
# 8-chars random secret, alternative to pwgen 8
db_get jitsi-videobridge/jvbsecret
if [ -n "$RET" ]; then
JVB_SECRET="$RET"
else
JVB_SECRET=`head -c 8 /dev/urandom | tr '\0-\377' 'a-zA-Z0-9a-zA-Z0-9a-zA-Z0-9a-zA-Z0-9@@@@####'`
fi
fi
fi
# Store it, so we can use it if xmpp server is on same machine
# we are currently doing this on every upgrade in order to be able to successfully upgrade
# from old packages, otherwise we can do it only when secret is first time generated
db_set jitsi-videobridge/jvbsecret $JVB_SECRET
# and we're done with debconf
db_stop
HOCON_CONFIG="/etc/jitsi/videobridge/jvb.conf"
# let's check whether there is a setting in the $CONFIG
# for home folder and logging props file, if missing add it
if ! grep -q "JAVA_SYS_PROPS" "$CONFIG"; then
echo >> $CONFIG
echo '# adds java system props that are passed to jvb (default are for home and logging config file)' >> $CONFIG
echo "JAVA_SYS_PROPS=\"-Dnet.java.sip.communicator.SC_HOME_DIR_LOCATION=/etc/jitsi\
-Dnet.java.sip.communicator.SC_HOME_DIR_NAME=videobridge\
-Dnet.java.sip.communicator.SC_LOG_DIR_LOCATION=/var/log/jitsi\
-Djava.util.logging.config.file=/etc/jitsi/videobridge/logging.properties\"" >> $CONFIG
fi
# Updates config so new and old installs will start using the new config file
if ! grep -q "\-Dconfig.file" "$CONFIG"; then
sed -i 's|JAVA_SYS_PROPS="|JAVA_SYS_PROPS="-Dconfig.file='"$HOCON_CONFIG"' |g' $CONFIG
fi
# unused old parameter, systemd unit files does not resolve bash variables,
# and this breaks startup script
sed -i 's/\$JVB_EXTRA_JVM_PARAMS//g' $CONFIG
if [ ! -f $HOCON_CONFIG ]; then
echo "Generating a default hocon config"
echo "videobridge {
apis.xmpp-client.configs {
shard {
HOSTNAME=localhost
DOMAIN=\"auth.$JVB_HOSTNAME\"
USERNAME=jvb
PASSWORD=\"$JVB_SECRET\"
MUC_JIDS=\"jvbbrewery@internal.auth.$JVB_HOSTNAME\"
MUC_NICKNAME=$(uuidgen)
}
}
}
ice4j {
harvest {
mapping {
aws {
enabled = false
}
stun {
addresses = [\"meet-jit-si-turnrelay.jitsi.net:443\"]
}
}
}
}" >> $HOCON_CONFIG
fi
# The REST API is disabled by default. It it was previously enabled via --apis, enable it in jvb.conf
if grep -v '^\s*#' /etc/jitsi/videobridge/config | grep -- '--apis=' | grep -i rest >/dev/null 2>&1 ;then
if ! hocon -f $HOCON_CONFIG get "videobridge.apis.rest.enabled" > /dev/null 2>&1 ;then
hocon -f $HOCON_CONFIG set "videobridge.apis.rest.enabled" "true"
fi
# Remove it from /etc/jitsi/videobridge/config to prevent it perpetually updating jvb.conf
sed -i 's/.*--apis.*//' $CONFIG
fi
# we don't want to start the daemon as root
if ! getent group jitsi > /dev/null ; then
groupadd jitsi
fi
if ! getent passwd jvb > /dev/null ; then
useradd -r -g jitsi --shell /bin/bash --create-home -d /usr/share/jitsi-videobridge jvb
fi
if ! groups jvb | grep '\bjitsi\b' > /dev/null ; then
usermod -g jitsi jvb
fi
mkdir -p /usr/share/jitsi-videobridge
# we claim the home folder of jvb in case it is owned by someone else
OWNER=$(stat -c '%U' /usr/share/jitsi-videobridge)
GROUP=$(stat -c '%G' /usr/share/jitsi-videobridge)
if ! dpkg-statoverride --list /usr/share/jitsi-videobridge/* >/dev/null && [ "$OWNER:$GROUP" != "jvb:jitsi" ]; then
chown -R jvb:jitsi /usr/share/jitsi-videobridge
OWNER=jvb
GROUP=jitsi
fi
CONFIG_DIR=$(dirname $CONFIG)
if ! dpkg-statoverride --list "$CONFIG_DIR" >/dev/null; then
chown -R jvb:jitsi "$CONFIG_DIR"
chmod 750 "$CONFIG_DIR"
fi
# die logz
if [ ! -d /var/log/jitsi ]; then
mkdir -p /var/log/jitsi
fi
chown $OWNER:$GROUP /var/log/jitsi
chmod 770 /var/log/jitsi
ls /var/log/jitsi/jvb* 1>/dev/null 2>&1 && chown -f -R $OWNER:$GROUP /var/log/jitsi/jvb*
ls /var/log/jitsi/jvb* 1>/dev/null 2>&1 && chmod -f -R 640 /var/log/jitsi/jvb*
# ensure videobridge is not running - it will be started at the end
if [ -d /run/systemd/system ]; then
systemctl stop jitsi-videobridge2.service >/dev/null || true
fi
# clean up old jvb group
if getent group jvb > /dev/null; then
groupdel jvb
fi
# load the UDP buffer sizes required by the JVB. As reported in
# https://github.com/jitsi/jitsi-videobridge/issues/461
# OpenVZ containers do not typically allow permission to modify the
# kernel with sysctl config values.
sysctl --system || true
;;
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