From 8351c819c17237a63ac709880cb534993dd3146d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 4 Aug 2019 23:00:10 +0200 Subject: [PATCH 01/13] Apply example_ynh --- README.md | 7 ++- check_process | 28 +++------ manifest.json | 8 +-- scripts/_common.sh | 120 +++++---------------------------------- scripts/backup | 71 ++++++++++++++--------- scripts/install | 113 ++++++++++++++++--------------------- scripts/remove | 31 +++++----- scripts/restore | 129 +++++++++++++++++++++++++++++------------- scripts/upgrade | 137 ++++++++++++++++++++++++++++++++++----------- 9 files changed, 330 insertions(+), 314 deletions(-) diff --git a/README.md b/README.md index abdd6b9..a2484f2 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Integration level](https://dash.yunohost.org/integration/collabora.svg)](https://dash.yunohost.org/appci/app/collabora) [![Install Collabora with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=collabora) -> *This package allow you to install Collabora Online quickly and simply on a YunoHost server. +> *This package allow you to install Collabora quickly and simply on a YunoHost server. If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* ## Overview @@ -28,8 +28,9 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/collabora%20%28Official%29.svg)](https://ci-apps.yunohost.org/ci/apps/collabora/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/collabora%20%28Official%29.svg)](https://ci-stretch.nohost.me/ci/apps/collabora/) +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/collabora%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/collabora/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/collabora%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/collabora/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/collabora%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/collabora/) ## Limitations diff --git a/check_process b/check_process index 3e678c7..c9672a4 100644 --- a/check_process +++ b/check_process @@ -6,37 +6,25 @@ ;; Test complet ; Manifest domain="domain.tld" (DOMAIN) - path="/" (PATH) - is_public=1 (PUBLIC|public=1|private=0) password="pass" - nextclouddomain="domain.tld" - port="9980" (PORT) + nextclouddomain="nextcloud.tld" ; Checks pkg_linter=1 setup_sub_dir=0 - setup_root=0 - setup_nourl=1 + setup_root=1 + setup_nourl=0 setup_private=0 - setup_public=0 + setup_public=1 upgrade=1 backup_restore=1 multi_instance=0 - incorrect_path=0 - port_already_use=1 + # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. + # incorrect_path=1 + port_already_use=0 change_url=0 ;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto -# Level 4: - Level 4=1 (This app supports the Nextcloud LDAP auth) -# Level 5: + # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 ;;; Options Email= Notification=none diff --git a/manifest.json b/manifest.json index f4069ab..0964e74 100644 --- a/manifest.json +++ b/manifest.json @@ -14,13 +14,11 @@ "url": "https://collaboraoffice.com" }, "requirements": { - "yunohost": ">= 2.7.2" + "yunohost": ">= 3.5" }, "multi_instance": false, "services": [ - "nginx", - "php5-fpm", - "mysql" + "nginx" ], "arguments": { "install" : [ @@ -46,7 +44,7 @@ }, { - "name": "nextclouddomain", + "name": "nextcloud_domain", "type": "string", "ask": { "en": "The domain of your Nextcloud instance", diff --git a/scripts/_common.sh b/scripts/_common.sh index 0f53f77..0ab2c58 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,112 +1,20 @@ #!/bin/bash -# ============================================================================= -# YUNOHOST 2.7 FORTHCOMING HELPERS -# ============================================================================= +#================================================= +# COMMON VARIABLES +#================================================= -# Create a dedicated nginx config -# -# usage: ynh_add_nginx_config -ynh_add_nginx_config () { - finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf" - ynh_backup_if_checksum_is_different "$finalnginxconf" - sudo cp ../conf/nginx.conf "$finalnginxconf" +# dependencies used by the app +pkg_dependencies="loolwsd code-brand" - # To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable. - # Substitute in a nginx config file only if the variable is not empty - if test -n "${path_url:-}"; then - ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf" - fi - if test -n "${domain:-}"; then - ynh_replace_string "__DOMAIN__" "$domain" "$finalnginxconf" - fi - if test -n "${port:-}"; then - ynh_replace_string "__PORT__" "$port" "$finalnginxconf" - fi - if test -n "${app:-}"; then - ynh_replace_string "__NAME__" "$app" "$finalnginxconf" - fi - if test -n "${final_path:-}"; then - ynh_replace_string "__FINALPATH__" "$final_path" "$finalnginxconf" - fi - ynh_store_file_checksum "$finalnginxconf" +#================================================= +# PERSONAL HELPERS +#================================================= - sudo systemctl reload nginx -} +#================================================= +# EXPERIMENTAL HELPERS +#================================================= -# Remove the dedicated nginx config -# -# usage: ynh_remove_nginx_config -ynh_remove_nginx_config () { - ynh_secure_remove "/etc/nginx/conf.d/$domain.d/$app.conf" - sudo systemctl reload nginx -} - -# Create a dedicated php-fpm config -# -# usage: ynh_add_fpm_config -ynh_add_fpm_config () { - finalphpconf="/etc/php5/fpm/pool.d/$app.conf" - ynh_backup_if_checksum_is_different "$finalphpconf" - sudo cp ../conf/php-fpm.conf "$finalphpconf" - ynh_replace_string "__NAMETOCHANGE__" "$app" "$finalphpconf" - ynh_replace_string "__FINALPATH__" "$final_path" "$finalphpconf" - ynh_replace_string "__USER__" "$app" "$finalphpconf" - sudo chown root: "$finalphpconf" - ynh_store_file_checksum "$finalphpconf" - - if [ -e "../conf/php-fpm.ini" ] - then - finalphpini="/etc/php5/fpm/conf.d/20-$app.ini" - ynh_backup_if_checksum_is_different "$finalphpini" - sudo cp ../conf/php-fpm.ini "$finalphpini" - sudo chown root: "$finalphpini" - ynh_store_file_checksum "$finalphpini" - fi - - sudo systemctl reload php5-fpm -} - -# Remove the dedicated php-fpm config -# -# usage: ynh_remove_fpm_config -ynh_remove_fpm_config () { - ynh_secure_remove "/etc/php5/fpm/pool.d/$app.conf" - ynh_secure_remove "/etc/php5/fpm/conf.d/20-$app.ini" 2>&1 - sudo systemctl reload php5-fpm -} - -# Create a dedicated systemd config -# -# usage: ynh_add_systemd_config -ynh_add_systemd_config () { - finalsystemdconf="/etc/systemd/system/$app.service" - ynh_backup_if_checksum_is_different "$finalsystemdconf" - sudo cp ../conf/systemd.service "$finalsystemdconf" - - # To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable. - # Substitute in a nginx config file only if the variable is not empty - if test -n "${final_path:-}"; then - ynh_replace_string "__FINALPATH__" "$final_path" "$finalsystemdconf" - fi - if test -n "${app:-}"; then - ynh_replace_string "__APP__" "$app" "$finalsystemdconf" - fi - ynh_store_file_checksum "$finalsystemdconf" - - sudo chown root: "$finalsystemdconf" - sudo systemctl enable $app - sudo systemctl daemon-reload -} - -# Remove the dedicated systemd config -# -# usage: ynh_remove_systemd_config -ynh_remove_systemd_config () { - finalsystemdconf="/etc/systemd/system/$app.service" - if [ -e "$finalsystemdconf" ]; then - sudo systemctl stop $app - sudo systemctl disable $app - ynh_secure_remove "$finalsystemdconf" - fi -} +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/backup b/scripts/backup index af8ccd9..faf1df7 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,33 +1,54 @@ #!/bin/bash -# Exit on command errors and treat unset variables as an error -set -eu +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# See comments in install script -app=$YNH_APP_INSTANCE_NAME - -# Source YunoHost helpers +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -# Backup sources & data -# Note: the last argument is where to save this path, see the restore script. -ynh_backup "/var/www/${app}" "sources" +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= -### MySQL (remove if not used) ### -# If a MySQL database is used: -# # Dump the database -# dbname=$app -# dbuser=$app -# dbpass=$(ynh_app_setting_get "$app" mysqlpwd) -# mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql -### MySQL end ### +ynh_clean_setup () { + ynh_clean_check_starting +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors -# Copy NGINX configuration -domain=$(ynh_app_setting_get "$app" domain) -ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info --message="Loading installation settings..." -### PHP (remove if not used) ### -# If a dedicated php-fpm process is used: -# # Copy PHP-FPM pool configuration -# ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf" -### PHP end ### +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get --app=$app --key=domain) + +#================================================= +# STANDARD BACKUP STEPS +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= +ynh_print_info --message="Backing up nginx web server configuration..." + +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# SPECIFIC BACKUP +#================================================= +# BACKUP CONFIGURATION +#================================================= +ynh_print_info --message="Backing up configuration..." + +ynh_backup --src_path="/etc/loolwsd/loolwsd.xml" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/install b/scripts/install index bf85ab4..20a3946 100644 --- a/scripts/install +++ b/scripts/install @@ -14,8 +14,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -24,62 +23,42 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -# Retrieve arguments domain=$YNH_APP_ARG_DOMAIN +path_url="/" password=$YNH_APP_ARG_PASSWORD -nextcloud_domain=$YNH_APP_ARG_NEXTCLOUDDOMAIN +nextcloud_domain=$YNH_APP_ARG_NEXTCLOUD_DOMAIN -### If it's a multi-instance app, meaning it can be installed several times independently -### The id of the app as stated in the manifest is available as $YNH_APP_ID -### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...) -### The app instance name is available as $YNH_APP_INSTANCE_NAME -### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample -### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2 -### - ynhexample__{N} for the subsequent installations, with N=3,4, ... -### The app instance name is probably what interests you most, since this is -### guaranteed to be unique. This is a good unique identifier to define installation path, -### db names, ... app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +ynh_print_info --message="Validating installation parameters..." -### If the app uses nginx as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". -### If the app provides an internal web server (or uses another application server such as uwsgi), the final path should be "/opt/yunohost/$app" -final_path=/opt/yunohost/$app -test ! -e "$final_path" || ynh_die "This path already contains a folder" - -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path /) - -# Check web path availability -ynh_webpath_available $domain / # Register (book) web path -ynh_webpath_register $app $domain / +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_print_info --message="Storing installation settings..." -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app password $password -ynh_app_setting_set $app nextcloud_domain $nextcloud_domain +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=password --value=$password +ynh_app_setting_set --app=$app --key=nextcloud_domain --value=$nextcloud_domain +#================================================= +# STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= - -### Use these lines if you have to open a port for the application -### `ynh_find_port` will find the first available port starting from the given port. -### If you're not using these lines: -### - Remove the section "CLOSE A PORT" in the remove script +ynh_print_info --message="Configuring firewall..." # Find a free port -port=$(ynh_find_port 9980) -# Open this port -yunohost firewall allow --no-upnp TCP $port 2>&1 -ynh_app_setting_set $app port $port +port=$(ynh_find_port --port=9980) + +ynh_app_setting_set --app=$app --key=port --value=$port #=============================================== # ADD COLLABORA REPOSITORY @@ -95,68 +74,70 @@ else echo 'deb https://collaboraoffice.com/repos/CollaboraOnline/CODE-debian9 ./' | sudo tee -a /etc/apt/sources.list.d/collabora.list fi -#============================================== -# INSTALL COLLABORA -#============================================== +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_print_info --message="Installing dependencies..." + ynh_package_update -ynh_install_app_dependencies loolwsd code-brand +ynh_install_app_dependencies $pkg_dependencies #================================================= # NGINX CONFIGURATION #================================================= +ynh_print_info --message="Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config #================================================= -# CREATE DEDICATED USER -#================================================= - -# Create a system user -ynh_system_user_create $app - +# SPECIFIC SETUP #================================================= # MODIFY A CONFIG FILE #================================================= -cp -a ../conf/loolwsd.xml /etc/loolwsd -ynh_replace_string "__NEXTCLOUDDOMAIN__" "$nextcloud_domain" "/etc/loolwsd/loolwsd.xml" -ynh_replace_string "__PASSWORD__" "$password" "/etc/loolwsd/loolwsd.xml" -systemctl start loolwsd +config="/etc/loolwsd/loolwsd.xml" + +cp -f ../conf/loolwsd.xml $config + +ynh_replace_string --match_string="__NEXTCLOUDDOMAIN__" --replace_string="$nextcloud_domain" --target_file="$config" +ynh_replace_string --match_string="__PASSWORD__" --replace_string="$password" --target_file="$config" #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= -### `ynh_store_file_checksum` is used to store the checksum of a file. -### That way, during the upgrade script, by using `ynh_backup_if_checksum_is_different`, -### you can make a backup of this file before modifying it again if the admin had modified it. - # Calculate and store the config file checksum into the app settings ynh_store_file_checksum "/etc/loolwsd/loolwsd.xml" - #================================================= # GENERIC FINALIZATION #================================================= -# SECURE FILES AND DIRECTORIES +# START SYSTEMD SERVICE #================================================= +ynh_print_info --message="Starting a systemd service..." -### For security reason, any app should set the permissions to root: before anything else. -### Then, if write authorization is needed, any access should be given only to directories -### that really need such authorization. - -# Set permissions to app files -chown -R root: /etc/loolwsd - +# Start a systemd service +ynh_systemd_action --service_name="loolwsd" --action="start" --log_path="systemd" --line_match="Started LibreOffice Online WebSocket Daemon" #================================================= # SETUP SSOWAT #================================================= +ynh_print_info --message="Configuring SSOwat..." +# Make app public # unprotected_uris allows SSO credentials to be passed anyway. ynh_app_setting_set $app unprotected_uris "/" -# Reload services -ynh_systemd_action -n loolwsd -a restart || true +#================================================= +# RELOAD NGINX +#================================================= +ynh_print_info --message="Reloading nginx web server..." +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info --message="Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index ae16a84..ba75d43 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,36 +12,31 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -port=$(ynh_app_setting_get $app port) -final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # STANDARD REMOVE #================================================= -#================================================= # REMOVE DEPENDENCIES #================================================= +ynh_print_info --message="Removing dependencies..." # Fix "rm: cannot remove '/etc/apt/apt.conf.d/25loolwsd': No such file or directory" # on apt remove touch /etc/apt/apt.conf.d/25loolwsd + # Remove metapackage and its dependencies ynh_remove_app_dependencies -#================================================= -# REMOVE APP MAIN DIR -#================================================= - -# Remove the app directory securely -ynh_secure_remove "$final_path" - #================================================= # REMOVE NGINX CONFIGURATION #================================================= +ynh_print_info --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config @@ -63,19 +58,21 @@ fi #================================================= # Remove a cron file -ynh_secure_remove "/etc/cron.d/$app" +ynh_secure_remove --file="/etc/cron.d/$app" # Remove a directory securely -ynh_secure_remove "/etc/apt/sources.list.d/collabora.list" +ynh_secure_remove --file="/etc/apt/sources.list.d/collabora.list" + +# Remove a directory securely +ynh_secure_remove --file="/etc/loolwsd/" # Remove the log files -ynh_secure_remove "/var/log/$app/" +ynh_secure_remove --file="/var/log/$app/" #================================================= # GENERIC FINALIZATION #================================================= -# REMOVE DEDICATED USER +# END OF SCRIPT #================================================= -# Delete a system user -ynh_system_user_delete $app +ynh_print_info --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 93169e9..09fce15 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,52 +1,101 @@ #!/bin/bash -# Note: each files and directories you've saved using the ynh_backup helper -# will be located in the current directory, regarding the last argument. +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= -# Exit on command errors and treat unset variables as an error -set -eu - -# See comments in install script -app=$YNH_APP_INSTANCE_NAME - -# Source YunoHost helpers +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -# Retrieve old app settings -domain=$(ynh_app_setting_get "$app" domain) -path_url=$(ynh_app_setting_get "$app" path_url) +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= -# Check domain/path availability -sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \ - || ynh_die "Path not available: ${domain}${path_url}" +ynh_clean_setup () { + ynh_clean_check_starting +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors -# Restore sources & data -src_path="/var/www/${app}" -sudo cp -a ./sources "$src_path" +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info --message="Loading settings..." -# Restore permissions to app files -# you may need to make some file and/or directory writeable by www-data (nginx user) -sudo chown -R root: "$src_path" +app=$YNH_APP_INSTANCE_NAME -### MySQL (remove if not used) ### -# If a MySQL database is used: -# # Create and restore the database -# dbname=$app -# dbuser=$app -# dbpass=$(ynh_app_setting_get "$app" mysqlpwd) -# ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" -# ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql -### MySQL end ### +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) -# Restore NGINX configuration -sudo cp -a ./nginx.conf "/etc/nginx/conf.d/${domain}.d/${app}.conf" +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= +ynh_print_info --message="Validating restoration parameters..." -### PHP (remove if not used) ### -# If a dedicated php-fpm process is used: -# # Copy PHP-FPM pool configuration and reload the service -# sudo cp -a ./php-fpm.conf "/etc/php5/fpm/pool.d/${app}.conf" -# sudo service php5-fpm reload -### PHP end ### +ynh_webpath_available --domain=$domain --path_url=$path_url \ + || ynh_die --message="Path not available: ${domain}${path_url}" -# Restart webserver -sudo service nginx reload +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# SPECIFIC RESTORATION +#=============================================== +# ADD COLLABORA REPOSITORY +#=============================================== + +ynh_install_app_dependencies apt-transport-https +apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0C54D189F4BA284D + +if [ "$(lsb_release --codename --short)" = "jessie" ]; then +echo 'deb https://collaboraoffice.com/repos/CollaboraOnline/CODE-debian8 ./' | sudo tee -a /etc/apt/sources.list.d/collabora.list +else + +echo 'deb https://collaboraoffice.com/repos/CollaboraOnline/CODE-debian9 ./' | sudo tee -a /etc/apt/sources.list.d/collabora.list +fi + +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_print_info --message="Reinstalling dependencies..." + +# Define and install dependencies +ynh_package_update +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# RESTORE CONFIGURATION +#================================================= +ynh_print_info --message="Restoring the configuration..." + +ynh_restore_file --origin_path="/etc/loolwsd/loolwsd.xml" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Starting a systemd service..." + +ynh_systemd_action --service_name="loolwsd" --action="restart" --log_path="systemd" --line_match="Started LibreOffice Online WebSocket Daemon" + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX +#================================================= +ynh_print_info --message="Reloading nginx web server..." + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 3d706e4..f531937 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,57 +1,130 @@ #!/bin/bash -# Exit on command errors and treat unset variables as an error -set -eu +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info --message="Loading installation settings..." -# See comments in install script app=$YNH_APP_INSTANCE_NAME -# Source YunoHost helpers -source /usr/share/yunohost/helpers -source _common.sh - -# Retrieve app settings -domain=$(ynh_app_setting_get "$app" domain) -password=$(ynh_app_setting_get "$app" password) -is_public=$(ynh_app_setting_get "$app" is_public) -nextclouddomain=$(ynh_app_setting_get "$app" nextclouddomain) - - -# Set permissions to app files -# you may need to make some file and/or directory writeable by www-data (nginx user) -sudo chown -R root: $src_path +domain=$(ynh_app_setting_get --app="$app" --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +password=$(ynh_app_setting_get --app="$app" --key=password) +nextclouddomain=$(ynh_app_setting_get --app="$app" --key=nextclouddomain) #================================================= -# UPGRADE COLLABORA +# ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_package_update -ynh_install_app_dependencies loolwsd code-brand +ynh_print_info --message="Ensuring downward compatibility..." + +# Fix is_public as a boolean value +if [ "$is_public" = "Yes" ]; then + ynh_app_setting_set --app=$app --key=is_public --value=1 + is_public=1 +elif [ "$is_public" = "No" ]; then + ynh_app_setting_set --app=$app --key=is_public --value=0 + is_public=0 +fi + +# If db_name doesn't exist, create it +if [ -z "$path_url" ]; then + path_url="/" + ynh_app_setting_set --app=$app --key=path_url --value=$path_url +fi + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_print_info --message="Backing up the app before upgrading (may take a while)..." + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_clean_check_starting + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# STANDARD UPGRADE STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Stopping a systemd service..." + +ynh_systemd_action --service_name="loolwsd" --action="stop" --log_path="systemd" --line_match="Stopped LibreOffice Online WebSocket Daemon." #================================================= # NGINX CONFIGURATION #================================================= +ynh_print_info --message="Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_print_info --message="Upgrading dependencies..." +ynh_package_update +ynh_install_app_dependencies loolwsd code-brand +#================================================= +# SPECIFIC UPGRADE #================================================= # UPGRADE CONFIG #================================================= -cp -a ../conf/loolwsd.xml /etc/loolwsd -ynh_replace_string "__NEXTCLOUDDOMAIN__" "$nextcloud_domain" "/etc/loolwsd/loolwsd.xml" -ynh_replace_string "__PASSWORD__" "$password" "/etc/loolwsd/loolwsd.xml" -systemctl restart loolwsd +config="/etc/loolwsd/loolwsd.xml" +ynh_backup_if_checksum_is_different --file="$config" -# If app is public, add url to SSOWat conf as skipped_uris -if [[ $is_public -eq 1 ]]; then - # See install script - ynh_app_setting_set "$app" unprotected_uris "/" -fi +cp -a ../conf/loolwsd.xml $config -# Reload nginx service -systemctl restart nginx -systemctl restart loolwsd +ynh_replace_string "__NEXTCLOUDDOMAIN__" "$nextcloud_domain" "$config" +ynh_replace_string "__PASSWORD__" "$password" "$config" +# Recalculate and store the checksum of the file for the next upgrade. +ynh_store_file_checksum --file="$config" + +#================================================= +# GENERIC FINALIZATION +#================================================= +# SETUP SSOWAT +#================================================= +ynh_print_info --message="Upgrading SSOwat configuration..." + +# Make app public +# unprotected_uris allows SSO credentials to be passed anyway +ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Starting a systemd service..." + +ynh_systemd_action --service_name="loolwsd" --action="start" --log_path="systemd" --line_match="Started LibreOffice Online WebSocket Daemon" + +#================================================= +# RELOAD NGINX +#================================================= +ynh_print_info --message="Reloading nginx web server..." + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info --message="Upgrade of $app completed" From cd07f44e0c6486a0e10515ed29a1a45e45249b1b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 4 Aug 2019 23:01:59 +0200 Subject: [PATCH 02/13] Create pull_request_template.md --- pull_request_template.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 pull_request_template.md diff --git a/pull_request_template.md b/pull_request_template.md new file mode 100644 index 0000000..f6155d6 --- /dev/null +++ b/pull_request_template.md @@ -0,0 +1,18 @@ +## Problem +- *Description of why you made this PR* + +## Solution +- *And how do you fix that problem* + +## PR Status +- [ ] Code finished. +- [ ] Tested with Package_check. +- [ ] Fix or enhancement tested. +- [ ] Upgrade from last version tested. +- [ ] Can be reviewed and tested. + +## Package_check results +--- +*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* + +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/collabora_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/collabora_ynh%20PR-NUM-%20(USERNAME)/) From 95113753176ac6fa0becb4da9c120075e296d3db Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 4 Aug 2019 23:13:48 +0200 Subject: [PATCH 03/13] fix nexctcloud_domain --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index c9672a4..a194e83 100644 --- a/check_process +++ b/check_process @@ -7,7 +7,7 @@ ; Manifest domain="domain.tld" (DOMAIN) password="pass" - nextclouddomain="nextcloud.tld" + nextcloud_domain="nextcloud.tld" ; Checks pkg_linter=1 setup_sub_dir=0 From 6bcd60137c92cd8048db8aa494f0f459f06df310 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 4 Aug 2019 23:16:36 +0200 Subject: [PATCH 04/13] fix package linter ! [YEP-1.9] The 'description' should explain what the app actually does. No need to say that it is 'for YunoHost' - this is a YunoHost app so of course we know it is for YunoHost ;-). --- manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 0964e74..09851fe 100644 --- a/manifest.json +++ b/manifest.json @@ -3,8 +3,8 @@ "id": "collabora", "packaging_format": 1, "description": { - "en": "Collabora online package for YunoHost.", - "fr": "Collabora online pour YunoHost." + "en": "Collabora online.", + "fr": "Collabora online." }, "url": "https://www.libreoffice.org/download/libreoffice-online/", "license": "MPL-2.0", From 160e0f2e8a37595a2254b5bdd4e4501d559c0447 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 4 Aug 2019 23:17:10 +0200 Subject: [PATCH 05/13] fix package_linter ! [YEP-2.12] You should not need to use 'sudo', the script is being run as root. (If you need to run a command using a specific user, use 'ynh_exec_as') --- scripts/install | 4 ++-- scripts/restore | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index 20a3946..ba15909 100644 --- a/scripts/install +++ b/scripts/install @@ -68,10 +68,10 @@ ynh_install_app_dependencies apt-transport-https apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0C54D189F4BA284D if [ "$(lsb_release --codename --short)" = "jessie" ]; then -echo 'deb https://collaboraoffice.com/repos/CollaboraOnline/CODE-debian8 ./' | sudo tee -a /etc/apt/sources.list.d/collabora.list +echo 'deb https://collaboraoffice.com/repos/CollaboraOnline/CODE-debian8 ./' | tee -a /etc/apt/sources.list.d/collabora.list else -echo 'deb https://collaboraoffice.com/repos/CollaboraOnline/CODE-debian9 ./' | sudo tee -a /etc/apt/sources.list.d/collabora.list +echo 'deb https://collaboraoffice.com/repos/CollaboraOnline/CODE-debian9 ./' | tee -a /etc/apt/sources.list.d/collabora.list fi #================================================= diff --git a/scripts/restore b/scripts/restore index 09fce15..2a4c2bf 100644 --- a/scripts/restore +++ b/scripts/restore @@ -56,10 +56,10 @@ ynh_install_app_dependencies apt-transport-https apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0C54D189F4BA284D if [ "$(lsb_release --codename --short)" = "jessie" ]; then -echo 'deb https://collaboraoffice.com/repos/CollaboraOnline/CODE-debian8 ./' | sudo tee -a /etc/apt/sources.list.d/collabora.list +echo 'deb https://collaboraoffice.com/repos/CollaboraOnline/CODE-debian8 ./' | tee -a /etc/apt/sources.list.d/collabora.list else -echo 'deb https://collaboraoffice.com/repos/CollaboraOnline/CODE-debian9 ./' | sudo tee -a /etc/apt/sources.list.d/collabora.list +echo 'deb https://collaboraoffice.com/repos/CollaboraOnline/CODE-debian9 ./' | tee -a /etc/apt/sources.list.d/collabora.list fi #================================================= From adff77f4d0854455657e011b67dfb8db9ace977d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 4 Aug 2019 23:17:56 +0200 Subject: [PATCH 06/13] Fix version --- manifest.json | 1 + 1 file changed, 1 insertion(+) diff --git a/manifest.json b/manifest.json index 09851fe..50ed587 100644 --- a/manifest.json +++ b/manifest.json @@ -6,6 +6,7 @@ "en": "Collabora online.", "fr": "Collabora online." }, + "version": "4.0.0~ynh1", "url": "https://www.libreoffice.org/download/libreoffice-online/", "license": "MPL-2.0", "maintainer": { From c514722ec4d4905dca0b8314b581e0c195dc2bb1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 4 Aug 2019 23:41:36 +0200 Subject: [PATCH 07/13] fix __NEXTCLOUDDOMAIN__ --- conf/loolwsd.xml | 4 ++-- scripts/install | 2 +- scripts/upgrade | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/conf/loolwsd.xml b/conf/loolwsd.xml index 3fb8166..d1c74b1 100644 --- a/conf/loolwsd.xml +++ b/conf/loolwsd.xml @@ -78,7 +78,7 @@ - __NEXTCLOUDDOMAIN__ + __NEXTCLOUD_DOMAIN__ 10\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} 172\.1[6789]\.[0-9]{1,3}\.[0-9]{1,3} 172\.2[0-9]\.[0-9]{1,3}\.[0-9]{1,3} @@ -88,7 +88,7 @@ 0 - __NEXTCLOUDDOMAIN__ + __NEXTCLOUD_DOMAIN__ diff --git a/scripts/install b/scripts/install index ba15909..c9a1b84 100644 --- a/scripts/install +++ b/scripts/install @@ -100,7 +100,7 @@ config="/etc/loolwsd/loolwsd.xml" cp -f ../conf/loolwsd.xml $config -ynh_replace_string --match_string="__NEXTCLOUDDOMAIN__" --replace_string="$nextcloud_domain" --target_file="$config" +ynh_replace_string --match_string="__NEXTCLOUD_DOMAIN__" --replace_string="$nextcloud_domain" --target_file="$config" ynh_replace_string --match_string="__PASSWORD__" --replace_string="$password" --target_file="$config" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index f531937..e96c8fb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -90,9 +90,9 @@ config="/etc/loolwsd/loolwsd.xml" ynh_backup_if_checksum_is_different --file="$config" -cp -a ../conf/loolwsd.xml $config +cp -f ../conf/loolwsd.xml $config -ynh_replace_string "__NEXTCLOUDDOMAIN__" "$nextcloud_domain" "$config" +ynh_replace_string "__NEXTCLOUD_DOMAIN__" "$nextcloud_domain" "$config" ynh_replace_string "__PASSWORD__" "$password" "$config" # Recalculate and store the checksum of the file for the next upgrade. From cf2280c32af65de2f63d9b4484be37014609cb7b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 4 Aug 2019 23:43:41 +0200 Subject: [PATCH 08/13] fix missing port uding upgrade --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index e96c8fb..9c5faf6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,6 +18,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app="$app" --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) +port=$(ynh_app_setting_get --app=$app --key=port) password=$(ynh_app_setting_get --app="$app" --key=password) nextclouddomain=$(ynh_app_setting_get --app="$app" --key=nextclouddomain) From 447e39503363c35dd02dc1198c0104936497e22b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 4 Aug 2019 23:46:22 +0200 Subject: [PATCH 09/13] fix nextcloud_domain during upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 9c5faf6..08b327f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,7 +20,7 @@ domain=$(ynh_app_setting_get --app="$app" --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) port=$(ynh_app_setting_get --app=$app --key=port) password=$(ynh_app_setting_get --app="$app" --key=password) -nextclouddomain=$(ynh_app_setting_get --app="$app" --key=nextclouddomain) +nextcloud_domain=$(ynh_app_setting_get --app="$app" --key=nextcloud_domain) #================================================= # ENSURE DOWNWARD COMPATIBILITY From f1d561f7e72268d12ffd6c7afc5fabc8e3c28f11 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 5 Aug 2019 00:03:27 +0200 Subject: [PATCH 10/13] fix upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 08b327f..678f95c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -115,7 +115,7 @@ ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" #================================================= ynh_print_info --message="Starting a systemd service..." -ynh_systemd_action --service_name="loolwsd" --action="start" --log_path="systemd" --line_match="Started LibreOffice Online WebSocket Daemon" +ynh_systemd_action --service_name="loolwsd" --action="restart" --log_path="systemd" --line_match="Started LibreOffice Online WebSocket Daemon" #================================================= # RELOAD NGINX From cb024f95b6f3595bb169561ff4a08d93a684d19f Mon Sep 17 00:00:00 2001 From: Rafi59 Date: Wed, 14 Aug 2019 18:35:40 +0200 Subject: [PATCH 11/13] ARM is not supported --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a2484f2..797c9c5 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to ## Limitations +ARM platform not supported. CODE has a warning limitation ![](https://www.libreoffice.org/assets/Uploads/LibreOffice-Online-limit.png) From 4f8c442c2f8be29df6df2c567998dde5b8a424ce Mon Sep 17 00:00:00 2001 From: Rafi59 Date: Thu, 29 Aug 2019 17:50:55 +0200 Subject: [PATCH 12/13] Change description Co-Authored-By: Alexandre Aubin --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 50ed587..5782455 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "id": "collabora", "packaging_format": 1, "description": { - "en": "Collabora online.", + "en": "A LibreOffice-based online office suite with collaborative editing", "fr": "Collabora online." }, "version": "4.0.0~ynh1", From 206c4d349b470c6fc22cd6023d23815f171aa738 Mon Sep 17 00:00:00 2001 From: Rafi59 Date: Thu, 29 Aug 2019 17:51:26 +0200 Subject: [PATCH 13/13] Change description Co-Authored-By: Alexandre Aubin --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 5782455..d0b2743 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "packaging_format": 1, "description": { "en": "A LibreOffice-based online office suite with collaborative editing", - "fr": "Collabora online." + "fr": "Une suite office en ligne et collaborative, basée sur LibreOffice" }, "version": "4.0.0~ynh1", "url": "https://www.libreoffice.org/download/libreoffice-online/",