diff --git a/README.md b/README.md index a0c578e..d12f998 100644 --- a/README.md +++ b/README.md @@ -35,30 +35,6 @@ Collabora Online is a powerful LibreOffice-based online office that supports all ![Screenshot of Collabora Online](./doc/screenshots/Nextcloud-writer.png) -## Disclaimers / important information - -## Configuration - -**Settings:** -The settings of Collabora are at `https://office.domain.tld/browser/dist/admin/admin.html`. - -- User: admin -- Password: The password set during the installation. (If you forgot it, you can find it again in `/etc/coolwsd/coolwsd.xml`). - -## Connexion to Nextcloud - -If you want to connect with Nextcloud, you have to install the [Collabora Online](https://apps.nextcloud.com/apps/richdocuments) app in Nextcloud, and configure it with the domain of your Collabora installation. - -*:warning: There are several Collabora Online apps. Be sure **not** to install the `Collabora Online - Built-in CODE server` apps, which are a lightwheigt version of this Collabora package. :warning:* - -## Limitations - -**ARM platform not supported.** If you want to run Collabora on Nextcloud, there is a lightweight version of the Collabora server for ARM, called [Collabora Online - Built-in CODE Server (ARM64)](https://apps.nextcloud.com/apps/richdocumentscode_arm64) which can easily connect with the [Collabora Online](https://apps.nextcloud.com/apps/richdocuments) app. - -**CODE has a warning limitation** - -![](https://www.libreoffice.org/assets/Uploads/LibreOffice-Online-limit.png) - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index b2d4222..7d44914 100644 --- a/README_fr.md +++ b/README_fr.md @@ -34,30 +34,6 @@ Collabora Online est une suite bureautique en ligne open source basé sur LibreO ![Capture d’écran de Collabora Online](./doc/screenshots/Nextcloud-writer.png) -## Avertissements / informations importantes - -## Configuration - -**Paramètres :** -Les paramètres de Collabora sont à `https://office.domain.tld/browser/dist/admin/admin.html`. - -- Utilisateur : admin -- Mot de passe : Le mot de passe défini lors de l'installation. (Si vous l'avez oublié, vous pouvez le retrouver dans `/etc/coolwsd/coolwsd.xml`). - -## Connexion à Nextcloud - -Si vous souhaitez vous connecter à Nextcloud, vous devez installer l'application [Collabora Online](https://apps.nextcloud.com/apps/richdocuments) dans Nextcloud, et la configurer avec le domaine de votre installation Collabora. - -*:warning: Il existe plusieurs applications Collabora Online. Assurez-vous **de ne pas** installer les applications `Collabora Online - Built-in CODE server`, qui sont une version allégée de ce package Collabora. :warning:* - -## Limites - -**Plateforme ARM non prise en charge.** Si vous souhaitez exécuter Collabora sur Nextcloud, il existe une version allégée du serveur Collabora pour ARM, appelée [Collabora Online - Built-in CODE Server (ARM64)](https://apps.nextcloud.com/apps/richdocumentscode_arm64) qui peut facilement se connecter à l'application [Collabora Online](https://apps.nextcloud.com/apps/richdocuments). - -**CODE a une limitation d'avertissement** - -![](https://www.libreoffice.org/assets/Uploads/LibreOffice-Online-limit.png) - ## Documentations et ressources * Site officiel de l’app : diff --git a/check_process b/check_process deleted file mode 100644 index 6cad445..0000000 --- a/check_process +++ /dev/null @@ -1,19 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - password="1Strong-Password" - nextcloud_domain="nextcloud.tld" - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=1 - setup_nourl=0 - setup_private=0 - setup_public=1 - upgrade=1 - backup_restore=1 - multi_instance=0 - change_url=0 -;;; Options -Email= -Notification=none diff --git a/conf/nginx.conf b/conf/nginx.conf index 436d7e5..5a7c4f8 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,8 +1,4 @@ -rewrite ^$ /; -location ~ ^/$ { - default_type text/plain; - return 200 "This is where Collabora Online is installed. To actually be useful, this needs to be integrated in a front-end such as Nextcloud for example."; -} +# rewrite ^$ / permanent; # static files location ^~ /browser { @@ -50,3 +46,8 @@ location ^~ /cool/adminws { proxy_set_header Host $host; proxy_read_timeout 36000s; } + +location / { + alias __INSTALL_DIR__/; + index index.html; +} diff --git a/conf/root_index.html b/conf/root_index.html new file mode 100644 index 0000000..f638df0 --- /dev/null +++ b/conf/root_index.html @@ -0,0 +1,7 @@ + + + + +This is where Collabora Online is installed. To actually be useful, this needs to be integrated in a front-end such as Nextcloud for example. + + diff --git a/doc/ADMIN.md b/doc/ADMIN.md new file mode 100644 index 0000000..0f6d826 --- /dev/null +++ b/doc/ADMIN.md @@ -0,0 +1,13 @@ +## Configuration + +**Settings:** +The settings of Collabora are at `https://__DOMAIN__/browser/dist/admin/admin.html`. + +- User: admin +- Password: The password set during the installation. (If you forgot it, you can find it again in `/etc/coolwsd/coolwsd.xml`). + +## Connection to Nextcloud + +If you want to connect with Nextcloud, you have to install the [Collabora Online](https://apps.nextcloud.com/apps/richdocuments) app in Nextcloud, and configure it with the domain of your Collabora installation. + +*:warning: There are several Collabora Online apps. Be sure **not** to install the `Collabora Online - Built-in CODE server` apps, which are a lightwheigt version of this Collabora package. :warning:* diff --git a/doc/DISCLAIMER_fr.md b/doc/ADMIN_fr.md similarity index 52% rename from doc/DISCLAIMER_fr.md rename to doc/ADMIN_fr.md index ea64e03..e29f1d9 100644 --- a/doc/DISCLAIMER_fr.md +++ b/doc/ADMIN_fr.md @@ -1,7 +1,7 @@ ## Configuration **Paramètres :** -Les paramètres de Collabora sont à `https://office.domain.tld/browser/dist/admin/admin.html`. +Les paramètres de Collabora sont à `https://__DOMAIN__/browser/dist/admin/admin.html`. - Utilisateur : admin - Mot de passe : Le mot de passe défini lors de l'installation. (Si vous l'avez oublié, vous pouvez le retrouver dans `/etc/coolwsd/coolwsd.xml`). @@ -11,11 +11,4 @@ Les paramètres de Collabora sont à `https://office.domain.tld/browser/dist/adm Si vous souhaitez vous connecter à Nextcloud, vous devez installer l'application [Collabora Online](https://apps.nextcloud.com/apps/richdocuments) dans Nextcloud, et la configurer avec le domaine de votre installation Collabora. *:warning: Il existe plusieurs applications Collabora Online. Assurez-vous **de ne pas** installer les applications `Collabora Online - Built-in CODE server`, qui sont une version allégée de ce package Collabora. :warning:* - -## Limites - -**Plateforme ARM non prise en charge.** Si vous souhaitez exécuter Collabora sur Nextcloud, il existe une version allégée du serveur Collabora pour ARM, appelée [Collabora Online - Built-in CODE Server (ARM64)](https://apps.nextcloud.com/apps/richdocumentscode_arm64) qui peut facilement se connecter à l'application [Collabora Online](https://apps.nextcloud.com/apps/richdocuments). - -**CODE a une limitation d'avertissement** - -![](https://www.libreoffice.org/assets/Uploads/LibreOffice-Online-limit.png) +ice-Online-limit.png) diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index 94c0f98..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1,21 +0,0 @@ -## Configuration - -**Settings:** -The settings of Collabora are at `https://office.domain.tld/browser/dist/admin/admin.html`. - -- User: admin -- Password: The password set during the installation. (If you forgot it, you can find it again in `/etc/coolwsd/coolwsd.xml`). - -## Connexion to Nextcloud - -If you want to connect with Nextcloud, you have to install the [Collabora Online](https://apps.nextcloud.com/apps/richdocuments) app in Nextcloud, and configure it with the domain of your Collabora installation. - -*:warning: There are several Collabora Online apps. Be sure **not** to install the `Collabora Online - Built-in CODE server` apps, which are a lightwheigt version of this Collabora package. :warning:* - -## Limitations - -**ARM platform not supported.** If you want to run Collabora on Nextcloud, there is a lightweight version of the Collabora server for ARM, called [Collabora Online - Built-in CODE Server (ARM64)](https://apps.nextcloud.com/apps/richdocumentscode_arm64) which can easily connect with the [Collabora Online](https://apps.nextcloud.com/apps/richdocuments) app. - -**CODE has a warning limitation** - -![](https://www.libreoffice.org/assets/Uploads/LibreOffice-Online-limit.png) diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md new file mode 100644 index 0000000..20ceac5 --- /dev/null +++ b/doc/POST_INSTALL.md @@ -0,0 +1 @@ +You can now use Collabora Online with Nextcloud, see the admin panel for more information! diff --git a/doc/PRE_INSTALL.md b/doc/PRE_INSTALL.md new file mode 100644 index 0000000..897e4d2 --- /dev/null +++ b/doc/PRE_INSTALL.md @@ -0,0 +1,8 @@ + +## ARM platform not supported + +If you want to run Collabora on Nextcloud, there is a lightweight version of the Collabora server for ARM, called [Collabora Online - Built-in CODE Server (ARM64)](https://apps.nextcloud.com/apps/richdocumentscode_arm64) which can easily connect with the [Nextcloud Office](https://apps.nextcloud.com/apps/richdocuments) app. + +## Usage limitation + +![LibreOffice online has a warning when more than 10 documents or more than 20 connections are in use.](https://www.libreoffice.org/assets/Uploads/LibreOffice-Online-limit.png) diff --git a/doc/PRE_INSTALL_fr.md b/doc/PRE_INSTALL_fr.md new file mode 100644 index 0000000..271e068 --- /dev/null +++ b/doc/PRE_INSTALL_fr.md @@ -0,0 +1,7 @@ +## Plateforme ARM non prise en charge + +Si vous souhaitez exécuter Collabora sur Nextcloud, il existe une version allégée du serveur Collabora pour ARM, appelée [Collabora Online - Built-in CODE Server (ARM64)](https://apps.nextcloud.com/apps/richdocumentscode_arm64) qui peut facilement se connecter à l'application [Collabora Online](https://apps.nextcloud.com/apps/richdocuments). + +## Avertissement de limite d'usage + +![LibreOffice online a un avertissement quand plus de 10 documents ou plus de 20 connections sont utilisées.](https://www.libreoffice.org/assets/Uploads/LibreOff diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 153e1f7..0000000 --- a/manifest.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "name": "Collabora Online", - "id": "collabora", - "packaging_format": 1, - "description": { - "en": "LibreOffice-based online office suite with collaborative editing", - "fr": "Suite office en ligne et collaborative, basée sur LibreOffice" - }, - "version": "22.05.14.3~ynh1", - "url": "https://collaboraoffice.com", - "upstream": { - "license": "MPL-2.0", - "website": "https://collaboraoffice.com", - "admindoc": "https://www.collaboraoffice.com/code/" - }, - "license": "MPL-2.0", - "maintainer": { - "name": "rafi59", - "email": "rafi59_dev@srvmaison.fr.nf" - }, - "requirements": { - "yunohost": ">= 11.2" - }, - "multi_instance": false, - "services": [ - "nginx" - ], - "arguments": { - "install" : [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "password", - "type": "password" - }, - { - "name": "nextcloud_domain", - "type": "string", - "ask": { - "en": "The domain of your Nextcloud instance", - "fr": "Le domain de votre instance Nextcloud" - }, - "example": "example.com/nextcloud", - "default": "" - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..910367a --- /dev/null +++ b/manifest.toml @@ -0,0 +1,75 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + +packaging_format = 2 + +id = "collabora" +name = "Collabora Online" +description.en = "LibreOffice-based online office suite with collaborative editing" +description.fr = "Suite office en ligne et collaborative, basée sur LibreOffice" + +version = "22.05.14.3~ynh1" + +maintainers = ["rafi59"] + +[upstream] +license = "MPL-2.0" +website = "https://collaboraoffice.com" +admindoc = "https://www.collaboraoffice.com/code/" +cpe = "cpe:2.3:a:collabora:online" + +[integration] +yunohost = ">= 11.2" +architectures = ["amd64", "i386", "arm64"] +multi_instance = false +ldap = "not_relevant" +sso = "not_relevant" +disk = "1G" +ram.build = "300M" +ram.runtime = "600M" + +[install] + [install.domain] + type = "domain" + + [install.init_main_permission] + help.en = "You will only be able to connect Collabora to Nextcloud if both apps are public!" + help.fr = "Nextcloud et Collabora doivent être des applications publiques si vous voulez les connecter !" + type = "group" + default = "visitors" + + [install.password] + type = "password" + + [install.nextcloud_domain] + ask.en = "The domain of your Nextcloud instance" + ask.fr = "Le domain de votre instance Nextcloud" + type = "string" + example = "example.com/nextcloud" + default = "" + +[resources] + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" + + [resources.ports] + main.default = 9980 + + [resources.apt] + packages = [ + "hunspell-de-de", + "hunspell-en-gb", + "hunspell-fr", + "hunspell", + ] + + [resources.apt.extras.collabora] + repo = "deb https://collaboraoffice.com/repos/CollaboraOnline/CODE-debian11 ./ " + key = "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x0C54D189F4BA284D" + packages = [ + "coolwsd", + "code-brand" + ] diff --git a/scripts/_common.sh b/scripts/_common.sh index 94e9d8f..944a65e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,9 +4,6 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -pkg_dependencies="coolwsd code-brand hunspell-de-de hunspell-en-gb hunspell-fr hunspell" - #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 0884082..59b1d7d 100644 --- a/scripts/backup +++ b/scripts/backup @@ -10,30 +10,17 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= ynh_print_info --message="Declaring files to be backed up..." +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= + +ynh_backup --src_path="$install_dir" + #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= @@ -41,9 +28,7 @@ ynh_print_info --message="Declaring files to be backed up..." ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP CONFIGURATION +# BACKUP VARIOUS FILES #================================================= ynh_backup --src_path="/etc/coolwsd/coolwsd.xml" diff --git a/scripts/install b/scripts/install index 6d59bae..4a2ac59 100644 --- a/scripts/install +++ b/scripts/install @@ -10,59 +10,19 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# MANAGE SCRIPT FAILURE +# INITIALIZE AND STORE SETTINGS #================================================= -ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors +ynh_app_setting_set --app="$app" --key=password --value="$password" #================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST +# DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Setting up source files..." --weight=1 -domain=$YNH_APP_ARG_DOMAIN -path_url="/" -password=$YNH_APP_ARG_PASSWORD -nextcloud_domain=$YNH_APP_ARG_NEXTCLOUD_DOMAIN +ynh_add_config --template="root_index.html" --destination="$install_dir/index.html" -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 - -if dpkg-architecture --is armhf -then - ynh_die --message="Sorry, this app can not be installed on an ARM architecture" -fi - -# Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 - -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 -#================================================= -ynh_script_progression --message="Finding an available port..." --weight=1 - -# Find a free port -port=$(ynh_find_port --port=9980) -ynh_app_setting_set --app=$app --key=port --value=$port +chown -R "$app:www-data" "$install_dir" #================================================= # CONFIGURE ONLYOFFICE @@ -74,30 +34,19 @@ ynh_script_progression --message="Installing config file..." --weight=2 # config directory which of course doesn't exists and we want to disable SSL # because we're in a reverse proxy context... mkdir -p /etc/coolwsd -ynh_add_config --template="../conf/coolwsd.xml" --destination="/etc/coolwsd/coolwsd.xml" +ynh_add_config --template="coolwsd.xml" --destination="/etc/coolwsd/coolwsd.xml" + chmod 640 "/etc/coolwsd/coolwsd.xml" +chown cool:root -R /etc/coolwsd #================================================= -# INSTALL DEPENDENCIES +# SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=10 - -DEBIAN_VERSION_NUMBER=$(cat /etc/debian_version | head -n 1 | cut -f1 -d .) -ynh_install_extra_app_dependencies --repo="deb https://collaboraoffice.com/repos/CollaboraOnline/CODE-debian${DEBIAN_VERSION_NUMBER} ./ " --package="$pkg_dependencies" --key="https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x0C54D189F4BA284D" 2>/dev/null - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=3 +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - yunohost service add "coolwsd" --description="Collabora online office suite" --log="/var/log/$app/$app.log" #================================================= @@ -107,23 +56,13 @@ yunohost service add "coolwsd" --description="Collabora online office suite" --l #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=5 -# Start a systemd service # NB. : we need a stupid *re*start because the service is in fact already started during the damn package install ... so it won't find a recent "Ready to accept connection" match ... -ynh_systemd_action --service_name="coolwsd" --action="restart" --log_path="systemd" --line_match="Ready to accept connections" +ynh_systemd_action --service_name="coolwsd" --action="stop" --log_path="systemd" +# The service installed by the deb package failed in loop, thus the reset-failed. +systemctl reset-failed coolwsd -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 - -ynh_permission_update --permission="main" --add="visitors" --show_tile="false" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload +# Start a systemd service +ynh_systemd_action --service_name="coolwsd" --action="start" --log_path="systemd" --line_match="Ready to accept connections" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 588d3ed..777208f 100644 --- a/scripts/remove +++ b/scripts/remove @@ -10,63 +10,30 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -port=$(ynh_app_setting_get --app=$app --key=port) - -#================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST +# REMOVE SYSTEM CONFIGURATIONS #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status "coolwsd" >/dev/null -then - ynh_script_progression --message="Removing coolwsd service integration..." --weight=1 - yunohost service remove "coolwsd" +if ynh_exec_warn_less yunohost service status "coolwsd" >/dev/null; then + yunohost service remove "coolwsd" fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 - # Remove the dedicated systemd config ynh_remove_systemd_config --service="coolwsd" -#================================================= -# STANDARD REMOVE -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -# 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 NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 - # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# SPECIFIC REMOVE -#================================================= - # Remove a directory securely ynh_secure_remove --file="/etc/coolwsd" + +# FIXME: is it still required? +# 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 + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index dbf3f14..8151baf 100644 --- a/scripts/restore +++ b/scripts/restore @@ -11,32 +11,16 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= -# MANAGE SCRIPT FAILURE +# RESTORE THE APP MAIN DIR #================================================= +ynh_script_progression --message="Restoring the app main directory..." --weight=1 -ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors +ynh_restore_file --origin_path="$install_dir" -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -path_url=$(ynh_app_setting_get --app=$app --key=path) - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +### $install_dir will automatically be initialized with some decent +### permissions by default ... however, you may need to recursively reapply +### ownership to all files such as after the ynh_setup_source step +chown -R "$app:www-data" "$install_dir" #================================================= # RESTORE CONFIGURATION @@ -44,36 +28,33 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_script_progression --message="Restoring the configuration..." --weight=3 ynh_restore_file --origin_path="/etc/coolwsd/coolwsd.xml" + chmod 640 "/etc/coolwsd/coolwsd.xml" +chown cool:root -R /etc/coolwsd #================================================= -# SPECIFIC RESTORATION +# RESTORE SYSTEM CONFIGURATIONS #================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=10 +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 -DEBIAN_VERSION_NUMBER=$(cat /etc/debian_version | head -n 1 | cut -f1 -d .) -ynh_install_extra_app_dependencies --repo="deb https://collaboraoffice.com/repos/CollaboraOnline/CODE-debian${DEBIAN_VERSION_NUMBER} ./ " --package="$pkg_dependencies" --key="https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x0C54D189F4BA284D" 2>/dev/null - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" yunohost service add "coolwsd" --description="Collabora online office suite" --log="/var/log/$app/$app.log" +#================================================= +# GENERIC FINALIZATION #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression --message="Starting a systemd service..." --weight=5 -ynh_systemd_action --service_name="coolwsd" --action="restart" --log_path="systemd" --line_match="Ready to accept connections" +# NB. : we need a stupid *re*start because the service is in fact already started during the damn package install ... so it won't find a recent "Ready to accept connection" match ... +ynh_systemd_action --service_name="coolwsd" --action="stop" --log_path="systemd" +# The service installed by the deb package failed in loop, thus the reset-failed. +systemctl reset-failed coolwsd -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=2 +# Start a systemd service +ynh_systemd_action --service_name="coolwsd" --action="start" --log_path="systemd" --line_match="Ready to accept connections" ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 78a4120..7d34b90 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,73 +9,26 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -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) -nextcloud_domain=$(ynh_app_setting_get --app="$app" --key=nextcloud_domain) - #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=2 -if ynh_compare_current_package_version --comparison le --version 6.4.10~ynh2 -then - ynh_die --message="Upgrade from version 6.4.10 is not possible. You must uninstall and reinstall Collabora package manually" +if ynh_compare_current_package_version --comparison le --version 6.4.10~ynh2; then + ynh_die --message="Upgrade from version 6.4.10 is not possible. You must uninstall and reinstall Collabora package manually" 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 - -if ynh_legacy_permissions_exists; then - ynh_legacy_permissions_delete_all - - ynh_app_setting_delete --app=$app --key=is_public -fi - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=5 - -# 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 - #================================================= # REMOVE OLD SERVICE INTEGRATION IN YUNOHOST #================================================= # Remove the old service from the list of services known by YunoHost (added from `yunohost service add`) -if ynh_exec_warn_less yunohost service status "loolwsd" >/dev/null -then - ynh_script_progression --message="Removing loolwsd service integration..." --weight=1 - yunohost service remove "loolwsd" +if ynh_exec_warn_less yunohost service status "loolwsd" >/dev/null; then + ynh_script_progression --message="Removing loolwsd service integration..." --weight=1 + yunohost service remove "loolwsd" fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the old systemd service..." --weight=1 - -# Remove the dedicated systemd config +# Remove the legacy systemd config ynh_remove_systemd_config --service="loolwsd" #================================================= @@ -88,12 +41,13 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=5 ynh_systemd_action --service_name="coolwsd" --action="stop" --log_path="systemd" --line_match="Stopped Collabora Online WebSocket Daemon" #================================================= -# NGINX CONFIGURATION +# DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 +ynh_script_progression --message="Setting up source files..." --weight=1 -# Create a dedicated NGINX config -ynh_add_nginx_config +ynh_add_config --template="root_index.html" --destination="$install_dir/index.html" + +chown -R "$app:www-data" "$install_dir" #================================================= # UPGRADE CONFIG @@ -106,17 +60,12 @@ chown cool: "/etc/coolwsd/coolwsd.xml" chmod 640 "/etc/coolwsd/coolwsd.xml" #================================================= -# UPGRADE DEPENDENCIES +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=10 +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 -DEBIAN_VERSION_NUMBER=$(cat /etc/debian_version | head -n 1 | cut -f1 -d .) -ynh_install_extra_app_dependencies --repo="deb https://collaboraoffice.com/repos/CollaboraOnline/CODE-debian${DEBIAN_VERSION_NUMBER} ./ " --package="$pkg_dependencies" --key="https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x0C54D189F4BA284D" 2>/dev/null - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +# Create a dedicated NGINX config +ynh_add_nginx_config yunohost service add "coolwsd" --description="Collabora online office suite" --log="/var/log/$app/$app.log" @@ -127,13 +76,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=3 ynh_systemd_action --service_name="coolwsd" --action="restart" --log_path="systemd" --line_match="Ready to accept connections" -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..cd550e9 --- /dev/null +++ b/tests.toml @@ -0,0 +1,11 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + +test_format = 1.0 + +[default] + + args.nextcloud_domain = "nextcloud.tld" + + exclude = ["change_url"] + + # test_upgrade_from.5725c85c09f1d3b76d12a4dc4d367ec911cd0019.name = "Last packaging v1 version"