diff --git a/conf/env.sample b/conf/env.sample index 593faf8..c1fb654 100644 --- a/conf/env.sample +++ b/conf/env.sample @@ -62,5 +62,7 @@ REVISIONS_FREQUENCY=300 # Sub-URI RAILS_RELATIVE_URL_ROOT=/ -# Enable public file server +# Public file server +# Empty is disabled +# Any value is enabled RAILS_SERVE_STATIC_FILES= diff --git a/scripts/change_url b/scripts/change_url index 515f083..29023a0 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -29,6 +29,8 @@ ynh_script_progression --message="Loading installation settings..." --weight=1 # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) port=$(ynh_app_setting_get --app=$app --key=port) +install_extensions=$(ynh_app_setting_get --app=$app --key=install_extensions) +access_domain=$(ynh_app_setting_get --app=$app --key=access_domain) # Add settings here as needed by your application #db_name=$(ynh_app_setting_get --app=$app --key=db_name) @@ -93,7 +95,7 @@ then domain="$old_domain" path_url="$new_path" # Create a dedicated nginx config - ynh_add_nginx_config "port" + ynh_add_nginx_config "port access_domain" fi # Change the domain for nginx @@ -114,6 +116,26 @@ ynh_script_progression --message="Modifying a config file..." --weight=1 config_file="$final_path/live/.env" ynh_replace_string --match_string="RAILS_RELATIVE_URL_ROOT=$old_path" --replace_string="RAILS_RELATIVE_URL_ROOT=$new_path" --target_file="$config_file" +#================================================= +# Modify Standard Notes - Extensions +#================================================= +if [ $install_extensions ] +then + ynh_script_progression --message="Modify Standard Notes - Extensions..." --weight=1 + + if [ $new_path = "/" ] + then + path="" + else + path=$new_path + fi + + find "$final_path/live/public/extensions/src/" -name "*.json" -print0 | while read -d $'\0' file + do + ynh_replace_string --match_string='"url": "https://.*/extensions/src/' --replace_string='"url": "https://$domain$path/extensions/src/' --target_file="$file" + done +fi + #================================================= # SETUP FAIL2BAN #================================================= diff --git a/scripts/install b/scripts/install index 61cb3d3..f5c91a9 100755 --- a/scripts/install +++ b/scripts/install @@ -164,15 +164,15 @@ if [ $install_extensions ] then ynh_script_progression --message="Installing Standard Notes - Extensions..." --weight=1 - ynh_replace_string --match_string="RAILS_SERVE_STATIC_FILES=" --replace_string="RAILS_SERVE_STATIC_FILES=true" --target_file="$config_file" - + ynh_replace_string --match_string="^RAILS_SERVE_STATIC_FILES=.*$" --replace_string="RAILS_SERVE_STATIC_FILES=true" --target_file="$config_file" + if [ $path_url = "/" ] then path="" else path=$path_url fi - + find "$final_path/live/public/extensions/src/" -name "*.json" -print0 | while read -d $'\0' file do ynh_replace_string --match_string="__DOMAIN__PATH__" --replace_string="$domain$path" --target_file="$file" diff --git a/scripts/upgrade b/scripts/upgrade index 3c303fb..7a7cdc3 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -180,7 +180,7 @@ then exec_as "$app" env PATH=$PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle config set with 'development' exec_as "$app" env PATH=$PATH /opt/rbenv/versions/$RUBY_VERSION/bin/bundle install exec_as "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails db:create db:migrate --quiet - exec_as "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails assets:precompile --quiet +# exec_as "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/$RUBY_VERSION/bin/bundle exec rails assets:precompile --quiet popd fi @@ -189,9 +189,27 @@ fi #================================================= if [ $install_extensions ] then - ynh_script_progression --message="Installing Standard Notes - Extensions..." --weight=1 + ynh_script_progression --message="Reinstalling Standard Notes - Extensions..." --weight=1 - ynh_replace_string --match_string="RAILS_SERVE_STATIC_FILES=false" --replace_string="RAILS_SERVE_STATIC_FILES=true" --target_file="$config_file" + ynh_replace_string --match_string="^RAILS_SERVE_STATIC_FILES=.*$" --replace_string="RAILS_SERVE_STATIC_FILES=true" --target_file="$config_file" + + if [ $path_url = "/" ] + then + path="" + else + path=$path_url + fi + + find "$final_path/live/public/extensions/src/" -name "*.json" -print0 | while read -d $'\0' file + do + ynh_replace_string --match_string="__DOMAIN__PATH__" --replace_string="$domain$path" --target_file="$file" + done + + find "../conf/" -name "ext_*.src" -print0 | while read -d $'\0' file + do + basename=$(basename -as .src $file) + ynh_setup_source --dest_dir="$final_path/live/public/extensions/src/${basename#'ext_'}" --source_id="$basename" + done fi #=================================================