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 #=================================================