mirror of
https://github.com/YunoHost-Apps/jitsi_ynh.git
synced 2024-09-03 19:35:57 +02:00
Update hooks
This commit is contained in:
parent
e1ca3f8222
commit
96dd648606
8 changed files with 124 additions and 105 deletions
41
conf/metronome_regen_conf.hook
Normal file
41
conf/metronome_regen_conf.hook
Normal file
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||
#=================================================
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
#=================================================
|
||||
|
|
|
@ -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
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue