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

Multi-instance and other minor fixes

This commit is contained in:
Jimmy Monin 2018-04-08 17:23:18 +02:00
parent 185ca464b3
commit a389c47520

View file

@ -153,7 +153,7 @@ ynh_store_file_checksum "$ldap_config_file"
#================================================= #=================================================
puma_config_file="$final_path/config/puma.rb" 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 "#{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" ynh_replace_string "daemonize true" "daemonize false" "$puma_config_file"
# Calculate and store the config file checksum # Calculate and store the config file checksum
ynh_store_file_checksum "$puma_config_file" ynh_store_file_checksum "$puma_config_file"
@ -186,8 +186,8 @@ cp ../conf/sidekiq.yml "$final_path/config/sidekiq.yml"
# PREPARE THE DATABASE # PREPARE THE DATABASE
#================================================= #=================================================
(cd "$final_path"
rake_exec="exec_as $app bin/rake RAILS_ENV=production" rake_exec="exec_as $app bin/rake RAILS_ENV=production"
(cd "$final_path"
$rake_exec db:migrate $rake_exec db:migrate
$rake_exec assets:precompile) $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()'); 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 ('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_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 ('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 ('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()'); 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()'); 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 # FIX INITIAL POSTS LINKS FOR SUBFOLDER INSTALL
#================================================= #=================================================
if [ "$path_url" != "/" ] ; then 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 fi
@ -231,7 +224,7 @@ fi
# Create a random password # Create a random password
admin_pwd=$(ynh_string_random) admin_pwd=$(ynh_string_random)
(cd "$final_path" (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
$admin_pwd $admin_pwd
y 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 app is public, add url to SSOWat conf as skipped_uris
if [ $is_public -eq 1 ]; then if [ $is_public -eq 1 ]; then
# unprotected_uris allows SSO credentials to be passed anyway. # unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set "$app" unprotected_uris "/" ynh_app_setting_set "$app" skipped_uris "/"
fi fi
#================================================= #=================================================
@ -307,3 +300,5 @@ systemctl reload nginx
# Wait for discourse-puma to be fully started # Wait for discourse-puma to be fully started
# As discourse-sidekiq is a dependency, it is automatically started before # As discourse-sidekiq is a dependency, it is automatically started before
ynh_check_starting_systemd "Use Ctrl-C to stop" "$app-puma" "120" 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