1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/jitsi_ynh.git synced 2024-09-03 19:35:57 +02:00
jitsi_ynh/scripts/upgrade

300 lines
12 KiB
Text
Raw Normal View History

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
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Loading settings..." --weight=1
2019-06-06 06:04:22 +02:00
2024-01-09 19:10:09 +01:00
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
2019-06-06 06:04:22 +02:00
2024-01-09 19:10:09 +01:00
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
2019-06-06 06:04:22 +02:00
2024-01-09 19:10:09 +01:00
#REMOVEME? max_memory=$(ynh_app_setting_get --app=$app --key=max_memory)
2024-01-09 19:10:09 +01:00
#REMOVEME? focus_user=$(ynh_app_setting_get --app=$app --key=focus_user)
#REMOVEME? focus_password=$(ynh_app_setting_get --app=$app --key=focus_password)
#REMOVEME? focus_secret=$(ynh_app_setting_get --app=$app --key=focus_secret)
2020-06-18 15:09:44 +02:00
2024-01-09 19:10:09 +01:00
#REMOVEME? videobridge_user=$(ynh_app_setting_get --app=$app --key=videobridge_user)
#REMOVEME? videobridge_secret=$(ynh_app_setting_get --app=$app --key=videobridge_secret)
2020-06-18 15:09:44 +02:00
2024-01-09 19:10:09 +01:00
#REMOVEME? turn_secret=$(ynh_app_setting_get --app=$app --key=turn_secret)
#REMOVEME? muc_nickname=$(ynh_app_setting_get --app=$app --key=muc_nickname)
2022-02-07 01:14:21 +01:00
2024-01-09 19:10:09 +01:00
#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
#REMOVEME? port_videobridge=$(ynh_app_setting_get --app=$app --key=port_videobridge)
#REMOVEME? port_component=$(ynh_app_setting_get --app=$app --key=port_component)
2019-07-14 01:17:46 +02:00
2019-06-06 06:04:22 +02:00
#=================================================
# CHECK VERSION
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Checking version..." --weight=1
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
#=================================================
2024-01-09 19:10:09 +01:00
#REMOVEME? 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
2024-01-09 19:10:09 +01:00
#REMOVEME? ynh_backup_before_upgrade
#REMOVEME? ynh_clean_setup () {
2022-02-03 03:00:20 +01:00
# Restore it if the upgrade fails
2024-01-09 19:10:09 +01:00
#REMOVEME? ynh_restore_upgradebackup
2019-06-06 06:04:22 +02:00
}
# Exit if an error occurs during the execution of the script
2024-01-09 19:10:09 +01:00
#REMOVEME? ynh_abort_if_errors
2019-06-06 06:04:22 +02:00
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Stopping a systemd service..." --weight=1
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
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
2022-02-03 03:00:20 +01:00
2024-01-09 19:10:09 +01:00
# If install_dir doesn't exist, create it
if [ -z "$install_dir" ]; then
#REMOVEME? install_dir=/var/www/$app
#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
2022-02-03 03:00:20 +01:00
fi
# If max_memory doesn't exist, create it and set to default 75 mb value
if [ -z "$max_memory" ]; then
2022-04-14 21:11:30 +02:00
max_memory=200
ynh_app_setting_set --app=$app --key=max_memory --value=$max_memory
fi
2022-02-03 03:00:20 +01:00
#=================================================
# CREATE DEDICATED USER
#=================================================
2024-01-09 19:10:09 +01:00
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
2022-02-03 03:00:20 +01:00
# Create a dedicated user (if not existing)
2024-01-09 19:10:09 +01:00
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
2022-02-08 22:42:11 +01:00
gpasswd --add www-data $app
2022-02-03 03:00:20 +01:00
2019-06-06 06:04:22 +02:00
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Upgrading source files..." --weight=1
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
2024-01-09 19:10:09 +01:00
#REMOVEME? ynh_secure_remove --file="$install_dir/${package}"
ynh_setup_source --dest_dir="$install_dir/${package}_temp" --source_id=$package
pushd "$install_dir/${package}_temp"
2020-04-10 05:21:33 +02:00
ar x $package.deb data.tar.xz
tar xf data.tar.xz
popd
2024-01-09 19:10:09 +01:00
mv "$install_dir/${package}_temp/usr/share/${packages[$package]}/" "$install_dir/${package}/"
#REMOVEME? ynh_secure_remove --file="$install_dir/${package}_temp"
2020-04-10 05:21:33 +02:00
done
2022-02-11 00:47:00 +01:00
2024-01-09 19:10:09 +01:00
ynh_setup_source --dest_dir="$install_dir/jitsi-meet-prosody" --source_id=mod_auth_ldap
2019-06-06 06:04:22 +02:00
fi
2024-01-09 19:10:09 +01:00
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:$app "$install_dir"
2022-02-08 22:42:11 +01:00
2019-06-06 06:04:22 +02:00
#=================================================
# UPGRADE DEPENDENCIES
#=================================================
2024-01-09 19:10:09 +01:00
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1
2019-06-06 06:04:22 +02:00
2022-06-09 01:19:53 +02:00
ynh_install_apps --apps="$ynh_app_dependencies"
2024-01-09 19:10:09 +01:00
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
2019-06-06 06:04:22 +02:00
2022-04-15 00:28:49 +02:00
if [ $YNH_ARCH == "armhf" ]
then
2024-01-09 19:10:09 +01:00
#REMOVEME? ynh_script_progression --message="Installing specific arm dependencies..." --weight=1
#REMOVEME? ynh_install_extra_app_dependencies --repo="deb http://security.debian.org/debian-security stretch/updates main" --package="$pkg_extra_depedencies_arm" --key="https://ftp-master.debian.org/keys/archive-key-9-security.asc"
2022-04-15 00:28:49 +02:00
fi
2022-02-09 08:21:08 +01:00
gpasswd --add prosody $app
2022-02-06 02:01:33 +01:00
2022-06-09 01:19:53 +02:00
#=================================================
# NGINX CONFIGURATION
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
2022-06-09 01:19:53 +02:00
# Create a dedicated NGINX config
ynh_add_nginx_config
2019-06-06 06:04:22 +02:00
#=================================================
# SPECIFIC UPGRADE
2022-02-12 23:52:11 +01:00
#=================================================
# CONFIGURE FIREWALL
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Configuring firewall..." --weight=1
2022-02-12 23:52:11 +01:00
# Open this port
ynh_exec_warn_less yunohost firewall allow TCP $port
ynh_exec_warn_less yunohost firewall allow UDP $port_videobridge
2022-02-06 17:19:59 +01:00
#=================================================
# CONFIGURE PROSODY
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Configuring Prosody..." --weight=1
2022-02-06 17:19:59 +01:00
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_add_config --template="../conf/prosody.cfg.lua" --destination="/etc/prosody/conf.avail/$domain.cfg.lua"
chmod 644 "/etc/prosody/conf.avail/$domain.cfg.lua"
fi
2019-06-06 06:04:22 +02:00
#=================================================
2020-04-11 21:55:05 +02:00
# CONFIGURE JITSI-VIDEOBRIDGE
2019-06-06 06:04:22 +02:00
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Configuring Jitsi-Videobridge..." --weight=1
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
2022-02-06 17:19:59 +01:00
ynh_add_config --template="../conf/jitsi-videobridge-callstats-java-sdk.properties" --destination="/etc/$app/videobridge/callstats-java-sdk.properties"
ynh_add_config --template="../conf/jitsi-videobridge-jvb.conf" --destination="/etc/$app/videobridge/jvb.conf"
ynh_add_config --template="../conf/jitsi-videobridge-logging.properties" --destination="/etc/$app/videobridge/logging.properties"
ynh_add_config --template="../conf/jitsi-videobridge-sip-communicator.properties" --destination="/etc/$app/videobridge/sip-communicator.properties"
ynh_add_config --template="../conf/jitsi-videobridge.config" --destination="/etc/$app/videobridge/config"
2019-07-14 01:17:46 +02:00
fi
2019-06-06 06:04:22 +02:00
2022-04-15 14:41:11 +02:00
#=================================================
# REPLACE JNIWRAPPER FOR ARMHF ARCHITECTURE IN JITSI-VIDEOBRIDGE
#=================================================
if [ $YNH_ARCH == "armhf" ]
then
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Configuring jniwrapper for armhf ..." --weight=1
2022-04-15 14:41:11 +02:00
ynh_jniwrapper_armhf
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
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="configuring Jitsi-Jicofo..." --weight=1
2019-07-14 01:17:46 +02:00
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
2022-02-06 17:19:59 +01:00
ynh_add_config --template="../conf/jitsi-jicofo-config" --destination="/etc/$app/jicofo/config"
ynh_add_config --template="../conf/jitsi-jicofo-jicofo.conf" --destination="/etc/$app/jicofo/jicofo.conf"
2019-07-14 01:17:46 +02:00
2022-02-06 17:19:59 +01:00
ynh_add_config --template="../conf/jitsi-jicofo-logging.properties" --destination="/etc/$app/jicofo/logging.properties"
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
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Configuring Jitsi-Meet..." --weight=1
2019-06-06 06:04:22 +02:00
2019-07-14 01:17:46 +02:00
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
2022-02-06 17:19:59 +01:00
ynh_add_config --template="../conf/jitsi-meet-config.js" --destination="/etc/$app/meet/$domain-config.js"
chmod 644 "/etc/$app/meet/$domain-config.js"
2019-07-14 01:17:46 +02:00
fi
2019-06-06 06:04:22 +02:00
2022-02-09 22:41:48 +01:00
#=================================================
# CREATE LOG DIR
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Creating log dir..." --weight=1
2022-02-09 22:41:48 +01:00
mkdir -p "/var/log/$app"
chown -R $app: /var/log/$app
chmod -R 770 /var/log/$app
2022-06-09 01:19:53 +02:00
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Securing files and directories..." --weight=1
2022-06-09 01:19:53 +02:00
# Set permissions on app files
chown -R $app: /etc/$app
2019-06-06 06:04:22 +02:00
#=================================================
# SETUP SYSTEMD
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
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
#=================================================
2020-06-18 02:03:31 +02:00
# SETUP LOGROTATE
2019-06-06 06:04:22 +02:00
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
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
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
2020-06-18 02:03:31 +02:00
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
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Starting a systemd service..." --weight=1
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"
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
#=================================================
2024-01-09 19:10:09 +01:00
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
2019-06-06 06:04:22 +02:00
2024-01-09 19:10:09 +01:00
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
2019-06-06 06:04:22 +02:00
#=================================================
# END OF SCRIPT
#=================================================
2022-10-14 03:49:09 +02:00
ynh_script_progression --message="Upgrade of $app completed" --last