From ca0a3bf24c9889458a7dfa2656dcf014c8965f28 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 13 Aug 2019 01:00:37 +0200 Subject: [PATCH 01/11] Adding hook For metronome regen --- conf/metronome_regenconf_hook | 53 +++++++++++++++++++++++++++++++++++ manifest.json | 2 +- scripts/backup | 6 ++++ scripts/install | 6 ++++ scripts/remove | 6 ++++ scripts/restore | 6 ++++ scripts/upgrade | 6 ++++ 7 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 conf/metronome_regenconf_hook diff --git a/conf/metronome_regenconf_hook b/conf/metronome_regenconf_hook new file mode 100644 index 0000000..1d84b1b --- /dev/null +++ b/conf/metronome_regenconf_hook @@ -0,0 +1,53 @@ +#!/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 + +# Define a temporary directory +temp_dir=/tmp/jitsi.bck + +# Retrieve Jitsi domain name +domain="$(yunohost app setting jitsi domain)" + +do_pre_regen() { + if [ $dryrun -eq 0 ] + then + # Create temporary directory + mkdir $temp_dir + + # Backup metronome config + cp -a "/etc/metronome/conf.d/$domain.cfg.lua" "$temp_dir/$domain.cfg.lua" + fi +} + +do_post_regen() { + # Backup Jitsi domain files + mv -f /etc/metronome/conf.d/$domain.cfg.lua /etc/metronome/conf.d/$domain.cfg.lua.back + mv -f /etc/metronome/conf.d/auth.$domain.cfg.lua /etc/metronome/conf.d/auth.$domain.cfg.lua.back + mv -f /etc/metronome/conf.d/conference.$domain.cfg.lua /etc/metronome/conf.d/conference.$domain.cfg.lua.back + mv -f /etc/metronome/conf.d/jitsi-videobridge.$domain.cfg.lua /etc/metronome/conf.d/jitsi-videobridge.$domain.cfg.lua.back + mv -f /etc/metronome/conf.d/focus.$domain.cfg.lua /etc/metronome/conf.d/focus.$domain.cfg.lua.back + + # Restore metronome config + cp -f "$temp_dir/$domain.cfg.lua" "/etc/metronome/conf.d/$domain.cfg.lua" + + # Delete temporary directory + test -n $temp_dir && rm -r $temp_dir + + # Reload metronome + systemctl reload metronome +} + +case "$1" in + pre) + do_pre_regen + ;; + post) + do_post_regen + ;; + *) + echo "Hook called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac 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/backup b/scripts/backup index 2a5821e..ae742d9 100644 --- a/scripts/backup +++ b/scripts/backup @@ -56,6 +56,12 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SPECIFIC BACKUP +#================================================= +# BACKUP CONF_REGEN HOOK +#================================================= + +ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/50-metronome_$app" + #================================================= # BACKUP LOGROTATE #================================================= diff --git a/scripts/install b/scripts/install index 7de3f18..10291d4 100644 --- a/scripts/install +++ b/scripts/install @@ -123,6 +123,12 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # SPECIFIC SETUP +#================================================= +# SET UP CONF_REGEN HOOK +#================================================= + +cp ../conf/metronome_regenconf_hook /usr/share/yunohost/hooks/conf_regen/50-metronome_$app + #================================================= # CONFIGURE METRONOME #================================================= diff --git a/scripts/remove b/scripts/remove index deed34b..aa55ce7 100644 --- a/scripts/remove +++ b/scripts/remove @@ -109,6 +109,12 @@ fi #================================================= # SPECIFIC REMOVE +#================================================= +# REMOVE CONF_REGEN HOOK +#================================================= + +ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/50-metronome_$app" + #================================================= # RECONFIGURE METRONOME #================================================= diff --git a/scripts/restore b/scripts/restore index 06c6649..cb44644 100644 --- a/scripts/restore +++ b/scripts/restore @@ -80,6 +80,12 @@ chown -R root: $final_path #================================================= # SPECIFIC RESTORATION +#================================================= +# RESTORE CONF_REGEN HOOK +#================================================= + +ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/50-metronome_$app" + #================================================= # REINSTALL DEPENDENCIES #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 2c46a60..957293b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -110,6 +110,12 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # SPECIFIC UPGRADE +#================================================= +# UPGRADE CONF_REGEN HOOK +#================================================= + +cp -f ../conf/metronome_regenconf_hook /usr/share/yunohost/hooks/conf_regen/50-metronome_$app + #================================================= # BUILD JITSI-VIDEOBRIDGE #================================================= From 0818c0a7ffea090239a312490cf5a6e22055bfc1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 13 Aug 2019 01:17:22 +0200 Subject: [PATCH 02/11] Adding notifications --- check_process | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check_process b/check_process index 93f5530..da085f9 100644 --- a/check_process +++ b/check_process @@ -24,8 +24,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. From ea58e6e73809b9947f5b4c494d0622f0263c2877 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 13 Aug 2019 01:25:28 +0200 Subject: [PATCH 03/11] adding information --- scripts/install | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install b/scripts/install index 10291d4..0f19cc6 100644 --- a/scripts/install +++ b/scripts/install @@ -136,6 +136,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 From aba12ab5b51f1f76c1c647e407ab12465998e661 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 13 Aug 2019 07:32:01 +0200 Subject: [PATCH 04/11] reorder hook test --- scripts/install | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index 0f19cc6..a6b00d0 100644 --- a/scripts/install +++ b/scripts/install @@ -123,12 +123,6 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # SPECIFIC SETUP -#================================================= -# SET UP CONF_REGEN HOOK -#================================================= - -cp ../conf/metronome_regenconf_hook /usr/share/yunohost/hooks/conf_regen/50-metronome_$app - #================================================= # CONFIGURE METRONOME #================================================= @@ -168,6 +162,12 @@ cp ../conf/mod_smacks.lua /usr/lib/metronome/modules/mod_smacks.lua ynh_systemd_action --service_name=metronome --action=restart +#================================================= +# SET UP CONF_REGEN HOOK +#================================================= + +cp ../conf/metronome_regenconf_hook /usr/share/yunohost/hooks/conf_regen/50-metronome_$app + #================================================= # BUILD JITSI-VIDEOBRIDGE #================================================= From e1ca3f8222646c4ecf5163d2db8781dd3320b54c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 13 Aug 2019 19:56:54 +0200 Subject: [PATCH 05/11] reorder RESTORE CONF_REGEN HOOK --- scripts/restore | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/restore b/scripts/restore index cb44644..a470ec5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -80,12 +80,6 @@ chown -R root: $final_path #================================================= # SPECIFIC RESTORATION -#================================================= -# RESTORE CONF_REGEN HOOK -#================================================= - -ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/50-metronome_$app" - #================================================= # REINSTALL DEPENDENCIES #================================================= @@ -138,6 +132,12 @@ ynh_restore_file --origin_path="/usr/lib/metronome/modules/mod_smacks.lua" ynh_systemd_action --service_name=metronome --action=restart +#================================================= +# RESTORE CONF_REGEN HOOK +#================================================= + +ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/50-metronome_$app" + #================================================= # RESTORE SYSTEMD #================================================= From 96dd6486060fcfbbd692e08e8b9d1c58948c2b68 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 25 Aug 2019 03:40:54 +0200 Subject: [PATCH 06/11] Update hooks --- conf/metronome_regen_conf.hook | 41 ++++++++++++++++++++++++++ conf/metronome_regenconf_hook | 53 ---------------------------------- scripts/_common.sh | 5 ++++ scripts/backup | 9 ++++++ scripts/install | 39 +++++++++++++------------ scripts/remove | 28 ++++++++++-------- scripts/restore | 24 ++++++--------- scripts/upgrade | 30 +++++++++++++++---- 8 files changed, 124 insertions(+), 105 deletions(-) create mode 100644 conf/metronome_regen_conf.hook delete mode 100644 conf/metronome_regenconf_hook diff --git a/conf/metronome_regen_conf.hook b/conf/metronome_regen_conf.hook new file mode 100644 index 0000000..576bbb7 --- /dev/null +++ b/conf/metronome_regen_conf.hook @@ -0,0 +1,41 @@ +#!/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() { + metronome_conf_dir="/home/yunohost.conf/pending/metronome/etc/metronome/conf.d" + domain="$(yunohost app setting jitsi domain)" + + # Delete pending metronome config + rm "${metronome_conf_dir}/$domain.cfg.lua" + rm "${metronome_conf_dir}/auth.$domain.cfg.lua" + rm "${metronome_conf_dir}/conference.$domain.cfg.lua" + rm "${metronome_conf_dir}/jitsi-videobridge.$domain.cfg.lua" + rm "${metronome_conf_dir}/focus.$domain.cfg.lua" + + # Add specific domain metronome conf + cp -f "/usr/share/yunohost/templates/jitsi/." "$metronome_conf_dir/" +} + +do_post_regen() { + # Put your code here for post regen conf. + # Be careful, this part will be executed only if the configuration has been modified. + sudo chown -R metronome: /etc/metronome/conf.d/ +} + +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/conf/metronome_regenconf_hook b/conf/metronome_regenconf_hook deleted file mode 100644 index 1d84b1b..0000000 --- a/conf/metronome_regenconf_hook +++ /dev/null @@ -1,53 +0,0 @@ -#!/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 - -# Define a temporary directory -temp_dir=/tmp/jitsi.bck - -# Retrieve Jitsi domain name -domain="$(yunohost app setting jitsi domain)" - -do_pre_regen() { - if [ $dryrun -eq 0 ] - then - # Create temporary directory - mkdir $temp_dir - - # Backup metronome config - cp -a "/etc/metronome/conf.d/$domain.cfg.lua" "$temp_dir/$domain.cfg.lua" - fi -} - -do_post_regen() { - # Backup Jitsi domain files - mv -f /etc/metronome/conf.d/$domain.cfg.lua /etc/metronome/conf.d/$domain.cfg.lua.back - mv -f /etc/metronome/conf.d/auth.$domain.cfg.lua /etc/metronome/conf.d/auth.$domain.cfg.lua.back - mv -f /etc/metronome/conf.d/conference.$domain.cfg.lua /etc/metronome/conf.d/conference.$domain.cfg.lua.back - mv -f /etc/metronome/conf.d/jitsi-videobridge.$domain.cfg.lua /etc/metronome/conf.d/jitsi-videobridge.$domain.cfg.lua.back - mv -f /etc/metronome/conf.d/focus.$domain.cfg.lua /etc/metronome/conf.d/focus.$domain.cfg.lua.back - - # Restore metronome config - cp -f "$temp_dir/$domain.cfg.lua" "/etc/metronome/conf.d/$domain.cfg.lua" - - # Delete temporary directory - test -n $temp_dir && rm -r $temp_dir - - # Reload metronome - systemctl reload metronome -} - -case "$1" in - pre) - do_pre_regen - ;; - post) - do_post_regen - ;; - *) - echo "Hook called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac 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 ae742d9..7675656 100644 --- a/scripts/backup +++ b/scripts/backup @@ -60,6 +60,11 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" # BACKUP CONF_REGEN HOOK #================================================= +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" ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/50-metronome_$app" #================================================= @@ -75,6 +80,10 @@ ynh_backup --src_path="/etc/logrotate.d/$app" ynh_print_info --message="Backing up Metronome configuration..." ynh_backup --src_path="/etc/metronome/conf.d/$domain.cfg.lua" +ynh_backup --src_path="/etc/metronome/conf.d/auth.$domain.cfg.lua" +ynh_backup --src_path="/etc/metronome/conf.d/conference.$domain.cfg.lua" +ynh_backup --src_path="/etc/metronome/conf.d/jitsi-videobridge.$domain.cfg.lua" +ynh_backup --src_path="/etc/metronome/conf.d/focus.$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" diff --git a/scripts/install b/scripts/install index a6b00d0..0467ec8 100644 --- a/scripts/install +++ b/scripts/install @@ -15,6 +15,7 @@ source /usr/share/yunohost/helpers ynh_clean_setup () { ynh_clean_check_starting + read -p "key" } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -140,33 +141,33 @@ 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 Package 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 ynh_systemd_action --service_name=metronome --action=restart -#================================================= -# SET UP CONF_REGEN HOOK -#================================================= - -cp ../conf/metronome_regenconf_hook /usr/share/yunohost/hooks/conf_regen/50-metronome_$app +read -p "key" #================================================= # BUILD JITSI-VIDEOBRIDGE diff --git a/scripts/remove b/scripts/remove index aa55ce7..4abc912 100644 --- a/scripts/remove +++ b/scripts/remove @@ -109,24 +109,28 @@ fi #================================================= # SPECIFIC REMOVE -#================================================= -# REMOVE CONF_REGEN HOOK -#================================================= - -ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/50-metronome_$app" - #================================================= # RECONFIGURE METRONOME #================================================= 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 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 + rm /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 + +# 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" diff --git a/scripts/restore b/scripts/restore index a470ec5..2035079 100644 --- a/scripts/restore +++ b/scripts/restore @@ -116,15 +116,15 @@ 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 - -ynh_restore_file --origin_path="/etc/metronome/conf.d/$domain.cfg.lua" -chown -R metronome:metronome "/etc/metronome/conf.d/" +# Restore metronome configuration +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="/usr/share/yunohost/hooks/conf_regen/50-metronome_$app" +yunohost tools regen-conf metronome 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" @@ -132,12 +132,6 @@ ynh_restore_file --origin_path="/usr/lib/metronome/modules/mod_smacks.lua" ynh_systemd_action --service_name=metronome --action=restart -#================================================= -# RESTORE CONF_REGEN HOOK -#================================================= - -ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/50-metronome_$app" - #================================================= # RESTORE SYSTEMD #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 957293b..f9075e0 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,29 @@ 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 + ynh_secure_remove --file="/etc/metronome/conf.d/$domain.cfg.lua.back" + ynh_secure_remove --file="/etc/metronome/conf.d/auth.$domain.cfg.lua.back" + ynh_secure_remove --file="/etc/metronome/conf.d/conference.$domain.cfg.lua.back" + ynh_secure_remove --file="/etc/metronome/conf.d/jitsi-videobridge.$domain.cfg.lua.back" + ynh_secure_remove --file="/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" + + 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" +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -110,12 +134,6 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # SPECIFIC UPGRADE -#================================================= -# UPGRADE CONF_REGEN HOOK -#================================================= - -cp -f ../conf/metronome_regenconf_hook /usr/share/yunohost/hooks/conf_regen/50-metronome_$app - #================================================= # BUILD JITSI-VIDEOBRIDGE #================================================= From 8c844d1145c830fa87836224b1ef9bb32941ccfe Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 25 Aug 2019 04:07:56 +0200 Subject: [PATCH 07/11] Remove read -p --- scripts/install | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/install b/scripts/install index 0467ec8..80dc320 100644 --- a/scripts/install +++ b/scripts/install @@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers ynh_clean_setup () { ynh_clean_check_starting - read -p "key" } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -167,8 +166,6 @@ cp ../conf/mod_smacks.lua /usr/lib/metronome/modules/mod_smacks.lua ynh_systemd_action --service_name=metronome --action=restart -read -p "key" - #================================================= # BUILD JITSI-VIDEOBRIDGE #================================================= From 724efe18f4684db75c98bca2c85d9e5d0a44294d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 25 Aug 2019 15:45:36 +0200 Subject: [PATCH 08/11] Cleanup and typo --- check_process | 1 + conf/metronome_regen_conf.hook | 15 ++------------- scripts/backup | 26 ++++++++++---------------- scripts/install | 2 +- scripts/remove | 14 +++++++------- scripts/restore | 5 ++++- scripts/upgrade | 10 ++++------ 7 files changed, 29 insertions(+), 44 deletions(-) diff --git a/check_process b/check_process index da085f9..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. diff --git a/conf/metronome_regen_conf.hook b/conf/metronome_regen_conf.hook index 576bbb7..c97cd4f 100644 --- a/conf/metronome_regen_conf.hook +++ b/conf/metronome_regen_conf.hook @@ -5,24 +5,13 @@ dryrun=${3:-0} # 0/1 --dry-run argument pending_conf=$4 # Path of the pending conf file do_pre_regen() { - metronome_conf_dir="/home/yunohost.conf/pending/metronome/etc/metronome/conf.d" - domain="$(yunohost app setting jitsi domain)" - - # Delete pending metronome config - rm "${metronome_conf_dir}/$domain.cfg.lua" - rm "${metronome_conf_dir}/auth.$domain.cfg.lua" - rm "${metronome_conf_dir}/conference.$domain.cfg.lua" - rm "${metronome_conf_dir}/jitsi-videobridge.$domain.cfg.lua" - rm "${metronome_conf_dir}/focus.$domain.cfg.lua" - # Add specific domain metronome conf + metronome_conf_dir="/home/yunohost.conf/pending/metronome/etc/metronome/conf.d" cp -f "/usr/share/yunohost/templates/jitsi/." "$metronome_conf_dir/" } do_post_regen() { - # Put your code here for post regen conf. - # Be careful, this part will be executed only if the configuration has been modified. - sudo chown -R metronome: /etc/metronome/conf.d/ + regen_conf_files=$1 } case "$1" in diff --git a/scripts/backup b/scripts/backup index 7675656..a643a1b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -57,16 +57,25 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SPECIFIC BACKUP #================================================= -# BACKUP CONF_REGEN HOOK +# 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 #================================================= @@ -74,21 +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="/etc/metronome/conf.d/auth.$domain.cfg.lua" -ynh_backup --src_path="/etc/metronome/conf.d/conference.$domain.cfg.lua" -ynh_backup --src_path="/etc/metronome/conf.d/jitsi-videobridge.$domain.cfg.lua" -ynh_backup --src_path="/etc/metronome/conf.d/focus.$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 80dc320..f4d7fa0 100644 --- a/scripts/install +++ b/scripts/install @@ -159,7 +159,7 @@ touch "/usr/share/yunohost/templates/jitsi/focus.$domain.cfg.lua" cp -R ../conf/metronome_regen_conf.hook /usr/share/yunohost/hooks/conf_regen/50-metronome_$app yunohost tools regen-conf metronome -# Add Metronome Package +# 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 4abc912..71c64ea 100644 --- a/scripts/remove +++ b/scripts/remove @@ -114,6 +114,13 @@ fi #================================================= ynh_print_info --message="Reconfiguring Metronome..." +# 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" @@ -130,13 +137,6 @@ fi ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/50-metronome_$app" yunohost tools regen-conf metronome -# 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 - # Delete focus user yunohost user delete $focus_user --purge diff --git a/scripts/restore b/scripts/restore index 2035079..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 -# Restore metronome configuration +# 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" + +# 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 f9075e0..9bfd717 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -46,12 +46,6 @@ if [ -z "$final_path" ]; then fi if ynh_version_gt "1.0.3387~ynh2" "${current_version}" ; then - ynh_secure_remove --file="/etc/metronome/conf.d/$domain.cfg.lua.back" - ynh_secure_remove --file="/etc/metronome/conf.d/auth.$domain.cfg.lua.back" - ynh_secure_remove --file="/etc/metronome/conf.d/conference.$domain.cfg.lua.back" - ynh_secure_remove --file="/etc/metronome/conf.d/jitsi-videobridge.$domain.cfg.lua.back" - ynh_secure_remove --file="/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/ @@ -66,6 +60,10 @@ if ynh_version_gt "1.0.3387~ynh2" "${current_version}" ; then 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 #================================================= From 867c9bea385db642b8ca40d0e95c38aef66d00fd Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 25 Aug 2019 18:40:23 +0200 Subject: [PATCH 09/11] Fix hook --- conf/metronome_regen_conf.hook | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/metronome_regen_conf.hook b/conf/metronome_regen_conf.hook index c97cd4f..a3bb2c0 100644 --- a/conf/metronome_regen_conf.hook +++ b/conf/metronome_regen_conf.hook @@ -7,7 +7,7 @@ pending_conf=$4 # Path of the pending conf file do_pre_regen() { # Add specific domain metronome conf metronome_conf_dir="/home/yunohost.conf/pending/metronome/etc/metronome/conf.d" - cp -f "/usr/share/yunohost/templates/jitsi/." "$metronome_conf_dir/" + cp -af "/usr/share/yunohost/templates/jitsi/." "$metronome_conf_dir/" } do_post_regen() { From d91a3ccae1c0c39fa210b278414da701c536d79d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 2 Sep 2019 23:09:51 +0200 Subject: [PATCH 10/11] using pending_conf --- conf/metronome_regen_conf.hook | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/conf/metronome_regen_conf.hook b/conf/metronome_regen_conf.hook index a3bb2c0..014db5b 100644 --- a/conf/metronome_regen_conf.hook +++ b/conf/metronome_regen_conf.hook @@ -6,8 +6,7 @@ pending_conf=$4 # Path of the pending conf file do_pre_regen() { # Add specific domain metronome conf - metronome_conf_dir="/home/yunohost.conf/pending/metronome/etc/metronome/conf.d" - cp -af "/usr/share/yunohost/templates/jitsi/." "$metronome_conf_dir/" + cp -af "/usr/share/yunohost/templates/jitsi/." "${pending_conf}/../metronome/etc/metronome/conf.d/" } do_post_regen() { From 30ace10b8a9f43e8a30e58d26243e03f35b67f3d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 3 Sep 2019 00:19:49 +0200 Subject: [PATCH 11/11] Fix removal --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 71c64ea..5e501d7 100644 --- a/scripts/remove +++ b/scripts/remove @@ -130,7 +130,7 @@ ynh_secure_remove --file="/usr/share/yunohost/templates/jitsi/focus.$domain.cfg. # Remove Jitsi template directory if [ -z "$(ls -A /usr/share/yunohost/templates/jitsi)" ]; then - rm /usr/share/yunohost/templates/jitsi + ynh_secure_remove --file="/usr/share/yunohost/templates/jitsi" fi # Remove Metronome Hook