1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/garage_ynh.git synced 2024-09-03 18:36:32 +02:00

change hook mechanism

This commit is contained in:
oiseauroch 2023-03-17 09:57:02 +01:00
parent d54595c39a
commit 571439b31b
6 changed files with 47 additions and 25 deletions

View file

@ -1,16 +0,0 @@
#!/bin/bash
source /usr/share/yunohost/helpers
garage_domains=$(yunohost app list --json | jq '.apps[] | select(.id | test("garage*")) | .domain_path')
for domain in $garage_domains;
do
domain=${domain//\"/}
if [[ "$domain" =~ "/" ]]
then
domain=${domain/\//}
ynh_replace_special_string --match_string="server_name $domain;" --replace_string="server_name $domain *.$>
fi
done

View file

@ -66,6 +66,7 @@ ynh_backup --src_path="$final_path"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
#================================================= #=================================================
@ -74,6 +75,12 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP HOOK
#=================================================
ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app"
#================================================= #=================================================
# BACKUP SYSTEMD # BACKUP SYSTEMD
#================================================= #=================================================
@ -81,6 +88,8 @@ ynh_backup --src_path="/etc/logrotate.d/$app"
ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/systemd/system/$app.service"
ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -201,14 +201,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_add_nginx_config
#add wildcard subdomain
ynh_replace_special_string --match_string="server_name $domain;" --replace_string="server_name $domain *.$domain;" --target_file="/etc/nginx/conf.d/$domain.conf"
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.conf"
#=================================================
# SPECIFIC SETUP
#=================================================
# ...
#=================================================
#================================================= #=================================================
# ADD A CONFIGURATION # ADD A CONFIGURATION
@ -292,6 +284,19 @@ then
VIRTUALISATION=true $final_path/umount_disk.sh VIRTUALISATION=true $final_path/umount_disk.sh
fi fi
#=================================================
# ADD REGEN-CONF HOOK
#=================================================
ynh_script_progression --message="adding regen-conf hook..." --weight=1
ynh_add_config --template="../sources/hooks/conf_regen/98-nginx_garage" --destination="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app"
#cp -R ../sources/hooks/conf_regen/98-nginx_garage /usr/share/yunohost/hooks/conf_regen/95-nginx_$app
ynh_systemd_action --service_name=nginx --action="reload"
#================================================= #=================================================
# SETUP SYSTEMD # SETUP SYSTEMD
#================================================= #=================================================

View file

@ -96,6 +96,10 @@ ynh_secure_remove --file="$final_path"
ynh_script_progression --message="Removing app data directory..." --weight=1 ynh_script_progression --message="Removing app data directory..." --weight=1
ynh_secure_remove --file="$datadir" ynh_secure_remove --file="$datadir"
#=================================================
# REMOVE NGINX HOOK
#=================================================
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
@ -147,6 +151,10 @@ ynh_script_progression --message="Removing the dedicated system user..." --weig
# Delete a system user # Delete a system user
ynh_system_user_delete --username=$app ynh_system_user_delete --username=$app
ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app"
yunohost tools regen-conf nginx
ynh_systemd_action --service_name=nginx --action="reload"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -115,7 +115,11 @@ ynh_script_progression --message="Restoring the NGINX web server configuration..
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#add wildcard subdomain #add wildcard subdomain
ynh_replace_special_string --match_string="server_name $domain" --replace_string="server_name $domain *.$domain" --target_file="/etc/nginx/conf.d/$domain.conf"
ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app"
yunohost tools regen-conf nginx
ynh_systemd_action --service_name=nginx --action="reload"
#================================================= #=================================================

View file

@ -0,0 +1,12 @@
#!/bin/bash
action=$1
pending_dir=$4
domain=__DOMAIN__
app=__APP__
[[ "$action" == "pre" ]] || exit 0
source /usr/share/yunohost/helpers
ynh_replace_special_string --match_string="server_name $domain" --replace_string="server_name $domain *.$domain" --target_file="/etc/nginx/conf.d/$domain.conf"
ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.conf"