2019-06-06 06:04:22 +02:00
|
|
|
#!/bin/bash
|
2015-01-14 10:55:14 +01:00
|
|
|
|
2019-06-06 06:04:22 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2015-01-14 10:55:14 +01:00
|
|
|
|
2019-06-06 06:04:22 +02:00
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
2015-01-14 10:55:14 +01:00
|
|
|
|
2019-06-06 06:04:22 +02:00
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
2020-06-18 02:03:31 +02:00
|
|
|
ynh_script_progression --message="Loading installation settings..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
|
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|
|
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
|
|
|
2020-06-18 15:09:44 +02:00
|
|
|
focus_user=$(ynh_app_setting_get --app=$app --key=focus_user)
|
|
|
|
focus_password=$(ynh_app_setting_get --app=$app --key=focus_password)
|
2019-06-06 06:04:22 +02:00
|
|
|
focus_secret=$(ynh_app_setting_get --app=$app --key=focus_secret)
|
2020-06-18 15:09:44 +02:00
|
|
|
|
|
|
|
videobridge_user=$(ynh_app_setting_get --app=$app --key=videobridge_user)
|
|
|
|
videobridge_secret=$(ynh_app_setting_get --app=$app --key=videobridge_secret)
|
|
|
|
|
2020-01-20 03:18:23 +01:00
|
|
|
port=$(ynh_app_setting_get --app=$app --key=port)
|
2020-06-18 15:09:44 +02:00
|
|
|
port_videobridge=$(ynh_app_setting_get --app=$app --key=port_videobridge)
|
2019-07-14 01:17:46 +02:00
|
|
|
port_component=$(ynh_app_setting_get --app=$app --key=port_component)
|
|
|
|
|
2019-06-06 06:04:22 +02:00
|
|
|
#=================================================
|
|
|
|
# CHECK VERSION
|
|
|
|
#=================================================
|
2020-06-18 02:03:31 +02:00
|
|
|
ynh_script_progression --message="Checking version..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
2019-08-25 03:40:54 +02:00
|
|
|
current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$app/manifest.json" --manifest_key="version" || echo 1.0)
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
|
|
#=================================================
|
2020-06-18 02:03:31 +02:00
|
|
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
# Backup the current version of the app
|
|
|
|
ynh_backup_before_upgrade
|
|
|
|
ynh_clean_setup () {
|
2019-08-06 21:18:00 +02:00
|
|
|
ynh_clean_check_starting
|
2022-02-03 03:00:20 +01:00
|
|
|
# Restore it if the upgrade fails
|
|
|
|
ynh_restore_upgradebackup
|
2019-06-06 06:04:22 +02:00
|
|
|
}
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
# STOP SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2020-06-18 02:03:31 +02:00
|
|
|
ynh_script_progression --message="Stopping a systemd service..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
2019-07-13 14:18:06 +02:00
|
|
|
ynh_systemd_action --service_name=$app-videobridge --action="stop" --log_path="/var/log/$app/$app-videobridge.log"
|
|
|
|
ynh_systemd_action --service_name=$app-jicofo --action="stop" --log_path="/var/log/$app/$app-jicofo.log"
|
2019-06-06 06:04:22 +02:00
|
|
|
|
2022-02-03 03:00:20 +01:00
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..."
|
|
|
|
|
|
|
|
# If final_path doesn't exist, create it
|
|
|
|
if [ -z "$final_path" ]; then
|
|
|
|
final_path=/var/www/$app
|
|
|
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
|
|
|
fi
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CREATE DEDICATED USER
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Making sure dedicated system user exists..."
|
|
|
|
|
|
|
|
# Create a dedicated user (if not existing)
|
|
|
|
ynh_system_user_create --username=$app --home_dir="$final_path"
|
|
|
|
|
2019-06-06 06:04:22 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
2020-06-18 02:03:31 +02:00
|
|
|
ynh_script_progression --message="Upgrading source files..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2020-04-10 05:21:33 +02:00
|
|
|
declare -A packages
|
2022-02-03 03:00:20 +01:00
|
|
|
packages[jitsi-jicofo]="jicofo"
|
2020-04-10 05:21:33 +02:00
|
|
|
packages[jitsi-meet-prosody]="jitsi-meet/prosody-plugins"
|
|
|
|
packages[jitsi-meet-web]="jitsi-meet"
|
|
|
|
packages[jitsi-videobridge]="jitsi-videobridge"
|
|
|
|
|
|
|
|
for package in "${!packages[@]}"
|
|
|
|
do
|
|
|
|
ynh_secure_remove --file="$final_path/${package}"
|
|
|
|
ynh_setup_source --dest_dir="$final_path/${package}_temp" --source_id=$package
|
|
|
|
pushd "$final_path/${package}_temp"
|
|
|
|
ar x $package.deb data.tar.xz
|
|
|
|
tar xf data.tar.xz
|
|
|
|
popd
|
|
|
|
|
|
|
|
mv "$final_path/${package}_temp/usr/share/${packages[$package]}/" "$final_path/${package}/"
|
|
|
|
ynh_secure_remove --file="$final_path/${package}_temp"
|
|
|
|
done
|
2019-06-06 06:04:22 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2022-02-03 03:00:20 +01:00
|
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
2022-02-03 03:00:20 +01:00
|
|
|
# Create a dedicated NGINX config
|
2019-06-06 06:04:22 +02:00
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# UPGRADE DEPENDENCIES
|
|
|
|
#=================================================
|
2020-06-18 02:03:31 +02:00
|
|
|
ynh_script_progression --message="Upgrading dependencies..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
ynh_install_app_dependencies $pkg_dependencies
|
|
|
|
|
2022-02-03 03:00:20 +01:00
|
|
|
if ! yunohost app list | grep -q "prosody"
|
|
|
|
then
|
2022-02-06 15:30:08 +01:00
|
|
|
yunohost tools update
|
|
|
|
yunohost app install prosody
|
2022-02-06 01:57:11 +01:00
|
|
|
else
|
2022-02-06 15:30:08 +01:00
|
|
|
yunohost tools update
|
|
|
|
yunohost app upgrade prosody
|
2022-02-03 03:00:20 +01:00
|
|
|
fi
|
2019-06-06 06:04:22 +02:00
|
|
|
|
2022-02-06 02:01:33 +01:00
|
|
|
ynh_app_setting_set --app=$app --key=require_prosody --value="1"
|
|
|
|
|
2019-06-06 06:04:22 +02:00
|
|
|
#=================================================
|
|
|
|
# SPECIFIC UPGRADE
|
|
|
|
#=================================================
|
2020-04-11 21:55:05 +02:00
|
|
|
# CONFIGURE JITSI-VIDEOBRIDGE
|
2019-06-06 06:04:22 +02:00
|
|
|
#=================================================
|
2020-06-18 02:03:31 +02:00
|
|
|
ynh_script_progression --message="Configuring Jitsi-Videobridge..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
2019-07-14 01:17:46 +02:00
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
2020-03-31 19:56:56 +02:00
|
|
|
public_ipv4="$(curl ip.yunohost.org)" || true
|
|
|
|
private_ipv4="$(ip route get 1 | sed -n 's/^.*src \([0-9.]*\) .*$/\1/p')" || true
|
2020-04-11 21:55:05 +02:00
|
|
|
|
|
|
|
jitsi_videobridge_sip_communicator_conf="/etc/$app/videobridge/sip-communicator.properties"
|
|
|
|
ynh_backup_if_checksum_is_different --file="$jitsi_videobridge_sip_communicator_conf"
|
|
|
|
cp -f ../conf/jitsi_videobridge-sip-communicator.properties "$jitsi_videobridge_sip_communicator_conf"
|
|
|
|
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="$jitsi_videobridge_sip_communicator_conf"
|
|
|
|
ynh_replace_string --match_string="__PRIVATE_IPV4__" --replace_string="$private_ipv4" --target_file="$jitsi_videobridge_sip_communicator_conf"
|
|
|
|
ynh_replace_string --match_string="__PUBLIC_IPV4__" --replace_string="$public_ipv4" --target_file="$jitsi_videobridge_sip_communicator_conf"
|
|
|
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$jitsi_videobridge_sip_communicator_conf"
|
2020-04-13 17:16:38 +02:00
|
|
|
ynh_replace_string --match_string="__VIDEOBRIDGE_USER__" --replace_string="$videobridge_user" --target_file="$jitsi_videobridge_sip_communicator_conf"
|
|
|
|
ynh_replace_string --match_string="__VIDEOBRIDGE_SECRET__" --replace_string="$videobridge_secret" --target_file="$jitsi_videobridge_sip_communicator_conf"
|
2020-04-11 21:55:05 +02:00
|
|
|
ynh_replace_string --match_string="__MUC_NICKNAME__" --replace_string="$muc_nickname" --target_file="$jitsi_videobridge_sip_communicator_conf"
|
|
|
|
ynh_store_file_checksum --file="$jitsi_videobridge_sip_communicator_conf"
|
|
|
|
|
|
|
|
jitsi_videobridge_conf="/etc/$app/videobridge/config"
|
|
|
|
ynh_backup_if_checksum_is_different --file="$jitsi_videobridge_conf"
|
|
|
|
cp ../conf/jitsi-videobridge.config "$jitsi_videobridge_conf"
|
|
|
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$jitsi_videobridge_conf"
|
|
|
|
ynh_replace_string --match_string="__PORT_COMPONENT__" --replace_string="$port_component" --target_file="$jitsi_videobridge_conf"
|
|
|
|
ynh_replace_string --match_string="__VIDEOBRIDGE_SECRET__" --replace_string="$videobridge_secret" --target_file="$jitsi_videobridge_conf"
|
|
|
|
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$jitsi_videobridge_conf"
|
|
|
|
ynh_store_file_checksum --file="$jitsi_videobridge_conf"
|
|
|
|
|
|
|
|
jitsi_videobridge_logging_conf="/etc/$app/videobridge/logging.properties"
|
|
|
|
ynh_backup_if_checksum_is_different --file="$jitsi_videobridge_logging_conf"
|
|
|
|
cp ../conf/jitsi-videobridge-logging.properties "$jitsi_videobridge_logging_conf"
|
|
|
|
ynh_store_file_checksum --file="$jitsi_videobridge_logging_conf"
|
2020-04-15 08:50:39 +02:00
|
|
|
|
|
|
|
jitsi_videobridge_callstats_java_sdk_conf="/etc/$app/videobridge/callstats-java-sdk.properties"
|
|
|
|
cp ../conf/jitsi-videobridge-callstats-java-sdk.properties "$jitsi_videobridge_callstats_java_sdk_conf"
|
|
|
|
|
|
|
|
jitsi_videobridge_log4j2_conf="/etc/$app/videobridge/log4j2.xml"
|
|
|
|
cp ../conf/jitsi-videobridge-log4j2.xml "$jitsi_videobridge_log4j2_conf"
|
|
|
|
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$jitsi_videobridge_log4j2_conf"
|
2019-07-14 01:17:46 +02:00
|
|
|
fi
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
2020-04-11 21:55:05 +02:00
|
|
|
# CONFIGURE JITSI-JICOFO
|
2019-06-06 06:04:22 +02:00
|
|
|
#=================================================
|
2020-06-18 02:03:31 +02:00
|
|
|
ynh_script_progression --message="configuring Jitsi-Jicofo..."
|
2019-07-14 01:17:46 +02:00
|
|
|
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
2020-04-11 21:55:05 +02:00
|
|
|
jitsi_jicofo_sip_communicator_conf="/etc/$app/jicofo/sip-communicator.properties"
|
|
|
|
ynh_backup_if_checksum_is_different --file="$jitsi_jicofo_sip_communicator_conf"
|
|
|
|
cp ../conf/jitsi-jicofo-sip-communicator.properties "$jitsi_jicofo_sip_communicator_conf"
|
|
|
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$jitsi_jicofo_sip_communicator_conf"
|
|
|
|
ynh_store_file_checksum --file="$jitsi_jicofo_sip_communicator_conf"
|
|
|
|
|
|
|
|
jitsi_jicofo_conf="/etc/$app/jicofo/config"
|
|
|
|
ynh_backup_if_checksum_is_different --file="$jitsi_jicofo_conf"
|
|
|
|
cp ../conf/jitsi-jicofo.config "$jitsi_jicofo_conf"
|
|
|
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$jitsi_jicofo_conf"
|
|
|
|
ynh_replace_string --match_string="__PORT_COMPONENT__" --replace_string="$port_component" --target_file="$jitsi_jicofo_conf"
|
|
|
|
ynh_replace_string --match_string="__FOCUS_SECRET__" --replace_string="$focus_secret" --target_file="$jitsi_jicofo_conf"
|
|
|
|
ynh_replace_string --match_string="__FOCUS_USER__" --replace_string="$focus_user" --target_file="$jitsi_jicofo_conf"
|
|
|
|
ynh_replace_string --match_string="__FOCUS_PASSWORD__" --replace_string="$focus_password" --target_file="$jitsi_jicofo_conf"
|
|
|
|
ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$jitsi_jicofo_conf"
|
|
|
|
ynh_store_file_checksum --file="$jitsi_jicofo_conf"
|
|
|
|
|
|
|
|
jitsi_jicofo_logging_conf="/etc/$app/jicofo/logging.properties"
|
|
|
|
ynh_backup_if_checksum_is_different --file="$jitsi_jicofo_logging_conf"
|
|
|
|
cp ../conf/jitsi-jicofo-logging.properties "$jitsi_jicofo_logging_conf"
|
|
|
|
ynh_store_file_checksum --file="$jitsi_jicofo_logging_conf"
|
2019-07-14 01:17:46 +02:00
|
|
|
|
|
|
|
fi
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
2020-04-11 21:55:05 +02:00
|
|
|
# CONFIGURE JITSI-MEET
|
2019-06-06 06:04:22 +02:00
|
|
|
#=================================================
|
2020-06-18 02:03:31 +02:00
|
|
|
ynh_script_progression --message="Configuring Jitsi-Meet..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
2019-07-14 01:17:46 +02:00
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
2020-04-11 21:55:05 +02:00
|
|
|
jitsi_meet_conf="/etc/$app/meet/config.js"
|
|
|
|
ynh_backup_if_checksum_is_different --file="$jitsi_meet_conf"
|
2020-06-19 04:34:21 +02:00
|
|
|
ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/config.js"
|
|
|
|
cpp -undef -P ../conf/config.js -o "$jitsi_meet_conf"
|
2020-04-11 21:55:05 +02:00
|
|
|
ynh_store_file_checksum --file="$jitsi_meet_conf"
|
2019-07-14 01:17:46 +02:00
|
|
|
fi
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP SYSTEMD
|
|
|
|
#=================================================
|
2020-06-18 02:03:31 +02:00
|
|
|
ynh_script_progression --message="Upgrading systemd configuration..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
# Create a dedicated systemd config
|
2019-07-13 14:18:06 +02:00
|
|
|
ynh_add_systemd_config --service=$app-videobridge --template="jitsi-videobridge.service"
|
|
|
|
ynh_add_systemd_config --service=$app-jicofo --template="jitsi-jicofo.service"
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
|
|
|
# SECURE FILES AND DIRECTORIES
|
|
|
|
#=================================================
|
2020-06-18 02:03:31 +02:00
|
|
|
ynh_script_progression --message="Securing files and directories..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
# Set permissions on app files
|
|
|
|
chown -R root: $final_path
|
2020-04-11 21:55:05 +02:00
|
|
|
chown -R $app: /etc/$app
|
2020-04-15 08:50:39 +02:00
|
|
|
chown -R $app: /var/log/$app
|
|
|
|
chmod -R 770 /var/log/$app
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
2020-06-18 02:03:31 +02:00
|
|
|
# SETUP LOGROTATE
|
2019-06-06 06:04:22 +02:00
|
|
|
#=================================================
|
2020-06-18 02:03:31 +02:00
|
|
|
ynh_script_progression --message="Upgrading logrotate configuration..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
2020-06-18 02:03:31 +02:00
|
|
|
# Use logrotate to manage app-specific logfile(s)
|
|
|
|
ynh_use_logrotate --non-append
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
|
|
|
|
2022-02-06 15:37:16 +01:00
|
|
|
yunohost service add $app-videobridge --log "/var/log/$app/$app-videobridge.log" --needs_exposed_ports $port $port_videobridge
|
|
|
|
yunohost service add $app-jicofo --log "/var/log/$app/$app-jicofo.log"
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# START SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2020-06-18 02:03:31 +02:00
|
|
|
ynh_script_progression --message="Starting a systemd service..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
2019-07-13 14:18:06 +02:00
|
|
|
ynh_systemd_action --service_name=$app-jicofo --action="start" --log_path="/var/log/$app/$app-jicofo.log"
|
2020-06-19 04:34:21 +02:00
|
|
|
ynh_systemd_action --service_name=$app-videobridge --action="start" --log_path="/var/log/$app/$app-videobridge.log"
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2022-02-03 03:00:20 +01:00
|
|
|
ynh_script_progression --message="Reloading NGINX web server..."
|
2019-06-06 06:04:22 +02:00
|
|
|
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2020-06-18 02:03:31 +02:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed"
|