From d1cd27f009e1beb1db640cbd81dba19e257d613e Mon Sep 17 00:00:00 2001 From: nemsia Date: Fri, 26 May 2017 23:29:05 +0200 Subject: [PATCH] [enh] final_path on nginx.conf --- scripts/backup | 2 +- scripts/restore | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/backup b/scripts/backup index 73372e3..dc81ab8 100644 --- a/scripts/backup +++ b/scripts/backup @@ -24,7 +24,7 @@ final_path="/opt/${app}" ynh_backup "$final_path" "sources" 1 # final_path on nginx -sudo sed -i "s@$final_path@__FINALPATH__@g" ../conf/nginx.conf +sudo sed -i "s@$final_path@__FINALPATH__@g" /etc/nginx/conf.d/${domain}.d/${app}.conf # Copy the nginx conf files ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" diff --git a/scripts/restore b/scripts/restore index 84828b1..4ac7f93 100644 --- a/scripts/restore +++ b/scripts/restore @@ -35,30 +35,30 @@ fi # Check configuration files nginx nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf" if [ -f $nginx_conf ]; then - ynh_die "The NGINX configuration already exists at '${nginx_conf}'. + ynh_die "The NGINX configuration already exists at '${nginx_conf}'. You should safely delete it before restoring this app." fi # Check configuration files php-fpm crontab_conf="/etc/cron.d/${app}" -if [ -f $crontab_conf ]; then - ynh_die "The CRONTAB configuration already exists at '${crontab_conf}'. +if [ -f $crontab_conf ]; then + ynh_die "The CRONTAB configuration already exists at '${crontab_conf}'. You should safely delete it before restoring this app." fi # Restore services web_systemd="/etc/systemd/system/${app}-web.service" if [ -f "${web_systemd}" ]; then - ynh_die "The MASTODON WEB configuration already exists at '${web_systemd}'. + ynh_die "The MASTODON WEB configuration already exists at '${web_systemd}'. You should safely delete it before restoring this app." fi sidekiq_systemd="/etc/systemd/system/${app}-sidekiq.service" if [ -f "${sidekiq_systemd}" ]; then - ynh_die "The MASTODON SIDEKIQ configuration already exists at '${sidekiq_systemd}'. + ynh_die "The MASTODON SIDEKIQ configuration already exists at '${sidekiq_systemd}'. You should safely delete it before restoring this app." fi streaming_systemd="/etc/systemd/system/${app}-streaming.service" if [ -f "${streaming_systemd}" ]; then - ynh_die "The MASTODON STREAMING configuration already exists at '${streaming_systemd}'. + ynh_die "The MASTODON STREAMING configuration already exists at '${streaming_systemd}'. You should safely delete it before restoring this app." fi @@ -97,7 +97,7 @@ sudo adduser $app --home /opt/$app --gecos "First Last,RoomNumber,WorkPhone,Home # Return to home popd - + # Restore sources & data sudo cp -a ./sources/. "$final_path" @@ -150,7 +150,9 @@ ynh_secure_remove $final_path/mastodon_db.sql # Create symlink for ruby sudo ln -s /opt/mastodon/.rbenv/versions/2.4.1/bin/ruby /usr/bin/ruby || true -# Restore nginx configuration files +# Modify Nginx configuration file and copy it to Nginx conf directory +sudo sed -i "s@__PATH__@$app@g" ./nginx.conf +sudo sed -i "s@__FINALPATH__@$final_path/@g" ./nginx.conf sudo cp -a ./nginx.conf "$nginx_conf" # Restore crontab sudo cp -a ./cron.conf "$crontab_conf"