From 3b0842e03d117943210deab470d9431018c340e3 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Sun, 28 Feb 2021 11:47:42 +0100 Subject: [PATCH] Simplify plugin install --- conf/credentials.json | 4 +- conf/nginx.conf | 22 ++++++---- scripts/config | 4 +- scripts/install | 100 +++++++++++++++++++++++------------------- scripts/upgrade | 15 ++++--- 5 files changed, 81 insertions(+), 64 deletions(-) diff --git a/conf/credentials.json b/conf/credentials.json index eb17770..109c327 100644 --- a/conf/credentials.json +++ b/conf/credentials.json @@ -23,10 +23,10 @@ /* An Example of MySQL Configuration */ "dbType" : "mysql", "dbSettings" : { - "user" : "__DB_USER__", + "user" : "__DB_NAME__", "host" : "localhost", "password": "__DB_PWD__", - "database": "__DB_USER__", + "database": "__DB_NAME__", "charset" : "utf8mb4" }, diff --git a/conf/nginx.conf b/conf/nginx.conf index e604ae3..f1702c1 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,3 +1,5 @@ +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +#sub_path_only rewrite ^__PATH__/admin$ __PATH__/admin/ permanent; location __PATH__/ { # Force usage of https @@ -5,17 +7,21 @@ location __PATH__/ { rewrite ^ https://$server_name$request_uri? permanent; } - #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; - #sub_path_only rewrite ^__PATH__/admin$ __PATH__/admin/ permanent; - proxy_pass http://127.0.0.1:__PORT__/; - proxy_set_header Host $host; - proxy_buffering off; + proxy_pass http://127.0.0.1:__PORT__/; + proxy_set_header Host $host; + proxy_buffering off; more_set_headers "X-Frame-Options : ALLOWALL"; - # Recommended proxy_http version for keepalive connections - # https://github.com/ether/etherpad-lite/wiki/How-to-put-Etherpad-Lite-behind-a-reverse-Proxy#nginx - proxy_http_version 1.1; + proxy_buffering off; + proxy_set_header X-Real-IP $remote_addr; # http://wiki.nginx.org/HttpProxyModule + proxy_set_header X-Forwarded-For $remote_addr; # EP logs to show the actual remote IP + proxy_set_header X-Forwarded-Proto $scheme; # for EP to set secure cookie flag when https is used + proxy_set_header Host $host; # pass the host header + proxy_http_version 1.1; # recommended with keepalive connections + # WebSocket proxying - from http://nginx.org/en/docs/http/websocket.html + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/scripts/config b/scripts/config index 23640bd..f63233f 100644 --- a/scripts/config +++ b/scripts/config @@ -85,11 +85,11 @@ pad_config_automatic_logout="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_AUTO # Etherpad skin old_pad_config_skinname="$(get_config_value skinName)" if [ "$old_pad_config_skinname" = "no-skin" ]; then - old_pad_config_skinname=noskin + old_pad_config_skinname=colibris fi pad_config_skinname="${YNH_CONFIG_MAIN_PAD_CONFIGURATION_PAD_CONFIG_SKINNAME:-$old_pad_config_skinname}" if [ "$pad_config_skinname" = "no-skin" ]; then - pad_config_skinname=noskin + pad_config_skinname=colibris fi # MyPads diff --git a/scripts/install b/scripts/install index 9849b5f..2e3152b 100644 --- a/scripts/install +++ b/scripts/install @@ -165,6 +165,12 @@ chown -R $app: $final_path pushd $final_path ynh_use_nodejs ynh_exec_as $app env "$ynh_node_load_PATH" bin/installDeps.sh + ynh_exec_as $app env "$ynh_node_load_PATH" npm install ep_spellcheck ep_countable ep_delete_empty_pads ep_subscript_and_superscript ep_headings2 ep_author_hover ep_markdown ep_comments_page ep_align ep_font_color ep_embedded_hyperlinks2 >> $install_log 2>&1 + if [ $mypads -eq 1 ]; then + # Framapad - Groups and private pads for Etherpad + ynh_exec_as $app env "$ynh_node_load_PATH" npm install ep_mypads >> $install_log 2>&1 + fi + popd #================================================= @@ -172,12 +178,16 @@ popd #================================================= ynh_script_progression --message="Configuring Etherpad..." --weight=6 +ynh_add_config --template="../conf/credentials.json" --destination="$final_path/credentials.json" + +#cp ../conf/credentials.json "$final_path/credentials.json" +#ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/credentials.json" +#ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/credentials.json" +#ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$final_path/credentials.json" +#ynh_print_OFF; ynh_replace_special_string --match_string="__PASSWORD__" --replace_string="$password" --target_file="$final_path/credentials.json"; ynh_print_ON + cp ../conf/settings.json "$final_path/settings.json" -cp ../conf/credentials.json "$final_path/credentials.json" -ynh_replace_string --match_string="__DB_USER__" --replace_string="$db_name" --target_file="$final_path/credentials.json" -ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/credentials.json" -ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$final_path/credentials.json" -ynh_print_OFF; ynh_replace_special_string --match_string="__PASSWORD__" --replace_string="$password" --target_file="$final_path/credentials.json"; ynh_print_ON + if [ "$export" = "abiword" ] then # Get abiword binary path @@ -227,47 +237,47 @@ ynh_add_systemd_config --others_var="ynh_node_load_PATH" yunohost service add $app --description="Collaborative editor" --log="/var/log/$app/etherpad.log" -#================================================= -# INSTALL FRAMAPAD'S PLUGINS -#================================================= -ynh_script_progression --message="Installing Etherpad plugins..." --weight=90 +# #================================================= +# # INSTALL FRAMAPAD'S PLUGINS +# #================================================= +# ynh_script_progression --message="Installing Etherpad plugins..." --weight=90 -pushd "$final_path" - # Add Left/Center/Right/Justify to lines of text in a pad - npm install ep_align@${ep_align_version} >> $install_log 2>&1 - # Framapad - Adds author names to span titles - npm install ep_author_hover@${ep_author_hover_version} >> $install_log 2>&1 - # Automatically disconnects user after some period of time (Prevent server overload) - npm install ep_automatic_logut@${ep_automatic_logut_version} >> $install_log 2>&1 - # Framapad - Adds comments on sidebar and link it to the text. - npm install ep_comments_page@${ep_comments_page_version} >> $install_log 2>&1 - # Framapad - Displays paragraphs, sentences, words and characters counts. - npm install ep_countable@${ep_countable_version} >> $install_log 2>&1 - # Framapad - Delete pads which were never edited - npm install ep_delete_empty_pads@${ep_delete_empty_pads_version} >> $install_log 2>&1 - # Framapad - Apply colors to fonts - npm install ep_font_color@${ep_font_color_version} >> $install_log 2>&1 - # Framapad - User Pad Contents font size can be set in settings, this does not effect other peoples views - npm install ep_font_size@${ep_font_size_version} >> $install_log 2>&1 - # Framapad - Adds heading support to Etherpad Lite. - npm install ep_headings2@${ep_headings2_version} >> $install_log 2>&1 - # Framapad - Edit and Export as Markdown in Etherpad - npm install ep_markdown@${ep_markdown_version} >> $install_log 2>&1 - if [ $mypads -eq 1 ]; then - # Framapad - Groups and private pads for Etherpad - npm install ep_mypads@${mypads_version} >> $install_log 2>&1 - fi - # Framapad - Add support to do 'page view', with a toggle on/off option in Settings, also Page Breaks with Control Enter - npm install ep_page_view@${ep_page_view_version} >> $install_log 2>&1 - # Framapad - Add support to do 'Spell checking' - npm install ep_spellcheck@${ep_spellcheck_version} >> $install_log 2>&1 - # Framapad - Add support for Subscript and Superscript - npm install ep_subscript_and_superscript@${ep_subscript_and_superscript_version} >> $install_log 2>&1 - # Framapad - View a table of contents for your pad - npm install ep_table_of_contents@${ep_table_of_contents_version} >> $install_log 2>&1 -popd +# pushd "$final_path" +# # Add Left/Center/Right/Justify to lines of text in a pad +# npm install ep_align@${ep_align_version} >> $install_log 2>&1 +# # Framapad - Adds author names to span titles +# npm install ep_author_hover@${ep_author_hover_version} >> $install_log 2>&1 +# # Automatically disconnects user after some period of time (Prevent server overload) +# npm install ep_automatic_logut@${ep_automatic_logut_version} >> $install_log 2>&1 +# # Framapad - Adds comments on sidebar and link it to the text. +# npm install ep_comments_page@${ep_comments_page_version} >> $install_log 2>&1 +# # Framapad - Displays paragraphs, sentences, words and characters counts. +# npm install ep_countable@${ep_countable_version} >> $install_log 2>&1 +# # Framapad - Delete pads which were never edited +# npm install ep_delete_empty_pads@${ep_delete_empty_pads_version} >> $install_log 2>&1 +# # Framapad - Apply colors to fonts +# npm install ep_font_color@${ep_font_color_version} >> $install_log 2>&1 +# # Framapad - User Pad Contents font size can be set in settings, this does not effect other peoples views +# npm install ep_font_size@${ep_font_size_version} >> $install_log 2>&1 +# # Framapad - Adds heading support to Etherpad Lite. +# npm install ep_headings2@${ep_headings2_version} >> $install_log 2>&1 +# # Framapad - Edit and Export as Markdown in Etherpad +# npm install ep_markdown@${ep_markdown_version} >> $install_log 2>&1 +# if [ $mypads -eq 1 ]; then +# # Framapad - Groups and private pads for Etherpad +# npm install ep_mypads@${mypads_version} >> $install_log 2>&1 +# fi +# # Framapad - Add support to do 'page view', with a toggle on/off option in Settings, also Page Breaks with Control Enter +# npm install ep_page_view@${ep_page_view_version} >> $install_log 2>&1 +# # Framapad - Add support to do 'Spell checking' +# npm install ep_spellcheck@${ep_spellcheck_version} >> $install_log 2>&1 +# # Framapad - Add support for Subscript and Superscript +# npm install ep_subscript_and_superscript@${ep_subscript_and_superscript_version} >> $install_log 2>&1 +# # Framapad - View a table of contents for your pad +# npm install ep_table_of_contents@${ep_table_of_contents_version} >> $install_log 2>&1 +# popd -chown -R $app: $final_path/node_modules +# chown -R $app: $final_path/node_modules #================================================= # SOME HACKS @@ -291,7 +301,7 @@ fi #================================================= # SETUP FAIL2BAN #================================================= -ynh_script_progression --message="Configuring Fail2Ban..." --weight=13 +ynh_script_progression --message="Configuring Fail2Ban..." --weight=60 # Create a dedicated Fail2Ban config ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex=" .* .POST /mypads/api/auth/login HTTP/1.1. 400" --max_retry=5 diff --git a/scripts/upgrade b/scripts/upgrade index acdfec4..d3ac1c5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -28,6 +28,7 @@ port=$(ynh_app_setting_get --app=$app --key=port) export=$(ynh_app_setting_get --app=$app --key=export) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +ynh_print_OFF; password=$(ynh_app_setting_get --app=$app --key=password); ynh_print_ON mypads=$(ynh_app_setting_get --app=$app --key=mypads) useldap=$(ynh_app_setting_get --app=$app --key=useldap) overwrite_settings=$(ynh_app_setting_get --app=$app --key=overwrite_settings) @@ -309,13 +310,13 @@ then then # Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ynh_backup_if_checksum_is_different --file="$final_path/credentials.json" - cp ../conf/credentials.json "$final_path/credentials.json" + ynh_add_config --template="../conf/credentials.json" --destination="$final_path/credentials.json" - ynh_replace_string --match_string="__DB_USER__" --replace_string="$app" --target_file="$final_path/credentials.json" - ynh_print_OFF; password=$(ynh_app_setting_get --app=$app --key=password); ynh_print_ON - ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/credentials.json" - ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$final_path/credentials.json" - ynh_print_OFF; ynh_replace_special_string --match_string="__PASSWORD__" --replace_string="$password" --target_file="$final_path/credentials.json"; ynh_print_ON + #cp ../conf/credentials.json "$final_path/credentials.json" + #ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/credentials.json" + #ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/credentials.json" + #ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="$final_path/credentials.json" + #ynh_print_OFF; ynh_replace_special_string --match_string="__PASSWORD__" --replace_string="$password" --target_file="$final_path/credentials.json"; ynh_print_ON # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$final_path/credentials.json" @@ -349,7 +350,7 @@ yunohost service add $app --description="Collaborative editor" --log="/var/log/$ #================================================= # UPGRADE FAIL2BAN #================================================= -ynh_script_progression --message="Reconfiguring Fail2ban..." --weight=8 +ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=8 # Create a dedicated fail2ban config ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-access.log" --failregex=" .* .POST /mypads/api/auth/login HTTP/1.1. 400" --max_retry=5