From a389c47520dfa19ba5d16a706bca34107e05be3c Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Sun, 8 Apr 2018 17:23:18 +0200 Subject: [PATCH] Multi-instance and other minor fixes --- scripts/install | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/scripts/install b/scripts/install index 74bfc07..7fc3cc0 100644 --- a/scripts/install +++ b/scripts/install @@ -153,7 +153,7 @@ ynh_store_file_checksum "$ldap_config_file" #================================================= puma_config_file="$final_path/config/puma.rb" ynh_replace_string "#{APP_ROOT}/log/puma" "/var/log/$app/puma" "$puma_config_file" -ynh_replace_string "/home/discourse" "/var/www" "$puma_config_file" +ynh_replace_string "/home/discourse/discourse" "/var/www/$app" "$puma_config_file" ynh_replace_string "daemonize true" "daemonize false" "$puma_config_file" # Calculate and store the config file checksum ynh_store_file_checksum "$puma_config_file" @@ -186,8 +186,8 @@ cp ../conf/sidekiq.yml "$final_path/config/sidekiq.yml" # PREPARE THE DATABASE #================================================= -(cd "$final_path" rake_exec="exec_as $app bin/rake RAILS_ENV=production" +(cd "$final_path" $rake_exec db:migrate $rake_exec assets:precompile) @@ -198,7 +198,7 @@ $rake_exec assets:precompile) ynh_psql_connect_as $db_name $db_pwd $db_name <<< "INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('title', 1, 'YunoHost Forum', 'NOW()', 'NOW()'); INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('site_description', 1, 'YunoHost Forum', 'NOW()', 'NOW()'); INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('contact_email', 14, '$admin_mail', 'NOW()', 'NOW()'); -INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('contact_url', 1, '$domain$path_rul', 'NOW()', 'NOW()'); +INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('contact_url', 1, '$domain$path_url', 'NOW()', 'NOW()'); INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('site_contact_username', 15, '$admin', 'NOW()', 'NOW()'); INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('logo_url', 1, '${path_url%/}/images/d-logo-sketch.png', 'NOW()', 'NOW()'); INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('long_polling_base_url', 1, '${path_url%/}/', 'NOW()', 'NOW()'); @@ -208,19 +208,12 @@ INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUE INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('wizard_enabled', 5, 'f', 'NOW()', 'NOW()'); " -toto="INSERT INTO site_settings (name, value) VALUES ('title', 1, 'YunoHost Forum'); -INSERT INTO site_settings (name, data_type, value) VALUES ('site_description', 1, 'YunoHost Forum'); -INSERT INTO site_settings (name, data_type, value) VALUES ('contact_email', 14, '$admin_mail'); -INSERT INTO site_settings (name, data_type, value) VALUES ('contact_url', 1, '$domain$path_url'); -INSERT INTO site_settings (name, data_type, value) VALUES ('site_contact_username', 15, '$admin'); -INSERT INTO site_settings (name, data_type, value) VALUES ('logo_url', 1, '${path_url%/}/images/d-logo-sketch.png'); -INSERT INTO site_settings (name, data_type, value) VALUES ('long_polling_base_url', 1, '${path_url%/}/');" - #================================================= # FIX INITIAL POSTS LINKS FOR SUBFOLDER INSTALL #================================================= + if [ "$path_url" != "/" ] ; then - (cd /$final_path ; RAILS_ENV=production sudo -H -E -u discourse bundle exec script/discourse remap /images/welcome/ $path_url/images/welcome/ <<< "YES + (cd /$final_path ; RAILS_ENV=production sudo -H -E -u $app bundle exec script/discourse remap /images/welcome/ $path_url/images/welcome/ <<< "YES ") fi @@ -231,7 +224,7 @@ fi # Create a random password admin_pwd=$(ynh_string_random) (cd "$final_path" -sudo -u discourse bin/rake RAILS_ENV=production admin:create <<< "$admin_mail +$rake_exec admin:create <<< "$admin_mail $admin_pwd $admin_pwd y @@ -291,7 +284,7 @@ yunohost service add $app-sidekiq --log "/var/www/$app/log/production.log" # If app is public, add url to SSOWat conf as skipped_uris if [ $is_public -eq 1 ]; then # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set "$app" unprotected_uris "/" + ynh_app_setting_set "$app" skipped_uris "/" fi #================================================= @@ -307,3 +300,5 @@ systemctl reload nginx # Wait for discourse-puma to be fully started # As discourse-sidekiq is a dependency, it is automatically started before ynh_check_starting_systemd "Use Ctrl-C to stop" "$app-puma" "120" +# Additional pause to avoid 502 errors in package_check after reinstall... +sleep 120s