From 2a5d98f7a8fa28bee0b58f51261233a5699d2001 Mon Sep 17 00:00:00 2001 From: mhfowler Date: Wed, 6 Oct 2021 12:35:46 +0200 Subject: [PATCH] Remove wildcard domain --- conf/systemd.service | 2 +- scripts/_common.sh | 14 -------------- scripts/backup | 2 +- scripts/change_url | 28 +++++++++++++++++++++++----- scripts/install | 5 ++--- scripts/remove | 5 +---- scripts/restore | 2 +- scripts/upgrade | 14 -------------- 8 files changed, 29 insertions(+), 43 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index 0fe421f..3f55017 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -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 diff --git a/scripts/_common.sh b/scripts/_common.sh index e7862b3..ac25ae5 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -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 #================================================= diff --git a/scripts/backup b/scripts/backup index 8e59560..01326c1 100755 --- a/scripts/backup +++ b/scripts/backup @@ -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 diff --git a/scripts/change_url b/scripts/change_url index 5b82867..ca3b5cf 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -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 diff --git a/scripts/install b/scripts/install index 76a2a98..117c94d 100755 --- a/scripts/install +++ b/scripts/install @@ -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 diff --git a/scripts/remove b/scripts/remove index 54fd75b..ce04534 100755 --- a/scripts/remove +++ b/scripts/remove @@ -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 diff --git a/scripts/restore b/scripts/restore index 67e6b1f..b0816d7 100755 --- a/scripts/restore +++ b/scripts/restore @@ -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 diff --git a/scripts/upgrade b/scripts/upgrade index 855b543..2c3a9dc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -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