From 7315af415064f1321c57361e79723244e5eec4d1 Mon Sep 17 00:00:00 2001 From: Martin Spiering Date: Thu, 17 Nov 2022 21:38:07 +0100 Subject: [PATCH 01/13] Send the jwt token via email to the admin --- conf/msg_install | 11 +++ manifest.json | 4 + scripts/install | 12 +++ scripts/ynh_send_readme_to_admin__2 | 127 ++++++++++++++++++++++++++++ 4 files changed, 154 insertions(+) create mode 100644 conf/msg_install create mode 100644 scripts/ynh_send_readme_to_admin__2 diff --git a/conf/msg_install b/conf/msg_install new file mode 100644 index 0000000..ed257a7 --- /dev/null +++ b/conf/msg_install @@ -0,0 +1,11 @@ +__APP__ was successfully installed :) + +Please open your __APP__ domain: https://__DOMAIN____PATH_URL__ + +To configure your OnlyOffice with your Nextcloud, go to the settings : + - under "Administration > ONLYOFFICE > Server settings > Address of the Document Server" enter "https://__DOMAIN____PATH_URL__" + - under "Administration > ONLYOFFICE > Server settings > Secret key" enter "__JWT_TOKEN__" + +Your OnlyOffice should now work with your Nextcloud! + +If you are facing any problem or want to improve this app, please open a new issue here: https://github.com/YunoHost-Apps/onlyoffice_ynh \ No newline at end of file diff --git a/manifest.json b/manifest.json index b296ef8..cb806e9 100644 --- a/manifest.json +++ b/manifest.json @@ -69,6 +69,10 @@ "fr": "Installez le connecteur OnlyOffice pour Γ©diter des documents dans Nextcloud." }, "default": "yunohost.domain/nextcloud" + }, + { + "name": "admin", + "type": "user" } ] } diff --git a/scripts/install b/scripts/install index 9d3a30c..e536ea8 100644 --- a/scripts/install +++ b/scripts/install @@ -8,6 +8,7 @@ source _common.sh source /usr/share/yunohost/helpers +source ynh_send_readme_to_admin__2 #================================================= # MANAGE SCRIPT FAILURE @@ -26,6 +27,8 @@ is_public=$YNH_APP_ARG_IS_PUBLIC nextclouddomain=$YNH_APP_ARG_NEXTCLOUDDOMAIN app=$YNH_APP_INSTANCE_NAME +admin=$YNH_APP_ARG_ADMIN +admin_mail=$(ynh_user_get_info --username=$admin --key="mail") #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS @@ -187,6 +190,15 @@ ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload +#================================================= +# SEND A README FOR THE ADMIN +#================================================= +ynh_script_progression --message="Sending a readme for the admin..." + +jwt_token=$(documentserver-jwt-status.sh | sed "3q;d" | cut -d "-" -f 2 | tr -d ' ') + +ynh_send_readme_to_admin --app_message="../conf/msg_install" --recipients=$admin_mail --type='install' + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/ynh_send_readme_to_admin__2 b/scripts/ynh_send_readme_to_admin__2 new file mode 100644 index 0000000..0d4403d --- /dev/null +++ b/scripts/ynh_send_readme_to_admin__2 @@ -0,0 +1,127 @@ +#!/bin/bash + +# Send an email to inform the administrator +# +# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type] +# | arg: -m --app_message= - The file with the content to send to the administrator. +# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root +# example: "root admin@domain" +# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you +# example: "root admin@domain user1 user2" +# | arg: -t, --type= - Type of mail, could be 'backup', 'change_url', 'install', 'remove', 'restore', 'upgrade' +# +# Requires YunoHost version 4.1.0 or higher. +ynh_send_readme_to_admin() { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [m]=app_message= [r]=recipients= [t]=type= ) + local app_message + local recipients + local type + # Manage arguments with getopts + + ynh_handle_getopts_args "$@" + app_message="${app_message:-}" + recipients="${recipients:-root}" + type="${type:-install}" + + # Get the value of admin_mail_html + admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) + admin_mail_html="${admin_mail_html:-0}" + + # Retrieve the email of users + find_mails () { + local list_mails="$1" + local mail + local recipients=" " + # Read each mail in argument + for mail in $list_mails + do + # Keep root or a real email address as it is + if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@" + then + recipients="$recipients $mail" + else + # But replace an user name without a domain after by its email + if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null) + then + recipients="$recipients $mail" + fi + fi + done + echo "$recipients" + } + recipients=$(find_mails "$recipients") + + # Subject base + local mail_subject="β˜οΈπŸ†ˆπŸ…½πŸ…·β˜οΈ: \`$app\`" + + # Adapt the subject according to the type of mail required. + if [ "$type" = "backup" ]; then + mail_subject="$mail_subject has just been backup." + elif [ "$type" = "change_url" ]; then + mail_subject="$mail_subject has just been moved to a new URL!" + elif [ "$type" = "remove" ]; then + mail_subject="$mail_subject has just been removed!" + elif [ "$type" = "restore" ]; then + mail_subject="$mail_subject has just been restored!" + elif [ "$type" = "upgrade" ]; then + mail_subject="$mail_subject has just been upgraded!" + else # install + mail_subject="$mail_subject has just been installed!" + fi + + ynh_add_config --template="$app_message" --destination="../conf/msg__to_send" + + ynh_delete_file_checksum --file="../conf/msg__to_send" + + local mail_message="This is an automated message from your beloved YunoHost server. +Specific information for the application $app. +$(cat "../conf/msg__to_send")" + + # Store the message into a file for further modifications. + echo "$mail_message" > mail_to_send + + # If a html email is required. Apply html tags to the message. + if [ "$admin_mail_html" -eq 1 ] + then + # Insert 'br' tags at each ending of lines. + ynh_replace_string "$" "
" mail_to_send + + # Insert starting HTML tags + sed --in-place '1s@^@\n\n\n\n@' mail_to_send + + # Keep tabulations + ynh_replace_string " " "\ \ " mail_to_send + ynh_replace_string "\t" "\ \ " mail_to_send + + # Insert url links tags + ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "\1" mail_to_send + + # Insert finishing HTML tags + echo -e "\n\n" >> mail_to_send + + # Otherwise, remove tags to keep a plain text. + else + # Remove URL tags + ynh_replace_string "__URL_TAG[1,3]__" "" mail_to_send + ynh_replace_string "__URL_TAG2__" ": " mail_to_send + fi + + # Define binary to use for mail command + if [ -e /usr/bin/bsd-mailx ] + then + local mail_bin=/usr/bin/bsd-mailx + else + local mail_bin=/usr/bin/mail.mailutils + fi + + if [ "$admin_mail_html" -eq 1 ] + then + content_type="text/html" + else + content_type="text/plain" + fi + + # Send the email to the recipients + cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients" +} \ No newline at end of file From 21fa63215f32bfbbc303afaf4b6a92b1667131d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 25 Apr 2023 09:53:11 +0200 Subject: [PATCH 02/13] Update install --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index d190353..b5f30fc 100644 --- a/scripts/install +++ b/scripts/install @@ -70,7 +70,7 @@ ynh_app_setting_set --app=$app --key=port --value=$port ynh_script_progression --message="Installing dependencies..." ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies -ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian/ $(lsb_release --codename --short) main contrib" --package=$contrib_dependencies --key="https://ftp-master.debian.org/keys/release-$(lsb_release --release --short).asc" +ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian/ $(lsb_release --codename --short) main contrib" --package="ttf-mscorefonts-installer" --key="https://ftp-master.debian.org/keys/release-$(lsb_release --release --short).asc" #================================================= # CREATE DEDICATED USER @@ -131,7 +131,7 @@ ynh_script_progression --message="Install OnlyOffice..." # restart nginx and the whole webadmin and maybe even the yunohost command # running the install ... -ynh_install_extra_app_dependencies --repo="https://download.onlyoffice.com/repo/debian squeeze main" --package=$extra_dependencies --key="https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE" +ynh_install_extra_app_dependencies --repo="https://download.onlyoffice.com/repo/debian squeeze main" --package="onlyoffice-documentserver" --key="https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE" #================================================= # ADD A CONFIGURATION From 4ad38088036b24a1e22e4969b08e547dd9ef37a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 25 Apr 2023 09:56:30 +0200 Subject: [PATCH 03/13] Update install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index b5f30fc..21702d8 100644 --- a/scripts/install +++ b/scripts/install @@ -103,7 +103,7 @@ else fi # Create a dedicated NGINX config -ynh_add_nginx_config "nextclouddomain" +ynh_add_nginx_config #================================================= # SPECIFIC SETUP From 42e87557f633e7cbbfde00fcf38fe421efdb9c94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 25 Apr 2023 09:57:34 +0200 Subject: [PATCH 04/13] Update install --- scripts/install | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 21702d8..c50a4cc 100644 --- a/scripts/install +++ b/scripts/install @@ -126,10 +126,10 @@ ynh_script_progression --message="Install OnlyOffice..." # keyserver.ubuntu.com response an error 500 regularly #apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 2>/dev/null -# The onlyoffice dev had the magnificent idea to add a "nginx restart" during +# The OnlyOffice dev had the magnificent idea to add a "nginx restart" during # the install/configure of their package, which is awful since that will -# restart nginx and the whole webadmin and maybe even the yunohost command -# running the install ... +# restart NGINX and the whole webadmin and maybe even the YunoHost command +# running the install... ynh_install_extra_app_dependencies --repo="https://download.onlyoffice.com/repo/debian squeeze main" --package="onlyoffice-documentserver" --key="https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE" From d97cf3315ae0e909c2df1c637dcbf905f8f5e123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:04:05 +0200 Subject: [PATCH 05/13] Update _common.sh --- scripts/_common.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index afbf1a8..58ae541 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,8 +6,6 @@ # dependencies used by the app pkg_dependencies="postgresql postgresql-contrib libstdc++6 rabbitmq-server libcurl4-dev" -contrib_dependencies="ttf-mscorefonts-installer" -extra_dependencies="onlyoffice-documentserver" #================================================= # PERSONAL HELPERS From 594909699b3cdad221eb0a949c4b624b363f1190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:05:17 +0200 Subject: [PATCH 06/13] Update install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index c50a4cc..15624bc 100644 --- a/scripts/install +++ b/scripts/install @@ -166,7 +166,7 @@ chown -R ds:ds "$final_path" #================================================= ynh_script_progression --message="Generating fonts..." -/usr/bin/documentserver-generate-allfonts.sh +/usr/bin/documentserver-generate-allfonts.sh 2>/dev/null #================================================= # SETUP SSOWAT From d9b584fbc3de191901ac61d818fd179fe0e8e1c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:23:54 +0200 Subject: [PATCH 07/13] Update nginx.conf --- conf/nginx.conf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index ce045d4..61686dd 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,6 @@ -location ^~ __PATH__/ { +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { + proxy_pass http://127.0.0.1:__PORT__/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; @@ -10,6 +12,7 @@ location ^~ __PATH__/ { proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; + more_set_headers "X-Frame-Options : ALLOW-FROM https://__NEXTCLOUDDOMAIN__ always"; client_max_body_size 10M; } From 74d9b9d3a3cf1e7b627c34ff32353eb1866d04e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 25 Apr 2023 10:29:45 +0200 Subject: [PATCH 08/13] fix --- scripts/install | 14 -------------- scripts/restore | 18 ++---------------- scripts/upgrade | 4 ++-- 3 files changed, 4 insertions(+), 32 deletions(-) diff --git a/scripts/install b/scripts/install index 15624bc..4783951 100644 --- a/scripts/install +++ b/scripts/install @@ -123,9 +123,6 @@ echo onlyoffice-documentserver onlyoffice/db-name string $db_name | debconf-set- #================================================= ynh_script_progression --message="Install OnlyOffice..." -# keyserver.ubuntu.com response an error 500 regularly -#apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 2>/dev/null - # The OnlyOffice dev had the magnificent idea to add a "nginx restart" during # the install/configure of their package, which is awful since that will # restart NGINX and the whole webadmin and maybe even the YunoHost command @@ -150,17 +147,6 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R ds:ds "$final_path" -#================================================= -# GENERIC FINALIZATION -#================================================= -# START SYSTEMD SERVICE -#================================================= -# ynh_script_progression --message="Starting a systemd service..." - -# supervisorctl reload - -# sleep 30 - #================================================= # REGENERATE FONTS #================================================= diff --git a/scripts/restore b/scripts/restore index f4ad5e3..dbad15d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -60,7 +60,7 @@ ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies -ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian/ buster main contrib" --package=$contrib_dependencies --key="https://ftp-master.debian.org/keys/release-$(lsb_release --release --short).asc" +ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian/ buster main contrib" --package="ttf-mscorefonts-installer" --key="https://ftp-master.debian.org/keys/release-$(lsb_release --release --short).asc" #================================================= # RESTORE THE NGINX CONFIGURATION @@ -94,10 +94,7 @@ echo onlyoffice-documentserver onlyoffice/db-name string $db_name | debconf-set- #================================================= ynh_script_progression --message="Reinstalling OnlyOffice..." -# apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 - -# ynh_install_extra_app_dependencies --repo="https://download.onlyoffice.com/repo/debian squeeze main" --package=$extra_dependencies --key="https://ftp-master.debian.org/keys/release-$(lsb_release --release --short).asc" -ynh_install_extra_app_dependencies --repo="https://download.onlyoffice.com/repo/debian squeeze main" --package=$extra_dependencies --key="https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE" +ynh_install_extra_app_dependencies --repo="https://download.onlyoffice.com/repo/debian squeeze main" --package="onlyoffice-documentserver" --key="https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE" #================================================= # RESTORE THE CONFIGURATION @@ -127,17 +124,6 @@ chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R ds:ds "$final_path" -#================================================= -# GENERIC FINALIZATION -#================================================= -# START SYSTEMD SERVICE -#================================================= -# ynh_script_progression --message="Starting a systemd service..." - -# supervisorctl reload - -# sleep 30 - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 8f93d8b..2aca68e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -95,7 +95,7 @@ ynh_system_user_create --username=$app --home_dir="$final_path" ynh_script_progression --message="Upgrading dependencies..." ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies -ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian/ $(lsb_release --codename --short) main contrib" --package=$contrib_dependencies --key="https://ftp-master.debian.org/keys/release-$(lsb_release --release --short).asc" +ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian/ $(lsb_release --codename --short) main contrib" --package="ttf-mscorefonts-installer" --key="https://ftp-master.debian.org/keys/release-$(lsb_release --release --short).asc" #================================================= # NGINX CONFIGURATION @@ -136,7 +136,7 @@ ynh_remove_extra_repo --name="$app" # backward compat # apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 # ynh_remove_app_dependencies -ynh_install_extra_app_dependencies --repo="https://download.onlyoffice.com/repo/debian squeeze main" --package=$extra_dependencies --key="https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE" +ynh_install_extra_app_dependencies --repo="https://download.onlyoffice.com/repo/debian squeeze main" --package="onlyoffice-documentserver" --key="https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE" #================================================= From baa7c18b5ccc31947f91ab0a076a1e5a22dec5dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 25 Apr 2023 11:34:30 +0200 Subject: [PATCH 09/13] Update install --- scripts/install | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install b/scripts/install index 4783951..43b67a1 100644 --- a/scripts/install +++ b/scripts/install @@ -118,6 +118,8 @@ echo onlyoffice-documentserver onlyoffice/db-user string $db_user | debconf-set- echo onlyoffice-documentserver onlyoffice/db-pwd password $db_pwd | debconf-set-selections echo onlyoffice-documentserver onlyoffice/db-name string $db_name | debconf-set-selections +echo onlyoffice-documentserver onlyoffice/jwt-enabled boolean false | debconf-set-selections + #================================================= # INSTALL ONLYOFFICE #================================================= From bddfd89bf83d2337c5a8fc2f83204066d03cb691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 25 Apr 2023 11:34:58 +0200 Subject: [PATCH 10/13] Update install --- scripts/install | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install b/scripts/install index 43b67a1..3685f6b 100644 --- a/scripts/install +++ b/scripts/install @@ -132,6 +132,8 @@ ynh_script_progression --message="Install OnlyOffice..." ynh_install_extra_app_dependencies --repo="https://download.onlyoffice.com/repo/debian squeeze main" --package="onlyoffice-documentserver" --key="https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE" +ynh_systemd_action --service_name=ds-* --action=reload + #================================================= # ADD A CONFIGURATION #================================================= From 2abed2d96e300adc4ba27fd018141219b0c9bf8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 25 Apr 2023 11:39:20 +0200 Subject: [PATCH 11/13] Update install --- scripts/install | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/install b/scripts/install index 3685f6b..43b67a1 100644 --- a/scripts/install +++ b/scripts/install @@ -132,8 +132,6 @@ ynh_script_progression --message="Install OnlyOffice..." ynh_install_extra_app_dependencies --repo="https://download.onlyoffice.com/repo/debian squeeze main" --package="onlyoffice-documentserver" --key="https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE" -ynh_systemd_action --service_name=ds-* --action=reload - #================================================= # ADD A CONFIGURATION #================================================= From 03850c037452d137a85d4249cf3718e61fc211bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 25 Apr 2023 11:40:46 +0200 Subject: [PATCH 12/13] Update install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 43b67a1..61a3bfe 100644 --- a/scripts/install +++ b/scripts/install @@ -130,7 +130,7 @@ ynh_script_progression --message="Install OnlyOffice..." # restart NGINX and the whole webadmin and maybe even the YunoHost command # running the install... -ynh_install_extra_app_dependencies --repo="https://download.onlyoffice.com/repo/debian squeeze main" --package="onlyoffice-documentserver" --key="https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE" +ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="https://download.onlyoffice.com/repo/debian squeeze main" --package="onlyoffice-documentserver" --key="https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE" #================================================= # ADD A CONFIGURATION From cd8fe67307e888c7d5c3234ca66905b2c1bdffd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 25 Apr 2023 11:59:11 +0200 Subject: [PATCH 13/13] cleaning --- conf/msg_install | 9 +- scripts/_common.sh | 126 +++++++++++++++++++++++++++ scripts/install | 3 +- scripts/ynh_send_readme_to_admin__2 | 127 ---------------------------- 4 files changed, 132 insertions(+), 133 deletions(-) delete mode 100644 scripts/ynh_send_readme_to_admin__2 diff --git a/conf/msg_install b/conf/msg_install index ed257a7..917dc24 100644 --- a/conf/msg_install +++ b/conf/msg_install @@ -2,10 +2,11 @@ __APP__ was successfully installed :) Please open your __APP__ domain: https://__DOMAIN____PATH_URL__ -To configure your OnlyOffice with your Nextcloud, go to the settings : - - under "Administration > ONLYOFFICE > Server settings > Address of the Document Server" enter "https://__DOMAIN____PATH_URL__" - - under "Administration > ONLYOFFICE > Server settings > Secret key" enter "__JWT_TOKEN__" +To configure OnlyOffice with your Nextcloud, go to the settings: +under "Administration > ONLYOFFICE > Server settings > +- Address of the Document Server" enter: "https://__DOMAIN____PATH_URL__" +- Secret key" enter "__JWT_TOKEN__" -Your OnlyOffice should now work with your Nextcloud! +OnlyOffice should now work with your Nextcloud! If you are facing any problem or want to improve this app, please open a new issue here: https://github.com/YunoHost-Apps/onlyoffice_ynh \ No newline at end of file diff --git a/scripts/_common.sh b/scripts/_common.sh index 58ae541..623b0e0 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -18,3 +18,129 @@ pkg_dependencies="postgresql postgresql-contrib libstdc++6 rabbitmq-server libcu #================================================= # FUTURE OFFICIAL HELPERS #================================================= + +# Send an email to inform the administrator +# +# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type] +# | arg: -m --app_message= - The file with the content to send to the administrator. +# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root +# example: "root admin@domain" +# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you +# example: "root admin@domain user1 user2" +# | arg: -t, --type= - Type of mail, could be 'backup', 'change_url', 'install', 'remove', 'restore', 'upgrade' +# +# Requires YunoHost version 4.1.0 or higher. +ynh_send_readme_to_admin() { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [m]=app_message= [r]=recipients= [t]=type= ) + local app_message + local recipients + local type + # Manage arguments with getopts + + ynh_handle_getopts_args "$@" + app_message="${app_message:-}" + recipients="${recipients:-root}" + type="${type:-install}" + + # Get the value of admin_mail_html + admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) + admin_mail_html="${admin_mail_html:-0}" + + # Retrieve the email of users + find_mails () { + local list_mails="$1" + local mail + local recipients=" " + # Read each mail in argument + for mail in $list_mails + do + # Keep root or a real email address as it is + if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@" + then + recipients="$recipients $mail" + else + # But replace an user name without a domain after by its email + if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null) + then + recipients="$recipients $mail" + fi + fi + done + echo "$recipients" + } + recipients=$(find_mails "$recipients") + + # Subject base + local mail_subject="β˜οΈπŸ†ˆπŸ…½πŸ…·β˜οΈ: \`$app\`" + + # Adapt the subject according to the type of mail required. + if [ "$type" = "backup" ]; then + mail_subject="$mail_subject has just been backup." + elif [ "$type" = "change_url" ]; then + mail_subject="$mail_subject has just been moved to a new URL!" + elif [ "$type" = "remove" ]; then + mail_subject="$mail_subject has just been removed!" + elif [ "$type" = "restore" ]; then + mail_subject="$mail_subject has just been restored!" + elif [ "$type" = "upgrade" ]; then + mail_subject="$mail_subject has just been upgraded!" + else # install + mail_subject="$mail_subject has just been installed!" + fi + + ynh_add_config --template="$app_message" --destination="../conf/msg__to_send" + + ynh_delete_file_checksum --file="../conf/msg__to_send" + + local mail_message="This is an automated message from your beloved YunoHost server. +Specific information for the application $app. +$(cat "../conf/msg__to_send")" + + # Store the message into a file for further modifications. + echo "$mail_message" > mail_to_send + + # If a html email is required. Apply html tags to the message. + if [ "$admin_mail_html" -eq 1 ] + then + # Insert 'br' tags at each ending of lines. + ynh_replace_string "$" "
" mail_to_send + + # Insert starting HTML tags + sed --in-place '1s@^@\n\n\n\n@' mail_to_send + + # Keep tabulations + ynh_replace_string " " "\ \ " mail_to_send + ynh_replace_string "\t" "\ \ " mail_to_send + + # Insert url links tags + ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "\1" mail_to_send + + # Insert finishing HTML tags + echo -e "\n\n" >> mail_to_send + + # Otherwise, remove tags to keep a plain text. + else + # Remove URL tags + ynh_replace_string "__URL_TAG[1,3]__" "" mail_to_send + ynh_replace_string "__URL_TAG2__" ": " mail_to_send + fi + + # Define binary to use for mail command + if [ -e /usr/bin/bsd-mailx ] + then + local mail_bin=/usr/bin/bsd-mailx + else + local mail_bin=/usr/bin/mail.mailutils + fi + + if [ "$admin_mail_html" -eq 1 ] + then + content_type="text/html" + else + content_type="text/plain" + fi + + # Send the email to the recipients + cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients" +} \ No newline at end of file diff --git a/scripts/install b/scripts/install index b71beed..a5668d9 100644 --- a/scripts/install +++ b/scripts/install @@ -8,7 +8,6 @@ source _common.sh source /usr/share/yunohost/helpers -source ynh_send_readme_to_admin__2 #================================================= # MANAGE SCRIPT FAILURE @@ -121,7 +120,7 @@ echo onlyoffice-documentserver onlyoffice/db-user string $db_user | debconf-set- echo onlyoffice-documentserver onlyoffice/db-pwd password $db_pwd | debconf-set-selections echo onlyoffice-documentserver onlyoffice/db-name string $db_name | debconf-set-selections -echo onlyoffice-documentserver onlyoffice/jwt-enabled boolean false | debconf-set-selections +#echo onlyoffice-documentserver onlyoffice/jwt-enabled boolean false | debconf-set-selections #================================================= # INSTALL ONLYOFFICE diff --git a/scripts/ynh_send_readme_to_admin__2 b/scripts/ynh_send_readme_to_admin__2 deleted file mode 100644 index 0d4403d..0000000 --- a/scripts/ynh_send_readme_to_admin__2 +++ /dev/null @@ -1,127 +0,0 @@ -#!/bin/bash - -# Send an email to inform the administrator -# -# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type] -# | arg: -m --app_message= - The file with the content to send to the administrator. -# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root -# example: "root admin@domain" -# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you -# example: "root admin@domain user1 user2" -# | arg: -t, --type= - Type of mail, could be 'backup', 'change_url', 'install', 'remove', 'restore', 'upgrade' -# -# Requires YunoHost version 4.1.0 or higher. -ynh_send_readme_to_admin() { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [m]=app_message= [r]=recipients= [t]=type= ) - local app_message - local recipients - local type - # Manage arguments with getopts - - ynh_handle_getopts_args "$@" - app_message="${app_message:-}" - recipients="${recipients:-root}" - type="${type:-install}" - - # Get the value of admin_mail_html - admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) - admin_mail_html="${admin_mail_html:-0}" - - # Retrieve the email of users - find_mails () { - local list_mails="$1" - local mail - local recipients=" " - # Read each mail in argument - for mail in $list_mails - do - # Keep root or a real email address as it is - if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@" - then - recipients="$recipients $mail" - else - # But replace an user name without a domain after by its email - if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null) - then - recipients="$recipients $mail" - fi - fi - done - echo "$recipients" - } - recipients=$(find_mails "$recipients") - - # Subject base - local mail_subject="β˜οΈπŸ†ˆπŸ…½πŸ…·β˜οΈ: \`$app\`" - - # Adapt the subject according to the type of mail required. - if [ "$type" = "backup" ]; then - mail_subject="$mail_subject has just been backup." - elif [ "$type" = "change_url" ]; then - mail_subject="$mail_subject has just been moved to a new URL!" - elif [ "$type" = "remove" ]; then - mail_subject="$mail_subject has just been removed!" - elif [ "$type" = "restore" ]; then - mail_subject="$mail_subject has just been restored!" - elif [ "$type" = "upgrade" ]; then - mail_subject="$mail_subject has just been upgraded!" - else # install - mail_subject="$mail_subject has just been installed!" - fi - - ynh_add_config --template="$app_message" --destination="../conf/msg__to_send" - - ynh_delete_file_checksum --file="../conf/msg__to_send" - - local mail_message="This is an automated message from your beloved YunoHost server. -Specific information for the application $app. -$(cat "../conf/msg__to_send")" - - # Store the message into a file for further modifications. - echo "$mail_message" > mail_to_send - - # If a html email is required. Apply html tags to the message. - if [ "$admin_mail_html" -eq 1 ] - then - # Insert 'br' tags at each ending of lines. - ynh_replace_string "$" "
" mail_to_send - - # Insert starting HTML tags - sed --in-place '1s@^@\n\n\n\n@' mail_to_send - - # Keep tabulations - ynh_replace_string " " "\ \ " mail_to_send - ynh_replace_string "\t" "\ \ " mail_to_send - - # Insert url links tags - ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "\1" mail_to_send - - # Insert finishing HTML tags - echo -e "\n\n" >> mail_to_send - - # Otherwise, remove tags to keep a plain text. - else - # Remove URL tags - ynh_replace_string "__URL_TAG[1,3]__" "" mail_to_send - ynh_replace_string "__URL_TAG2__" ": " mail_to_send - fi - - # Define binary to use for mail command - if [ -e /usr/bin/bsd-mailx ] - then - local mail_bin=/usr/bin/bsd-mailx - else - local mail_bin=/usr/bin/mail.mailutils - fi - - if [ "$admin_mail_html" -eq 1 ] - then - content_type="text/html" - else - content_type="text/plain" - fi - - # Send the email to the recipients - cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients" -} \ No newline at end of file