From 36f5e3e94c5ba80df0dc4fde5f201ee9b0617cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 19 Mar 2024 14:57:06 +0100 Subject: [PATCH] move code to _common.sh --- manifest.toml | 9 +++++---- scripts/_common.sh | 28 ++++++++++++++++++++++++++++ scripts/install | 19 ++----------------- scripts/restore | 19 ++----------------- scripts/upgrade | 23 ++++------------------- 5 files changed, 41 insertions(+), 57 deletions(-) diff --git a/manifest.toml b/manifest.toml index b4eba7d..1de95e4 100644 --- a/manifest.toml +++ b/manifest.toml @@ -74,10 +74,11 @@ ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requiremen "libcurl4-openssl-dev", ] - [resources.apt.extras.ttf] - repo = "deb http://deb.debian.org/debian/ bullseye main contrib" - key = "https://ftp-master.debian.org/keys/release-bullseye.asc" - packages = ["ttf-mscorefonts-installer"] + # Manual install in scripts + # [resources.apt.extras.ttf] + # repo = "deb http://deb.debian.org/debian/ bullseye main contrib" + # key = "https://ftp-master.debian.org/keys/release-bullseye.asc" + # packages = ["ttf-mscorefonts-installer"] # Manual install in scripts # [resources.apt.extras.onlyoffice] diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..658bd36 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,6 +8,34 @@ # PERSONAL HELPERS #================================================= +_install_msfonts_deb() { + # Run this here because it's less verbose for some reason + ynh_exec_warn_less ynh_install_extra_app_dependencies \ + --repo="deb http://deb.debian.org/debian/ $(lsb_release --codename --short) main contrib" \ + --key="https://ftp-master.debian.org/keys/release-$(lsb_release --release --short).asc" \ + --package="ttf-mscorefonts-installer" +} + +_install_onlyoffice_deb() { + echo onlyoffice-documentserver onlyoffice/ds-port select "$port" | debconf-set-selections + echo onlyoffice-documentserver onlyoffice/db-host string 127.0.0.1 | debconf-set-selections + echo onlyoffice-documentserver onlyoffice/db-user string "$db_user" | debconf-set-selections + 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-secret password "$jwt_secret" | debconf-set-selections + + # 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... + + # Can't do that in the manifest because we need the debconf-set-selections and postgresql already configured + ynh_exec_warn_less ynh_install_extra_app_dependencies \ + --repo="https://download.onlyoffice.com/repo/debian squeeze main" \ + --key="https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE" \ + --package="onlyoffice-documentserver" +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 0e30299..fca5967 100644 --- a/scripts/install +++ b/scripts/install @@ -21,23 +21,8 @@ ynh_app_setting_set --app="$app" --key=jwt_secret --value="$jwt_secret" #================================================= ynh_script_progression --message="Install OnlyOffice..." -echo onlyoffice-documentserver onlyoffice/ds-port select "$port" | debconf-set-selections -echo onlyoffice-documentserver onlyoffice/db-host string 127.0.0.1 | debconf-set-selections -echo onlyoffice-documentserver onlyoffice/db-user string "$db_user" | debconf-set-selections -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-secret password "$jwt_secret" | debconf-set-selections - -# 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... - -# Can't do that in the manifest because we need the debconf-set-selections and postgresql already configured -ynh_exec_warn_less ynh_install_extra_app_dependencies \ - --repo="https://download.onlyoffice.com/repo/debian squeeze main" \ - --key="https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE" \ - --package="onlyoffice-documentserver" +_install_msfonts_deb +_install_onlyoffice_deb #================================================= # ADD A CONFIGURATION diff --git a/scripts/restore b/scripts/restore index 14cd2c1..89df2da 100644 --- a/scripts/restore +++ b/scripts/restore @@ -20,23 +20,8 @@ ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" #================================================= ynh_script_progression --message="Install OnlyOffice..." -echo onlyoffice-documentserver onlyoffice/ds-port select "$port" | debconf-set-selections -echo onlyoffice-documentserver onlyoffice/db-host string 127.0.0.1 | debconf-set-selections -echo onlyoffice-documentserver onlyoffice/db-user string "$db_user" | debconf-set-selections -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-secret password "$jwt_secret" | debconf-set-selections - -# 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... - -# Can't do that in the manifest because we need the debconf-set-selections and postgresql already configured -ynh_exec_warn_less ynh_install_extra_app_dependencies \ - --repo="https://download.onlyoffice.com/repo/debian squeeze main" \ - --key="https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE" \ - --package="onlyoffice-documentserver" +_install_msfonts_deb +_install_onlyoffice_deb #================================================= # RESTORE THE CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 5d19c47..f8cd7d5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,24 +21,9 @@ ynh_secure_remove --file="/etc/apt/sources.list.d/nodesource.list" ynh_script_progression --message="Upgrading OnlyOffice..." ynh_backup_if_checksum_is_different --file="/etc/onlyoffice/documentserver/default.json" -echo onlyoffice-documentserver onlyoffice/ds-port select $port | debconf-set-selections -echo onlyoffice-documentserver onlyoffice/db-host string 127.0.0.1 | debconf-set-selections -echo onlyoffice-documentserver onlyoffice/db-user string $db_user | debconf-set-selections -echo onlyoffice-documentserver onlyoffice/db-pwd password $db_pwd | debconf-set-selections -echo onlyoffice-documentserver onlyoffice/db-name string $db_name | debconf-set-selections -# JWT options -# echo onlyoffice-documentserver onlyoffice/jwt-secret password $jwt_secret | debconf-set-selections -# 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... - -# Can't do that in the manifest because we need the debconf-set-selections and postgresql already configured -ynh_exec_warn_less ynh_install_extra_app_dependencies \ - --repo="https://download.onlyoffice.com/repo/debian squeeze main" \ - --key="https://download.onlyoffice.com/GPG-KEY-ONLYOFFICE" \ - --package="onlyoffice-documentserver" +_install_msfonts_deb +_install_onlyoffice_deb #================================================= # UPDATE A CONFIG FILE @@ -48,8 +33,8 @@ ynh_script_progression --message="Updating a configuration file..." ynh_backup_if_checksum_is_different --file="/etc/onlyoffice/documentserver/default.json" ynh_replace_string --target_file="/etc/onlyoffice/documentserver/default.json" \ - --match_string="\"rejectUnauthorized\": true" \ - --replace_string="\"rejectUnauthorized\": false" + --match_string="\"rejectUnauthorized\": true" \ + --replace_string="\"rejectUnauthorized\": false" # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="/etc/onlyoffice/documentserver/default.json"