1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ssbroom_ynh.git synced 2024-09-03 20:26:29 +02:00

Remove wildcard domain

This commit is contained in:
mhfowler 2021-10-06 12:35:46 +02:00
parent 3840731c91
commit 2a5d98f7a8
8 changed files with 29 additions and 43 deletions

View file

@ -7,7 +7,7 @@ Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__DATADIR__/
ExecStart=__FINALPATH__/go-ssb-room -repo __DATADIR__/ -lishttp localhost:__PORT__ -https-domain __DOMAIN__ -lismux :__SSBPORT__
ExecStart=__FINALPATH__/go-ssb-room -repo __DATADIR__/ -lishttp localhost:__PORT__ -https-domain __DOMAIN__ -lismux :__SSBPORT__ -aliases-as-subdomains false
StandardOutput=append:/var/log/__APP__/__APP__.log
StandardError=inherit

View file

@ -11,20 +11,6 @@ pkg_dependencies=""
# PERSONAL HELPERS
#=================================================
# because ssbroom requires wildcard subdomains for aliases
# we need this custom function for creating the ssbroom nginx config
# instead of the standard ynh_add_nginx_config
add_ssb_room_nginx_config() {
domain=$1
domainregex=$(echo "$domain" | sed -r 's/\./\\\./g')
# the sed statement above replaces all . with \.
ynh_add_config --template="full_nginx.conf" --destination="/etc/nginx/conf.d/$domain.conf"
}
remove_ssb_room_nginx_config() {
rm "/etc/nginx/conf.d/$domain.conf"
}
#=================================================
# EXPERIMENTAL HELPERS
#=================================================

View file

@ -58,7 +58,7 @@ ynh_backup --src_path="$datadir" --is_big
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.conf"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP

View file

@ -81,11 +81,29 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1
# because ssbroom requires wildcard subdomains for aliases
# we need this custom function for creating the ssbroom nginx config
# instead of the standard ynh_add_nginx_config
remove_ssb_room_nginx_config $old_domain
add_ssb_room_nginx_config $new_domain
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
# Change the path in the NGINX config file
if [ $change_path -eq 1 ]
then
# Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
path_url="$new_path"
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location
ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
# GENERIC FINALISATION

View file

@ -104,9 +104,8 @@ chown -R $app:www-data "$final_path"
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --time --weight=1
# because ssbroom requires wildcard subdomains for aliases
# we need this custom function for creating the ssbroom nginx config
add_ssb_room_nginx_config $domain
# add nginx config
ynh_add_nginx_config
#=================================================
# CREATE DATA DIRECTORY

View file

@ -80,11 +80,8 @@ ynh_secure_remove --file="$datadir"
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --time --weight=1
# because ssbroom requires wildcard subdomains for aliases
# we need this custom function for creating/removing the ssbroom nginx config
# instead of the standard ynh_add_nginx_config
# Remove the dedicated NGINX config
remove_ssb_room_nginx_config $domain
ynh_remove_nginx_config
#=================================================
# CLOSE A PORT

View file

@ -48,7 +48,7 @@ test ! -d $final_path \
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..." --time --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.conf"
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RECREATE THE DEDICATED USER

View file

@ -146,13 +146,6 @@ ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
ynh_install_app_dependencies $pkg_dependencies
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --time --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
#=================================================
# SPECIFIC UPGRADE
@ -217,13 +210,6 @@ ynh_script_progression --message="Starting a systemd service..." --time --weight
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
#=================================================
# UPGRADE FAIL2BAN
#=================================================
ynh_script_progression --message="Reconfiguring Fail2Ban..." --time --weight=1
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
#=================================================
# RELOAD NGINX