diff --git a/check_process b/check_process index 93f5530..4254b27 100644 --- a/check_process +++ b/check_process @@ -14,6 +14,7 @@ setup_private=0 setup_public=1 upgrade=1 + upgrade=1 from_commit=0ea33568698b64285207a9e3e9b5bd1f621e7826 backup_restore=1 multi_instance=0 # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. @@ -24,8 +25,8 @@ # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto ;;; Options -Email= -Notification=none +Email=yalh@yahoo.com +Notification=all ;;; Upgrade options ; commit=CommitHash name=Name and date of the commit. diff --git a/conf/metronome_regen_conf.hook b/conf/metronome_regen_conf.hook new file mode 100644 index 0000000..014db5b --- /dev/null +++ b/conf/metronome_regen_conf.hook @@ -0,0 +1,29 @@ +#!/bin/bash + +force=${2:-0} # 0/1 --force argument +dryrun=${3:-0} # 0/1 --dry-run argument +pending_conf=$4 # Path of the pending conf file + +do_pre_regen() { + # Add specific domain metronome conf + cp -af "/usr/share/yunohost/templates/jitsi/." "${pending_conf}/../metronome/etc/metronome/conf.d/" +} + +do_post_regen() { + regen_conf_files=$1 +} + +case "$1" in + pre) + do_pre_regen + ;; + post) + do_post_regen + ;; + *) + echo "Hook called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +exit 0 \ No newline at end of file diff --git a/manifest.json b/manifest.json index 4f4a389..72d7212 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Video conferencing web application", "fr": "Application web de conférence vidéo" }, - "version": "1.0.3387~ynh1", + "version": "1.0.3387~ynh2", "url": "https://jitsi.org/Projects/JitMeet", "license": "Apache-2.0", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index f6f2db2..5ecd355 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -11,6 +11,11 @@ pkg_dependencies="openjdk-8-jdk openjdk-8-jre maven" # PERSONAL HELPERS #================================================= +ynh_version_gt () +{ + dpkg --compare-versions "$1" gt "$2" +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 2a5821e..a643a1b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -56,6 +56,26 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SPECIFIC BACKUP +#================================================= +# BACKUP METRONOME +#================================================= +ynh_print_info --message="Backing up Metronome..." + +# Backup Metronome domain conf template +ynh_backup --src_path="/usr/share/yunohost/templates/jitsi/$domain.cfg.lua" +ynh_backup --src_path="/usr/share/yunohost/templates/jitsi/auth.$domain.cfg.lua" +ynh_backup --src_path="/usr/share/yunohost/templates/jitsi/conference.$domain.cfg.lua" +ynh_backup --src_path="/usr/share/yunohost/templates/jitsi/jitsi-videobridge.$domain.cfg.lua" +ynh_backup --src_path="/usr/share/yunohost/templates/jitsi/focus.$domain.cfg.lua" + +# Backup Metronome Hook +ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/50-metronome_$app" + +# Backup Metronome Module +ynh_backup --src_path="/usr/lib/metronome/modules/mod_carbons.lua" +ynh_backup --src_path="/usr/lib/metronome/modules/mod_http_altconnect.lua" +ynh_backup --src_path="/usr/lib/metronome/modules/mod_smacks.lua" + #================================================= # BACKUP LOGROTATE #================================================= @@ -63,17 +83,6 @@ ynh_print_info --message="Backing up logrotate configuration..." ynh_backup --src_path="/etc/logrotate.d/$app" -#================================================= -# BACKUP METRONOME CONFIG -#================================================= -ynh_print_info --message="Backing up Metronome configuration..." - -ynh_backup --src_path="/etc/metronome/conf.d/$domain.cfg.lua" - -ynh_backup --src_path="/usr/lib/metronome/modules/mod_carbons.lua" -ynh_backup --src_path="/usr/lib/metronome/modules/mod_http_altconnect.lua" -ynh_backup --src_path="/usr/lib/metronome/modules/mod_smacks.lua" - #================================================= # BACKUP SYSTEMD #================================================= diff --git a/scripts/install b/scripts/install index 7de3f18..f4d7fa0 100644 --- a/scripts/install +++ b/scripts/install @@ -130,6 +130,7 @@ ynh_print_info --message="Configuring metronome..." # Create additional domains if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then + ynh_print_info --message="Creating additional domains for package_check..." yunohost domain add auth.$domain yunohost domain add conference.$domain yunohost domain add jitsi-videobridge.$domain @@ -139,22 +140,26 @@ fi # Create focus user yunohost user create $focus_user -f $focus_user -l $focus_user -m ${focus_user}@auth.$domain -p $focus_password -q 0 -# Configure metronome -mv /etc/metronome/conf.d/$domain.cfg.lua /etc/metronome/conf.d/$domain.cfg.lua.back -mv /etc/metronome/conf.d/auth.$domain.cfg.lua /etc/metronome/conf.d/auth.$domain.cfg.lua.back -mv /etc/metronome/conf.d/conference.$domain.cfg.lua /etc/metronome/conf.d/conference.$domain.cfg.lua.back -mv /etc/metronome/conf.d/jitsi-videobridge.$domain.cfg.lua /etc/metronome/conf.d/jitsi-videobridge.$domain.cfg.lua.back -mv /etc/metronome/conf.d/focus.$domain.cfg.lua /etc/metronome/conf.d/focus.$domain.cfg.lua.back +# Add Metronome domain conf template +metronome_conf="/usr/share/yunohost/templates/jitsi/$domain.cfg.lua" +mkdir -p /usr/share/yunohost/templates/jitsi/ +cp ../conf/metronome.cfg.lua $metronome_conf +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$metronome_conf" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$metronome_conf" +ynh_replace_string --match_string="__VIDEOBRIDGE_SECRET__" --replace_string="$videobridge_secret" --target_file="$metronome_conf" +ynh_replace_string --match_string="__FOCUS_SECRET__" --replace_string="$focus_secret" --target_file="$metronome_conf" +ynh_replace_string --match_string="__PORT_COMPONENT__" --replace_string="$port_component" --target_file="$metronome_conf" -metronome="/etc/metronome/conf.d/$domain.cfg.lua" -cp ../conf/metronome.cfg.lua "$metronome" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$metronome" -ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$metronome" -ynh_replace_string --match_string="__VIDEOBRIDGE_SECRET__" --replace_string="$videobridge_secret" --target_file="$metronome" -ynh_replace_string --match_string="__FOCUS_SECRET__" --replace_string="$focus_secret" --target_file="$metronome" -ynh_replace_string --match_string="__PORT_COMPONENT__" --replace_string="$port_component" --target_file="$metronome" -chown -R metronome:metronome "/etc/metronome/conf.d/" +touch "/usr/share/yunohost/templates/jitsi/auth.$domain.cfg.lua" +touch "/usr/share/yunohost/templates/jitsi/conference.$domain.cfg.lua" +touch "/usr/share/yunohost/templates/jitsi/jitsi-videobridge.$domain.cfg.lua" +touch "/usr/share/yunohost/templates/jitsi/focus.$domain.cfg.lua" +# Add Metronome hook +cp -R ../conf/metronome_regen_conf.hook /usr/share/yunohost/hooks/conf_regen/50-metronome_$app +yunohost tools regen-conf metronome + +# Add Metronome modules cp ../conf/mod_carbons.lua /usr/lib/metronome/modules/mod_carbons.lua cp ../conf/mod_http_altconnect.lua /usr/lib/metronome/modules/mod_http_altconnect.lua cp ../conf/mod_smacks.lua /usr/lib/metronome/modules/mod_smacks.lua diff --git a/scripts/remove b/scripts/remove index deed34b..5e501d7 100644 --- a/scripts/remove +++ b/scripts/remove @@ -114,19 +114,29 @@ fi #================================================= ynh_print_info --message="Reconfiguring Metronome..." -# Reconfigure metronome -mv -f /etc/metronome/conf.d/$domain.cfg.lua.back /etc/metronome/conf.d/$domain.cfg.lua -mv /etc/metronome/conf.d/auth.$domain.cfg.lua.back /etc/metronome/conf.d/auth.$domain.cfg.lua -mv /etc/metronome/conf.d/conference.$domain.cfg.lua.back /etc/metronome/conf.d/conference.$domain.cfg.lua -mv /etc/metronome/conf.d/jitsi-videobridge.$domain.cfg.lua.back /etc/metronome/conf.d/jitsi-videobridge.$domain.cfg.lua -mv /etc/metronome/conf.d/focus.$domain.cfg.lua.back /etc/metronome/conf.d/focus.$domain.cfg.lua - +# Remove Metronome modules ynh_secure_remove --file="/usr/lib/metronome/modules/mod_carbons.lua" ynh_secure_remove --file="/usr/lib/metronome/modules/mod_http_altconnect.lua" ynh_secure_remove --file="/usr/lib/metronome/modules/mod_smacks.lua" ynh_systemd_action --service_name=metronome --action=restart +# Remove domain conf template +ynh_secure_remove --file="/usr/share/yunohost/templates/jitsi/$domain.cfg.lua" +ynh_secure_remove --file="/usr/share/yunohost/templates/jitsi/auth.$domain.cfg.lua" +ynh_secure_remove --file="/usr/share/yunohost/templates/jitsi/conference.$domain.cfg.lua" +ynh_secure_remove --file="/usr/share/yunohost/templates/jitsi/jitsi-videobridge.$domain.cfg.lua" +ynh_secure_remove --file="/usr/share/yunohost/templates/jitsi/focus.$domain.cfg.lua" + +# Remove Jitsi template directory +if [ -z "$(ls -A /usr/share/yunohost/templates/jitsi)" ]; then + ynh_secure_remove --file="/usr/share/yunohost/templates/jitsi" +fi + +# Remove Metronome Hook +ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/50-metronome_$app" +yunohost tools regen-conf metronome + # Delete focus user yunohost user delete $focus_user --purge diff --git a/scripts/restore b/scripts/restore index 06c6649..32e5b88 100644 --- a/scripts/restore +++ b/scripts/restore @@ -116,16 +116,19 @@ fi # Create focus user yunohost user create $focus_user -f $focus_user -l $focus_user -m ${focus_user}@auth.$domain -p $focus_password -q 0 -# Configure metronome -mv /etc/metronome/conf.d/$domain.cfg.lua /etc/metronome/conf.d/$domain.cfg.lua.back -mv /etc/metronome/conf.d/auth.$domain.cfg.lua /etc/metronome/conf.d/auth.$domain.cfg.lua.back -mv /etc/metronome/conf.d/conference.$domain.cfg.lua /etc/metronome/conf.d/conference.$domain.cfg.lua.back -mv /etc/metronome/conf.d/jitsi-videobridge.$domain.cfg.lua /etc/metronome/conf.d/jitsi-videobridge.$domain.cfg.lua.back -mv /etc/metronome/conf.d/focus.$domain.cfg.lua /etc/metronome/conf.d/focus.$domain.cfg.lua.back +# Restore Metronome domain conf template +mkdir -p /usr/share/yunohost/templates/jitsi/ +ynh_restore_file --origin_path="/usr/share/yunohost/templates/jitsi/$domain.cfg.lua" +ynh_restore_file --origin_path="/usr/share/yunohost/templates/jitsi/auth.$domain.cfg.lua" +ynh_restore_file --origin_path="/usr/share/yunohost/templates/jitsi/conference.$domain.cfg.lua" +ynh_restore_file --origin_path="/usr/share/yunohost/templates/jitsi/jitsi-videobridge.$domain.cfg.lua" +ynh_restore_file --origin_path="/usr/share/yunohost/templates/jitsi/focus.$domain.cfg.lua" -ynh_restore_file --origin_path="/etc/metronome/conf.d/$domain.cfg.lua" -chown -R metronome:metronome "/etc/metronome/conf.d/" +# Restore Metronome Hook +ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/50-metronome_$app" +yunohost tools regen-conf metronome +# Restore Metronome modules ynh_restore_file --origin_path="/usr/lib/metronome/modules/mod_carbons.lua" ynh_restore_file --origin_path="/usr/lib/metronome/modules/mod_http_altconnect.lua" ynh_restore_file --origin_path="/usr/lib/metronome/modules/mod_smacks.lua" diff --git a/scripts/upgrade b/scripts/upgrade index 2c46a60..9bfd717 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -32,6 +32,7 @@ focus_password=$(ynh_app_setting_get --app=$app --key=focus_password) #================================================= upgrade_type=$(ynh_check_app_version_changed) +current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$app/manifest.json" --manifest_key="version" || echo 1.0) #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -44,6 +45,27 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi +if ynh_version_gt "1.0.3387~ynh2" "${current_version}" ; then + # Add Metronome domain conf template + metronome_conf="/usr/share/yunohost/templates/jitsi/$domain.cfg.lua" + mkdir -p /usr/share/yunohost/templates/jitsi/ + cp ../conf/metronome.cfg.lua $metronome_conf + ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$metronome_conf" + ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="$metronome_conf" + ynh_replace_string --match_string="__VIDEOBRIDGE_SECRET__" --replace_string="$videobridge_secret" --target_file="$metronome_conf" + ynh_replace_string --match_string="__FOCUS_SECRET__" --replace_string="$focus_secret" --target_file="$metronome_conf" + ynh_replace_string --match_string="__PORT_COMPONENT__" --replace_string="$port_component" --target_file="$metronome_conf" + + touch "/usr/share/yunohost/templates/jitsi/auth.$domain.cfg.lua" + touch "/usr/share/yunohost/templates/jitsi/conference.$domain.cfg.lua" + touch "/usr/share/yunohost/templates/jitsi/jitsi-videobridge.$domain.cfg.lua" + touch "/usr/share/yunohost/templates/jitsi/focus.$domain.cfg.lua" + + # Add Metronome hook + cp -R ../conf/metronome_regen_conf.hook /usr/share/yunohost/hooks/conf_regen/50-metronome_$app + yunohost tools regen-conf metronome +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #=================================================