From 6474f21db61c7c9b5a8cb59fa8a0203a26a98567 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 25 Feb 2019 19:45:11 +0100 Subject: [PATCH 01/88] Apply example_ynh --- README.md | 79 ++++++++++++++++++------ check_process | 5 +- manifest.json | 32 +++------- scripts/_common.sh | 14 ++++- scripts/backup | 81 ++++++++++++++++-------- scripts/install | 134 +++++++++++++++++++++------------------- scripts/remove | 29 +++++++-- scripts/restore | 139 ++++++++++++++++++++++++++++++------------ scripts/upgrade | 149 +++++++++++++++++++++++++++++++++++---------- 9 files changed, 452 insertions(+), 210 deletions(-) diff --git a/README.md b/README.md index 25539ff..7d14afa 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,75 @@ -# OnlyOffice app for YunoHost +# OnlyOffice for YunoHost + +[![Integration level](https://dash.yunohost.org/integration/REPLACEBYYOURAPP.svg)](https://dash.yunohost.org/appci/app/REPLACEBYYOURAPP) +[![Install REPLACEBYYOURAPP with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=REPLACEBYYOURAPP) + +> *This package allow you to install REPLACEBYYOURAPP 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 OnlyOffice Document Server -- [Yunohost project](https://yunohost.org) -- [OnlyOffice website](https://www.onlyoffice.com) +**Shipped version:** 1.0 + +## Screenshots ![](http://kaosenlared.net/wp-content/uploads/2016/10/onlyoffyce-2.jpg) -[![Integration level](https://dash.yunohost.org/integration/onlyoffice_ynh.svg)](https://dash.yunohost.org/appci/app/onlyoffice_ynh) -[![Install OnlyOffice with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=onlyoffice) +## Demo -### Version +* [Official demo](Link to a demo site for this app) -1. Master = Is stable and work version +## Configuration -2. BETA_VERSION = Beta is version for multi-instances and add possibility to install on same domain as nextcloud (not work need fix). +How to configure this app: by an admin panel, a plain file with SSH, or any other way. -3. YHN_VERSION = This version respect rules of yunohost for app install (not work need fix). +## Documentation -### Installing guide + * Official documentation: Link to the official documentation of this app + * YunoHost documentation: If specific documentation is needed, feel free to contribute. - 1. App can be installed by YunoHost **admin web-interface** or by **running following command**: +## YunoHost specific features - $ sudo yunohost app install https://github.com/YunoHost-Apps/onlyoffice_ynh - - $ sudo yunohost app install --debug https://github.com/YunoHost-Apps/onlyoffice_ynh - - 2. Need to restart yunohost. - -### Upgrade this package: +#### Multi-users support - $ sudo yunohost app upgrade --verbose example -u https://github.com/YunoHost-Apps/onlyoffice_ynh +Are LDAP and HTTP auth supported? +Can the app be used by multiple users? +#### Supported architectures +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/REPLACEBYYOURAPP%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/REPLACEBYYOURAPP/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/REPLACEBYYOURAPP%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/REPLACEBYYOURAPP/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/REPLACEBYYOURAPP%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/REPLACEBYYOURAPP/) + +## Limitations + +* Any known limitations. + +## Additional information + +* Other information you would add about this application + +**More information on the documentation page:** +https://yunohost.org/packaging_apps + +## Links + + * Report a bug: https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/issues + * App website: https://www.onlyoffice.com + * Github App website: https://github.com/ONLYOFFICE/CommunityServer + * YunoHost website: https://yunohost.org/ + +--- + +Developers info +---------------- + +**Only if you want to use a testing branch for coding, instead of merging directly into master.** +Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing --debug +or +sudo yunohost app upgrade REPLACEBYYOURAPP -u https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing --debug +``` diff --git a/check_process b/check_process index 0cbeae3..ed2844f 100644 --- a/check_process +++ b/check_process @@ -28,9 +28,8 @@ Level 1=auto Level 2=auto Level 3=auto -# Level 4: - Level 4=1 (This app supports the Nextcloud LDAP auth) -# Level 5: +# Level 4: (This app supports the Nextcloud LDAP auth) + Level 4=1 Level 5=auto Level 6=auto Level 7=auto diff --git a/manifest.json b/manifest.json index 5be903a..8ad8c89 100644 --- a/manifest.json +++ b/manifest.json @@ -3,23 +3,22 @@ "id": "onlyoffice", "packaging_format": 1, "description": { - "en": "OnlyOffice package for YunoHost.", - "fr": "OnlyOffice pour YunoHost." + "en": "OnlyOffice Document Server.", + "fr": "Serveur de documents OnlyOffice." }, - "url": "https://www.plex.tv/", - "license": "free", + "version": "1.0~ynh1", + "url": "https://www.onlyoffice.com", + "license": "GPL-3.0-or-later", "maintainer": { "name": "liberodark", "email": "liberodark@gmail.com" }, "requirements": { - "yunohost": ">= 2.7.2" + "yunohost": ">= 3.4" }, "multi_instance": false, "services": [ - "nginx", - "php5-fpm", - "mysql" + "nginx" ], "arguments": { "install": [{ @@ -42,26 +41,15 @@ "example": "example.com", "default": "example.com" }, - - { - "name": "path", - "type": "path", - "ask": { - "en": "Choose a path for OnlyOffice only / is accepted", - "fr": "Choisissez un chemin pour OnlyOffice uniquement / est accepté" - }, - "example": "/", - "default": "/" - }, { "name": "is_public", "type": "boolean", "ask": { - "en": "Is it a public site ?", - "fr": "Est-ce un site public ?" + "en": "Is it a public application?", + "fr": "Est-ce une application publique ?" }, - "default": "true" + "default": true } ] } diff --git a/scripts/_common.sh b/scripts/_common.sh index cc1f786..b905339 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1 +1,13 @@ -#!/bin/bash \ No newline at end of file +#!/bin/bash + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/backup b/scripts/backup index 86e3061..39b1593 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,34 +1,63 @@ #!/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 +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 () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} +# 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" -ynh_backup "/etc/onlyoffice/documentserver/default.json" +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info "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 + +final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get $app domain) +db_name=$(ynh_app_setting_get $app db_name) + +#================================================= +# STANDARD BACKUP STEPS +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= +ynh_print_info "Backing up the main app directory..." + +ynh_backup "$final_path" + +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= +ynh_print_info "Backing up nginx web server configuration..." + +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +9999 ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" +9999 ynh_backup "/etc/onlyoffice/documentserver/default.json" + +#================================================= +# BACKUP THE POSTGRESQL DATABASE +#================================================= +ynh_print_info "Backing up the PostgreSQL database..." + +ynh_psql_dump_db "$db_name" > db.sql + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/install b/scripts/install index b36bc3f..a6c7169 100644 --- a/scripts/install +++ b/scripts/install @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#source _common.sh +source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -26,7 +26,7 @@ ynh_abort_if_errors # Retrieve arguments domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH +path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC nextclouddomain=$YNH_APP_ARG_NEXTCLOUDDOMAIN @@ -45,6 +45,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +ynh_print_info "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" @@ -54,23 +55,25 @@ test ! -e "$final_path" || ynh_die "This path already contains a folder" # Normalize the url path syntax path_url=$(ynh_normalize_url_path $path_url) -# Check web path availability -ynh_webpath_available $domain $path_url # Register (book) web path ynh_webpath_register $app $domain $path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_print_info "Storing installation settings..." ynh_app_setting_set $app domain $domain ynh_app_setting_set $app nextclouddomain $nextclouddomain ynh_app_setting_set $app path $path_url ynh_app_setting_set $app is_public $is_public +#================================================= +# STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= +ynh_print_info "Configuring firewall..." ### 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. @@ -80,73 +83,49 @@ ynh_app_setting_set $app is_public $is_public # Find a free port port=$(ynh_find_port 9980) # Open this port -yunohost firewall allow --no-upnp TCP $port 2>&1 +#ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port ynh_app_setting_set $app port $port -#============================================== -# INSTALL POSTGRES -#============================================== +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_print_info "Installing dependencies..." -#Master -#ynh_install_app_dependencies postgresql redis-server apt-transport-https libasound2 libboost-regex-dev libboost1.62-dev libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libfontenc1 libgail-common libgail18 libgconf-2-4 libgconf2-4 libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libglu1-mesa libgtk2.0-0 libgtk2.0-bin libgtk2.0-common libgtkglext1 libice6 libicu-dev libllvm3.9 libpangox-1.0-0 libpciaccess0 librsvg2-2 librsvg2-common libsm6 libtxc-dxtn-s2tc libx11-xcb1 libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-sync1 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxfont1 libxfont2 libxi6 libxinerama1 libxkbfile1 libxmu6 libxrandr2 libxshmfence1 libxt6 libxtst6 libxxf86vm1 postgresql-client pwgen python-meld3 supervisor x11-xkb-utils xfonts-base xfonts-encodings xfonts-utils xserver-common xvfb - -#Beta -sudo apt-get install -y postgresql redis-server rabbitmq-server apt-transport-https - -#Old -# ynh_install_app_dependencies postgresql redis-server rabbitmq-server apt-transport-https -# ynh_install_app_dependencies postgresql redis-server rabbitmq-server apt-transport-https libcurl3 libxml2 supervisor fonts-dejavu fonts-liberation ttf-mscorefonts-installer fonts-crosextra-carlito fonts-takao-gothic fonts-opensymbol +ynh_install_app_dependencies postgresql libstdc redis-server rabbitmq-server #================================================= # INSTALL NODEJS #================================================= -# Use Helper instead of package from the repo -#Master -#ynh_install_nodejs 8.12.0 +ynh_install_nodejs 8.12.0 -#Beta -curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - +#================================================= +# CREATE A POSTGRESQL DATABASE +#================================================= +ynh_print_info "Creating a PostgreSQL database..." -#=============================================== -# ADD ONLYOFFCE REPOSITORY -#=============================================== +### Use these lines if you need a database for the application. +### `ynh_mysql_setup_db` will create a database, an associated user and a ramdom password. +### The password will be stored as 'mysqlpwd' into the app settings, +### and will be available as $db_pwd +### If you're not using these lines: +### - Remove the section "BACKUP THE POSTGRESQL DATABASE" in the backup script +### - Remove also the section "REMOVE THE POSTGRESQL DATABASE" in the remove script +### - As well as the section "RESTORE THE POSTGRESQL DATABASE" in the restore script -#Beta no for Master version -apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 -echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list -ynh_package_update - -#============================================== -# CREATE DB -#============================================== - -sudo -i -u postgres psql -c "CREATE DATABASE onlyoffice;" -sudo -i -u postgres psql -c "CREATE USER onlyoffice WITH password 'onlyoffice';" -sudo -i -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;" - -#============================================== -# DEFINE PORT -#============================================== - -echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections - -#============================================== -# INSTALL ONLYOFFICE -#============================================== - -#Master -#ynh_package_install_from_equivs ../conf/fakenode-deps.control -#ynh_package_install_from_equivs ../conf/fakepostgres-deps.control -#wget --no-verbose https://github.com/ONLYOFFICE/DocumentServer/releases/download/ONLYOFFICE-DocumentServer-5.2.3/onlyoffice-documentserver_amd64.deb -#dpkg --install onlyoffice-documentserver_amd64.deb - -#Beta -sudo apt-get install -y onlyoffice-documentserver +db_name=$(ynh_sanitize_dbid $app) +db_pwd=$(ynh_string_random 30) +ynh_app_setting_set $app db_name $db_name +ynh_app_setting_set $app db_pwd $db_pwd +ynh_psql_test_if_first_run +ynh_psql_create_db $db_name $db_name $db_pwd #================================================= # NGINX CONFIGURATION #================================================= +ynh_print_info "Configuring nginx web server..." + +### `ynh_add_nginx_config` will use the file conf/nginx.conf # Create a dedicated nginx config ynh_add_nginx_config "nextclouddomain" @@ -154,11 +133,32 @@ ynh_add_nginx_config "nextclouddomain" #================================================= # CREATE DEDICATED USER #================================================= +ynh_print_info "Configuring system user..." # Create a system user ynh_system_user_create $app #================================================= +# SPECIFIC SETUP +#============================================== +# DEFINE PORT +#============================================== + +echo onlyoffice-documentserver onlyoffice/ds-port select $port | sudo debconf-set-selections + +#=============================================== +# ADD ONLYOFFICE REPOSITORY +#=============================================== + +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 +echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list +ynh_package_update + +#============================================== +# INSTALL ONLYOFFICE +#============================================== + +sudo apt-get install -y onlyoffice-documentserver # MODIFY A CONFIG FILE #================================================= @@ -200,13 +200,25 @@ cp -a ../conf/default.json /etc/onlyoffice/documentserver/default.json #================================================= # SETUP SSOWAT #================================================= +ynh_print_info "Configuring SSOwat..." -# If app is public, add url to SSOWat conf as skipped_uris -if [ $is_public -eq 1 ]; then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set "$app" unprotected_uris "/" +# Make app public if necessary +if [ $is_public -eq 1 ] +then + # unprotected_uris allows SSO credentials to be passed anyway. + ynh_app_setting_set $app unprotected_uris "/" fi -# Reload services +#================================================= +# RELOAD NGINX +#================================================= +ynh_print_info "Reloading nginx web server..." + systemctl reload nginx supervisorctl restart all + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index 35577fb..bc71c21 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,19 +12,31 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) port=$(ynh_app_setting_get $app port) +db_name=$(ynh_app_setting_get $app db_name) final_path=$(ynh_app_setting_get $app final_path) #================================================= # STANDARD REMOVE #================================================= + +#================================================= +# REMOVE THE POSTGRESQL DATABASE +#================================================= +ynh_print_info "Removing the PostgreSQL database" + +# Remove a database if it exists, along with the associated user +ynh_psql_drop_db $db_name $db_name + #================================================= # REMOVE DEPENDENCIES #================================================= +ynh_print_info "Removing dependencies" # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -32,6 +44,7 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= +ynh_print_info "Removing app main directory" # Remove the app directory securely ynh_secure_remove "$final_path" @@ -39,6 +52,7 @@ ynh_secure_remove "$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= +ynh_print_info "Removing nginx web server configuration" # Remove the dedicated nginx config ynh_remove_nginx_config @@ -49,8 +63,8 @@ ynh_remove_nginx_config if yunohost firewall list | grep -q "\- $port$" then - echo "Close port $port" >&2 - yunohost firewall disallow TCP $port 2>&1 + ynh_print_info "Closing port $port" + ynh_exec_warn_less yunohost firewall disallow TCP $port fi #================================================= @@ -65,10 +79,6 @@ ynh_secure_remove "/etc/cron.d/$app" # Remove a directory securely ynh_secure_remove "/etc/apt/sources.list.d/onlyoffice.list" -# Remove DB -sudo -i -u postgres psql -c "DROP DATABASE onlyoffice;" -sudo -i -u postgres psql -c "DROP USER onlyoffice;" - # Remove the log files ynh_secure_remove "/var/log/$app/" @@ -77,6 +87,13 @@ ynh_secure_remove "/var/log/$app/" #================================================= # REMOVE DEDICATED USER #================================================= +ynh_print_info "Removing the dedicated system user" # Delete a system user ynh_system_user_delete $app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 93169e9..efcdc00 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,52 +1,111 @@ #!/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 +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 () { + #### Remove this function if there's nothing to clean before calling the remove script. + true +} +# 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 "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 domain) +path_url=$(ynh_app_setting_get $app path) +final_path=$(ynh_app_setting_get $app final_path) +db_name=$(ynh_app_setting_get $app db_name) +db_pwd=$(ynh_app_setting_get $app db_pwd) -# 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 "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 $path_url \ + || ynh_die "Path not available: ${domain}${path_url}" +test ! -d $final_path \ + || ynh_die "There is already a directory: $final_path " -# Restart webserver -sudo service nginx reload +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= + +ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_print_info "Restoring the app main directory..." + +ynh_restore_file "$final_path" + +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_print_info "Recreating the dedicated system user..." + +# Create the dedicated user (if not existing) +ynh_system_user_create $app + +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Restore permissions on app files +chown -R root: $final_path + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_print_info "Reinstalling dependencies..." + +# Define and install dependencies +ynh_install_app_dependencies deb1 deb2 + +#================================================= +# RESTORE THE POSTGRESQL DATABASE +#================================================= +ynh_print_info "Restoring the PostgreSQL database..." + +ynh_psql_test_if_first_run +ynh_psql_create_db $db_name $db_name $db_pwd +ynh_psql_execute_file_as_root ./db.sql "$db_name" + + + + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX +#================================================= +ynh_print_info "Reloading nginx web server..." + +systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 3d706e4..094104a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,57 +1,142 @@ #!/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 "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 domain) +path_url=$(ynh_app_setting_get $app path) +is_public=$(ynh_app_setting_get $app is_public) +db_name=$(ynh_app_setting_get $app db_name) +nextclouddomain=$(ynh_app_setting_get $app nextclouddomain) #================================================= -# UPGRADE COLLABORA +# ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_package_update -ynh_install_app_dependencies loolwsd code-brand +ynh_print_info "Ensuring downward compatibility..." +# Fix is_public as a boolean value +if [ "$is_public" = "Yes" ]; then + ynh_app_setting_set $app is_public 1 + is_public=1 +elif [ "$is_public" = "No" ]; then + ynh_app_setting_set $app is_public 0 + is_public=0 +fi + +# If db_name doesn't exist, create it +if [ -z $db_name ]; then + db_name=$(ynh_sanitize_dbid $app) + ynh_app_setting_set $app db_name $db_name +fi + +# If final_path doesn't exist, create it +if [ -z $final_path ]; then + final_path=/var/www/$app + ynh_app_setting_set $app final_path $final_path +fi + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_print_info "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_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# CHECK THE PATH +#================================================= + +# Normalize the URL path syntax +path_url=$(ynh_normalize_url_path $path_url) + +#================================================= +# STANDARD UPGRADE STEPS #================================================= # NGINX CONFIGURATION #================================================= +ynh_print_info "Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_print_info "Upgrading dependencies..." + +ynh_install_app_dependencies deb1 deb2 #================================================= -# UPGRADE CONFIG +# CREATE DEDICATED USER #================================================= -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 +ynh_print_info "Making sure dedicated system user exists..." + +# Create a dedicated user (if not existing) +ynh_system_user_create $app + +#================================================= +# SPECIFIC UPGRADE +#================================================= +# ... +#================================================= + +### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. +### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. +#ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE" +# Recalculate and store the checksum of the file for the next upgrade. +#ynh_store_file_checksum "$final_path/CONFIG_FILE" +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= -# 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 "/" +# Set permissions on app files +chown -R root: $final_path + +#================================================= +# SETUP SSOWAT +#================================================= +ynh_print_info "Upgrading SSOwat configuration..." + +# Make app public if necessary +if [ $is_public -eq 1 ] +then + # unprotected_uris allows SSO credentials to be passed anyway + ynh_app_setting_set $app unprotected_uris "/" fi -# Reload nginx service -systemctl restart nginx -systemctl restart loolwsd +#================================================= +# RELOAD NGINX +#================================================= +ynh_print_info "Reloading nginx web server..." +systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Upgrade of $app completed" From f7682167682e699d6c277f1584dda6daa5b1127c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 25 Feb 2019 19:46:18 +0100 Subject: [PATCH 02/88] Add wait during installation --- scripts/install | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install b/scripts/install index a6c7169..eb42ca1 100644 --- a/scripts/install +++ b/scripts/install @@ -15,6 +15,7 @@ source /usr/share/yunohost/helpers ynh_clean_setup () { ### Remove this function if there's nothing to clean before calling the remove script. + read -p "Press any key..." true } # Exit if an error occurs during the execution of the script From d66a3fa8580beeb9531dd66279e20feaac22a770 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 25 Feb 2019 19:51:44 +0100 Subject: [PATCH 03/88] Fix libstdc++6 dependency --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index eb42ca1..1977ae2 100644 --- a/scripts/install +++ b/scripts/install @@ -92,7 +92,7 @@ ynh_app_setting_set $app port $port #================================================= ynh_print_info "Installing dependencies..." -ynh_install_app_dependencies postgresql libstdc redis-server rabbitmq-server +ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server #================================================= # INSTALL NODEJS From 4030cdb0657daee7a9aaa5423c507084e0776913 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 25 Feb 2019 19:58:27 +0100 Subject: [PATCH 04/88] Fix nodejs installation --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 1977ae2..f1c7a5b 100644 --- a/scripts/install +++ b/scripts/install @@ -98,7 +98,7 @@ ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server # INSTALL NODEJS #================================================= -ynh_install_nodejs 8.12.0 +curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - #================================================= # CREATE A POSTGRESQL DATABASE From 6473bbf0c9097dd62e51deb844f6a1500aa2dc9f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 25 Feb 2019 20:15:41 +0100 Subject: [PATCH 05/88] fix drop postgresql user --- scripts/remove | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/remove b/scripts/remove index bc71c21..62f94fe 100644 --- a/scripts/remove +++ b/scripts/remove @@ -32,6 +32,7 @@ ynh_print_info "Removing the PostgreSQL database" # Remove a database if it exists, along with the associated user ynh_psql_drop_db $db_name $db_name +ynh_psql_drop_user $db_name #================================================= # REMOVE DEPENDENCIES From 5b0a1b9c76d10f79e082d465863eb74e8b01343b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 25 Feb 2019 20:26:38 +0100 Subject: [PATCH 06/88] Fix remove step --- scripts/remove | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/remove b/scripts/remove index 62f94fe..fc4b6de 100644 --- a/scripts/remove +++ b/scripts/remove @@ -31,6 +31,8 @@ final_path=$(ynh_app_setting_get $app final_path) ynh_print_info "Removing the PostgreSQL database" # Remove a database if it exists, along with the associated user +ynh_psql_execute_as_root "\connect $db_name +SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$db_name';" ynh_psql_drop_db $db_name $db_name ynh_psql_drop_user $db_name From 26b674948e62502d6a95da0ae81fb7729b403cae Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 25 Feb 2019 20:59:36 +0100 Subject: [PATCH 07/88] Fix port --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index f1c7a5b..f449915 100644 --- a/scripts/install +++ b/scripts/install @@ -145,7 +145,7 @@ ynh_system_user_create $app # DEFINE PORT #============================================== -echo onlyoffice-documentserver onlyoffice/ds-port select $port | sudo debconf-set-selections +echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections #=============================================== # ADD ONLYOFFICE REPOSITORY From 4849f62bc9a77fd31c4e11a69268546d1b559a40 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 25 Feb 2019 21:13:59 +0100 Subject: [PATCH 08/88] fix db_pwd --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index f449915..fd549a2 100644 --- a/scripts/install +++ b/scripts/install @@ -115,7 +115,7 @@ ynh_print_info "Creating a PostgreSQL database..." ### - As well as the section "RESTORE THE POSTGRESQL DATABASE" in the restore script db_name=$(ynh_sanitize_dbid $app) -db_pwd=$(ynh_string_random 30) +db_pwd="onlyoffice" ynh_app_setting_set $app db_name $db_name ynh_app_setting_set $app db_pwd $db_pwd ynh_psql_test_if_first_run From c14e23dc1cb8109ededcffc86cc2a00a4d37cb58 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 25 Feb 2019 22:35:07 +0100 Subject: [PATCH 09/88] Differents fixes --- scripts/install | 41 ++++++++++++++++++++++------------------- scripts/remove | 2 ++ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/scripts/install b/scripts/install index fd549a2..6fc072b 100644 --- a/scripts/install +++ b/scripts/install @@ -50,7 +50,7 @@ ynh_print_info "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 +final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" # Normalize the url path syntax @@ -92,6 +92,13 @@ ynh_app_setting_set $app port $port #================================================= ynh_print_info "Installing dependencies..." +### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. +### Those deb packages will be installed as dependencies of this package. +### If you're not using this helper: +### - Remove the section "REMOVE DEPENDENCIES" in the remove script +### - As well as the section "REINSTALL DEPENDENCIES" in the restore script +### - And the section "UPGRADE DEPENDENCIES" in the upgrade script + ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server #================================================= @@ -137,40 +144,36 @@ ynh_add_nginx_config "nextclouddomain" ynh_print_info "Configuring system user..." # Create a system user -ynh_system_user_create $app +ynh_system_user_create $app $final_path #================================================= # SPECIFIC SETUP -#============================================== +#================================================= # DEFINE PORT -#============================================== +#================================================= echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections -#=============================================== +#================================================= # ADD ONLYOFFICE REPOSITORY -#=============================================== +#================================================= apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list ynh_package_update -#============================================== +#================================================= # INSTALL ONLYOFFICE -#============================================== +#================================================= -sudo apt-get install -y onlyoffice-documentserver +ynh_package_install onlyoffice-documentserver + +#================================================= # MODIFY A CONFIG FILE #================================================= # Fix https://github.com/ONLYOFFICE/onlyoffice-owncloud/issues/172#issuecomment-411746394 -cp -a ../conf/default.json /etc/onlyoffice/documentserver/default.json - -# Fix Nextcloud http://dev.onlyoffice.org/viewtopic.php?f=53&t=10001 -#sed -i "/# Add headers to serve security.*/a \ \ \ \ add_header X-Frame-Options \"ALLOW-FROM https://$domain/\";" /etc/nginx/conf.d/$nextcloud_domain.d/nextcloud.conf - -# Fix OnlyOffice http://dev.onlyoffice.org/viewtopic.php?f=53&t=10001 -#sed -i "/# Add headers to serve security.*/a \ \ \ \ add_header X-Frame-Options \"ALLOW-FROM https://$domain/\";" /etc/nginx/conf.d/$domain.d/onlyoffice.conf +#cp -a ../conf/default.json /etc/onlyoffice/documentserver/default.json #================================================= # STORE THE CONFIG FILE CHECKSUM @@ -195,8 +198,7 @@ cp -a ../conf/default.json /etc/onlyoffice/documentserver/default.json ### that really need such authorization. # Set permissions to app files -#chown -R root: /etc/loolwsd - +chown -R $app: $final_path #================================================= # SETUP SSOWAT @@ -216,7 +218,8 @@ fi ynh_print_info "Reloading nginx web server..." systemctl reload nginx -supervisorctl restart all +supervisorctl stop all +supervisorctl start all #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index fc4b6de..d0f1814 100644 --- a/scripts/remove +++ b/scripts/remove @@ -42,6 +42,8 @@ ynh_psql_drop_user $db_name ynh_print_info "Removing dependencies" # Remove metapackage and its dependencies +ynh_package_remove onlyoffice-documentserver +ynh_package_remove nodejs ynh_remove_app_dependencies #================================================= From 128a7fd5bf5b083c3f7a2c07bf80451feb70db09 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 25 Feb 2019 23:02:44 +0100 Subject: [PATCH 10/88] fix backup / restore --- scripts/backup | 2 -- scripts/restore | 31 +++++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/scripts/backup b/scripts/backup index 39b1593..cae426f 100644 --- a/scripts/backup +++ b/scripts/backup @@ -46,8 +46,6 @@ ynh_backup "$final_path" ynh_print_info "Backing up nginx web server configuration..." ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" -9999 ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" -9999 ynh_backup "/etc/onlyoffice/documentserver/default.json" #================================================= # BACKUP THE POSTGRESQL DATABASE diff --git a/scripts/restore b/scripts/restore index efcdc00..76668a7 100644 --- a/scripts/restore +++ b/scripts/restore @@ -32,6 +32,7 @@ path_url=$(ynh_app_setting_get $app path) final_path=$(ynh_app_setting_get $app final_path) db_name=$(ynh_app_setting_get $app db_name) db_pwd=$(ynh_app_setting_get $app db_pwd) +port=$(ynh_app_setting_get $app port) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -71,7 +72,7 @@ ynh_system_user_create $app #================================================= # Restore permissions on app files -chown -R root: $final_path +chown -R $app: $final_path #================================================= # SPECIFIC RESTORATION @@ -81,7 +82,13 @@ chown -R root: $final_path ynh_print_info "Reinstalling dependencies..." # Define and install dependencies -ynh_install_app_dependencies deb1 deb2 +ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server + +#================================================= +# INSTALL NODEJS +#================================================= + +curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - #================================================= # RESTORE THE POSTGRESQL DATABASE @@ -92,7 +99,25 @@ ynh_psql_test_if_first_run ynh_psql_create_db $db_name $db_name $db_pwd ynh_psql_execute_file_as_root ./db.sql "$db_name" +#================================================= +# DEFINE PORT +#================================================= +echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections + +#================================================= +# ADD ONLYOFFICE REPOSITORY +#================================================= + +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 +echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list +ynh_package_update + +#================================================= +# INSTALL ONLYOFFICE +#================================================= + +ynh_package_install onlyoffice-documentserver #================================================= @@ -103,6 +128,8 @@ ynh_psql_execute_file_as_root ./db.sql "$db_name" ynh_print_info "Reloading nginx web server..." systemctl reload nginx +supervisorctl stop all +supervisorctl start all #================================================= # END OF SCRIPT From b3eca428ce29420e8148124a7e56b72cc3d388eb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 25 Feb 2019 23:15:24 +0100 Subject: [PATCH 11/88] fix remove db --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index d0f1814..98dd899 100644 --- a/scripts/remove +++ b/scripts/remove @@ -33,7 +33,7 @@ ynh_print_info "Removing the PostgreSQL database" # Remove a database if it exists, along with the associated user ynh_psql_execute_as_root "\connect $db_name SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$db_name';" -ynh_psql_drop_db $db_name $db_name +ynh_psql_remove_db $db_name $db_name ynh_psql_drop_user $db_name #================================================= From 4e4e4331e19d306145f2961258de73576cd74250 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 25 Feb 2019 23:35:33 +0100 Subject: [PATCH 12/88] Fix pgsql removal --- scripts/remove | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/remove b/scripts/remove index 98dd899..6876b84 100644 --- a/scripts/remove +++ b/scripts/remove @@ -34,7 +34,6 @@ ynh_print_info "Removing the PostgreSQL database" ynh_psql_execute_as_root "\connect $db_name SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$db_name';" ynh_psql_remove_db $db_name $db_name -ynh_psql_drop_user $db_name #================================================= # REMOVE DEPENDENCIES @@ -79,7 +78,7 @@ fi #================================================= # Remove a cron file -ynh_secure_remove "/etc/cron.d/$app" +#ynh_secure_remove "/etc/cron.d/$app" # Remove a directory securely ynh_secure_remove "/etc/apt/sources.list.d/onlyoffice.list" From a6dec1d9deda1b924f0092b92d1b90218ae407ee Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 25 Feb 2019 23:57:27 +0100 Subject: [PATCH 13/88] Fix user removal --- scripts/remove | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/remove b/scripts/remove index 6876b84..f63265d 100644 --- a/scripts/remove +++ b/scripts/remove @@ -94,6 +94,7 @@ ynh_secure_remove "/var/log/$app/" ynh_print_info "Removing the dedicated system user" # Delete a system user +ynh_system_user_delete www-data ynh_system_user_delete $app #================================================= From fbd7581aeab9c3211c9ce886149b064b064f26b3 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 00:00:29 +0100 Subject: [PATCH 14/88] Fix removal --- scripts/remove | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/remove b/scripts/remove index f63265d..778713c 100644 --- a/scripts/remove +++ b/scripts/remove @@ -52,6 +52,7 @@ ynh_print_info "Removing app main directory" # Remove the app directory securely ynh_secure_remove "$final_path" +rm -rf "$final_path" #================================================= # REMOVE NGINX CONFIGURATION From 0d2e99bf9d11d94736260ec267398608421569fb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 00:14:20 +0100 Subject: [PATCH 15/88] Fix group removal --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 778713c..4a65fd2 100644 --- a/scripts/remove +++ b/scripts/remove @@ -95,7 +95,7 @@ ynh_secure_remove "/var/log/$app/" ynh_print_info "Removing the dedicated system user" # Delete a system user -ynh_system_user_delete www-data +gpasswd -d www-data onlyoffice ynh_system_user_delete $app #================================================= From 5b679535081fa3f5acd239aa288b8fa509f0fe33 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 00:52:20 +0100 Subject: [PATCH 16/88] Fix install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 6fc072b..a8cbd9c 100644 --- a/scripts/install +++ b/scripts/install @@ -173,7 +173,7 @@ ynh_package_install onlyoffice-documentserver #================================================= # Fix https://github.com/ONLYOFFICE/onlyoffice-owncloud/issues/172#issuecomment-411746394 -#cp -a ../conf/default.json /etc/onlyoffice/documentserver/default.json +cp -a ../conf/default.json /etc/onlyoffice/documentserver/default.json #================================================= # STORE THE CONFIG FILE CHECKSUM From 633869aaff3409dc453b7524b5a7f77aeaf7c66c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 01:43:44 +0100 Subject: [PATCH 17/88] Fix README.md --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 7d14afa..f3f4e35 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # OnlyOffice for YunoHost -[![Integration level](https://dash.yunohost.org/integration/REPLACEBYYOURAPP.svg)](https://dash.yunohost.org/appci/app/REPLACEBYYOURAPP) -[![Install REPLACEBYYOURAPP with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=REPLACEBYYOURAPP) +[![Integration level](https://dash.yunohost.org/integration/onlyoffice.svg)](https://dash.yunohost.org/appci/app/onlyoffice) +[![Install onlyoffice with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=onlyoffice) -> *This package allow you to install REPLACEBYYOURAPP quickly and simply on a YunoHost server. +> *This package allow you to install OnlyOffice 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 @@ -37,9 +37,9 @@ Can the app be used by multiple users? #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/REPLACEBYYOURAPP%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/REPLACEBYYOURAPP/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/REPLACEBYYOURAPP%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/REPLACEBYYOURAPP/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/REPLACEBYYOURAPP%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/REPLACEBYYOURAPP/) +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/onlyoffice%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/onlyoffice/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/onlyoffice%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/onlyoffice/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/onlyoffice%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/onlyoffice/) ## Limitations @@ -54,7 +54,7 @@ https://yunohost.org/packaging_apps ## Links - * Report a bug: https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/issues + * Report a bug: https://github.com/YunoHost-Apps/onlyoffice_ynh/issues * App website: https://www.onlyoffice.com * Github App website: https://github.com/ONLYOFFICE/CommunityServer * YunoHost website: https://yunohost.org/ @@ -65,11 +65,11 @@ Developers info ---------------- **Only if you want to use a testing branch for coding, instead of merging directly into master.** -Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing). +Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/onlyoffice_ynh/tree/testing). To try the testing branch, please proceed like that. ``` -sudo yunohost app install https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing --debug +sudo yunohost app install https://github.com/YunoHost-Apps/onlyoffice_ynh/tree/testing --debug or -sudo yunohost app upgrade REPLACEBYYOURAPP -u https://github.com/YunoHost-Apps/REPLACEBYYOURAPP_ynh/tree/testing --debug +sudo yunohost app upgrade onlyoffice -u https://github.com/YunoHost-Apps/onlyoffice_ynh/tree/testing --debug ``` From 2d4d91395c3f6b68ceb64e4ca03ff32d38e72d9a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 12:11:38 +0100 Subject: [PATCH 18/88] remove rm -rf --- scripts/remove | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 4a65fd2..84e03e1 100644 --- a/scripts/remove +++ b/scripts/remove @@ -52,7 +52,6 @@ ynh_print_info "Removing app main directory" # Remove the app directory securely ynh_secure_remove "$final_path" -rm -rf "$final_path" #================================================= # REMOVE NGINX CONFIGURATION From 0406c5020737dd06608159779295afe1b86a61b4 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 18:23:23 +0100 Subject: [PATCH 19/88] Fix install step --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index a8cbd9c..9b40bb8 100644 --- a/scripts/install +++ b/scripts/install @@ -173,7 +173,7 @@ ynh_package_install onlyoffice-documentserver #================================================= # Fix https://github.com/ONLYOFFICE/onlyoffice-owncloud/issues/172#issuecomment-411746394 -cp -a ../conf/default.json /etc/onlyoffice/documentserver/default.json +cp -f ../conf/default.json /etc/onlyoffice/documentserver/default.json #================================================= # STORE THE CONFIG FILE CHECKSUM From d778307c1956950f31dba39e4acc71f90aa38e02 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 18:33:54 +0100 Subject: [PATCH 20/88] Fix check_process --- check_process | 9 +++------ scripts/install | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/check_process b/check_process index ed2844f..721161c 100644 --- a/check_process +++ b/check_process @@ -6,24 +6,21 @@ ;; Test complet ; Manifest domain="domain.tld" (DOMAIN) - path="/" (PATH) + nextclouddomain="domain.tld" is_public=1 (PUBLIC|public=1|private=0) -# password="pass" -# nextclouddomain="domain.tld" - port="9980" (PORT) ; Checks pkg_linter=1 setup_sub_dir=0 setup_root=1 setup_nourl=0 - setup_private=0 + setup_private=1 setup_public=1 upgrade=1 backup_restore=1 multi_instance=1 incorrect_path=1 port_already_use=0 - change_url=0 + change_url=1 ;;; Levels Level 1=auto Level 2=auto diff --git a/scripts/install b/scripts/install index 9b40bb8..01c4a3c 100644 --- a/scripts/install +++ b/scripts/install @@ -166,7 +166,7 @@ ynh_package_update # INSTALL ONLYOFFICE #================================================= -ynh_package_install onlyoffice-documentserver +ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server onlyoffice-documentserver #================================================= # MODIFY A CONFIG FILE From f3dc151dba6b829d92d4175d935c1699f4d3a34d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 18:44:13 +0100 Subject: [PATCH 21/88] Add install comments --- scripts/install | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/install b/scripts/install index 01c4a3c..3e98f25 100644 --- a/scripts/install +++ b/scripts/install @@ -151,12 +151,14 @@ ynh_system_user_create $app $final_path #================================================= # DEFINE PORT #================================================= +ynh_print_info "Define OnlyOffice server port..." echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections #================================================= # ADD ONLYOFFICE REPOSITORY #================================================= +ynh_print_info "Add OnlyOffice repository..." apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list @@ -165,12 +167,14 @@ ynh_package_update #================================================= # INSTALL ONLYOFFICE #================================================= +ynh_print_info "Install OnlyOffice..." ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server onlyoffice-documentserver #================================================= # MODIFY A CONFIG FILE #================================================= +ynh_print_info "Fix config file..." # Fix https://github.com/ONLYOFFICE/onlyoffice-owncloud/issues/172#issuecomment-411746394 cp -f ../conf/default.json /etc/onlyoffice/documentserver/default.json From 5e3e306a8ffd40553e5dd85f55be847a8c1f0c6e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 18:59:36 +0100 Subject: [PATCH 22/88] Fix final_path --- scripts/install | 13 +++++++++++++ scripts/remove | 3 +-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 3e98f25..43c3add 100644 --- a/scripts/install +++ b/scripts/install @@ -128,6 +128,19 @@ ynh_app_setting_set $app db_pwd $db_pwd ynh_psql_test_if_first_run ynh_psql_create_db $db_name $db_name $db_pwd +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_print_info "Setting up source files..." + +### `ynh_setup_source` is used to install an app from a zip or tar.gz file, +### downloaded from an upstream source, like a git repository. +### `ynh_setup_source` use the file conf/app.src + +ynh_app_setting_set $app final_path $final_path +# Download, check integrity, uncompress and patch the source from app.src +#ynh_setup_source "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= diff --git a/scripts/remove b/scripts/remove index 84e03e1..446c83a 100644 --- a/scripts/remove +++ b/scripts/remove @@ -41,9 +41,8 @@ ynh_psql_remove_db $db_name $db_name ynh_print_info "Removing dependencies" # Remove metapackage and its dependencies -ynh_package_remove onlyoffice-documentserver -ynh_package_remove nodejs ynh_remove_app_dependencies +ynh_package_remove nodejs #================================================= # REMOVE APP MAIN DIR From 40e2c06f5f24da637b7fc286bbac6f8f7b35d867 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 19:23:11 +0100 Subject: [PATCH 23/88] Fixes --- manifest.json | 9 ++++----- scripts/install | 9 ++++----- scripts/remove | 3 --- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/manifest.json b/manifest.json index 8ad8c89..477abb1 100644 --- a/manifest.json +++ b/manifest.json @@ -21,7 +21,8 @@ "nginx" ], "arguments": { - "install": [{ + "install" : [ + { "name": "domain", "type": "domain", "ask": { @@ -29,8 +30,7 @@ "fr": "Choisissez un nom de domaine pour OnlyOffice" }, "example": "example.com" - }, - + }, { "name": "nextclouddomain", "type": "string", @@ -40,8 +40,7 @@ }, "example": "example.com", "default": "example.com" - }, - + }, { "name": "is_public", "type": "boolean", diff --git a/scripts/install b/scripts/install index 43c3add..670195b 100644 --- a/scripts/install +++ b/scripts/install @@ -25,7 +25,6 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -# Retrieve arguments domain=$YNH_APP_ARG_DOMAIN path_url="/" is_public=$YNH_APP_ARG_IS_PUBLIC @@ -65,9 +64,9 @@ ynh_webpath_register $app $domain $path_url ynh_print_info "Storing installation settings..." ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app nextclouddomain $nextclouddomain ynh_app_setting_set $app path $path_url ynh_app_setting_set $app is_public $is_public +ynh_app_setting_set $app nextclouddomain $nextclouddomain #================================================= # STANDARD MODIFICATIONS @@ -82,7 +81,7 @@ ynh_print_info "Configuring firewall..." ### - Remove the section "CLOSE A PORT" in the remove script # Find a free port -port=$(ynh_find_port 9980) +port=$(ynh_find_port 8095) # Open this port #ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port ynh_app_setting_set $app port $port @@ -190,7 +189,7 @@ ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server ynh_print_info "Fix config file..." # Fix https://github.com/ONLYOFFICE/onlyoffice-owncloud/issues/172#issuecomment-411746394 -cp -f ../conf/default.json /etc/onlyoffice/documentserver/default.json +#cp -f ../conf/default.json /etc/onlyoffice/documentserver/default.json #================================================= # STORE THE CONFIG FILE CHECKSUM @@ -215,7 +214,7 @@ cp -f ../conf/default.json /etc/onlyoffice/documentserver/default.json ### that really need such authorization. # Set permissions to app files -chown -R $app: $final_path +#chown -R $app: $final_path #================================================= # SETUP SSOWAT diff --git a/scripts/remove b/scripts/remove index 446c83a..4ae53fe 100644 --- a/scripts/remove +++ b/scripts/remove @@ -31,8 +31,6 @@ final_path=$(ynh_app_setting_get $app final_path) ynh_print_info "Removing the PostgreSQL database" # Remove a database if it exists, along with the associated user -ynh_psql_execute_as_root "\connect $db_name -SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$db_name';" ynh_psql_remove_db $db_name $db_name #================================================= @@ -93,7 +91,6 @@ ynh_secure_remove "/var/log/$app/" ynh_print_info "Removing the dedicated system user" # Delete a system user -gpasswd -d www-data onlyoffice ynh_system_user_delete $app #================================================= From 570b8a27d2075b6d5263d3a0a262b6a2df5851f5 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 19:37:32 +0100 Subject: [PATCH 24/88] Fix upgrade --- scripts/install | 3 ++- scripts/remove | 3 ++- scripts/upgrade | 18 ++++++++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index 670195b..2a29de9 100644 --- a/scripts/install +++ b/scripts/install @@ -103,6 +103,7 @@ ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server #================================================= # INSTALL NODEJS #================================================= +ynh_print_info "Installing nodejs..." curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - @@ -181,7 +182,7 @@ ynh_package_update #================================================= ynh_print_info "Install OnlyOffice..." -ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server onlyoffice-documentserver +ynh_package_install onlyoffice-documentserver #================================================= # MODIFY A CONFIG FILE diff --git a/scripts/remove b/scripts/remove index 4ae53fe..d479203 100644 --- a/scripts/remove +++ b/scripts/remove @@ -39,8 +39,9 @@ ynh_psql_remove_db $db_name $db_name ynh_print_info "Removing dependencies" # Remove metapackage and its dependencies -ynh_remove_app_dependencies +ynh_package_remove onlyoffice-documentserver ynh_package_remove nodejs +ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR diff --git a/scripts/upgrade b/scripts/upgrade index 094104a..383d979 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -77,14 +77,28 @@ path_url=$(ynh_normalize_url_path $path_url) ynh_print_info "Upgrading nginx web server configuration..." # Create a dedicated nginx config -ynh_add_nginx_config +ynh_add_nginx_config "nextclouddomain" #================================================= # UPGRADE DEPENDENCIES #================================================= ynh_print_info "Upgrading dependencies..." -ynh_install_app_dependencies deb1 deb2 +ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server + +#================================================= +# UPGRADE NODEJS +#================================================= +ynh_print_info "Upgrading nodejs..." + +curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - + +#================================================= +# UPGRADE ONLYOFFICE +#================================================= +ynh_print_info "Upgrading OnlyOffice..." + +ynh_package_install onlyoffice-documentserver #================================================= # CREATE DEDICATED USER From e738b63ed15e836b0e53b2305dc63aee6d568b47 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 19:50:27 +0100 Subject: [PATCH 25/88] Fix group removal --- scripts/remove | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/remove b/scripts/remove index d479203..ee71d4d 100644 --- a/scripts/remove +++ b/scripts/remove @@ -92,6 +92,7 @@ ynh_secure_remove "/var/log/$app/" ynh_print_info "Removing the dedicated system user" # Delete a system user +gpasswd -d www-data onlyoffice ynh_system_user_delete $app #================================================= From 9f257fbd179296b8f1b18cb549bceb0249f4812c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 20:02:12 +0100 Subject: [PATCH 26/88] Remove nodejs install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 2a29de9..8e95ab9 100644 --- a/scripts/install +++ b/scripts/install @@ -105,7 +105,7 @@ ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server #================================================= ynh_print_info "Installing nodejs..." -curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - +#curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - #================================================= # CREATE A POSTGRESQL DATABASE From ef2ca80d36d53669cae256fe6d8c3ce00a6e9c98 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 20:11:40 +0100 Subject: [PATCH 27/88] Change order for dependencies --- scripts/install | 69 +++++++++++++++++++++++-------------------------- scripts/remove | 2 ++ scripts/upgrade | 9 +------ 3 files changed, 36 insertions(+), 44 deletions(-) diff --git a/scripts/install b/scripts/install index 8e95ab9..7464cdf 100644 --- a/scripts/install +++ b/scripts/install @@ -87,25 +87,19 @@ port=$(ynh_find_port 8095) ynh_app_setting_set $app port $port #================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_print_info "Installing dependencies..." - -### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. -### Those deb packages will be installed as dependencies of this package. -### If you're not using this helper: -### - Remove the section "REMOVE DEPENDENCIES" in the remove script -### - As well as the section "REINSTALL DEPENDENCIES" in the restore script -### - And the section "UPGRADE DEPENDENCIES" in the upgrade script - -ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server - -#================================================= -# INSTALL NODEJS +# ADD NODEJS REPOSITORY #================================================= ynh_print_info "Installing nodejs..." -#curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - +curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - + +#================================================= +# ADD ONLYOFFICE REPOSITORY +#================================================= +ynh_print_info "Add OnlyOffice repository..." + +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 +echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list #================================================= # CREATE A POSTGRESQL DATABASE @@ -121,6 +115,7 @@ ynh_print_info "Creating a PostgreSQL database..." ### - Remove also the section "REMOVE THE POSTGRESQL DATABASE" in the remove script ### - As well as the section "RESTORE THE POSTGRESQL DATABASE" in the restore script +ynh_package_install postgresql db_name=$(ynh_sanitize_dbid $app) db_pwd="onlyoffice" ynh_app_setting_set $app db_name $db_name @@ -128,6 +123,27 @@ ynh_app_setting_set $app db_pwd $db_pwd ynh_psql_test_if_first_run ynh_psql_create_db $db_name $db_name $db_pwd +#================================================= +# DEFINE PORT +#================================================= +ynh_print_info "Define OnlyOffice server port..." + +echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections + +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_print_info "Installing dependencies..." + +### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. +### Those deb packages will be installed as dependencies of this package. +### If you're not using this helper: +### - Remove the section "REMOVE DEPENDENCIES" in the remove script +### - As well as the section "REINSTALL DEPENDENCIES" in the restore script +### - And the section "UPGRADE DEPENDENCIES" in the upgrade script + +ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server onlyoffice-documentserver + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -162,27 +178,8 @@ ynh_system_user_create $app $final_path #================================================= # SPECIFIC SETUP #================================================= -# DEFINE PORT +# ... #================================================= -ynh_print_info "Define OnlyOffice server port..." - -echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections - -#================================================= -# ADD ONLYOFFICE REPOSITORY -#================================================= -ynh_print_info "Add OnlyOffice repository..." - -apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 -echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list -ynh_package_update - -#================================================= -# INSTALL ONLYOFFICE -#================================================= -ynh_print_info "Install OnlyOffice..." - -ynh_package_install onlyoffice-documentserver #================================================= # MODIFY A CONFIG FILE diff --git a/scripts/remove b/scripts/remove index ee71d4d..17aea17 100644 --- a/scripts/remove +++ b/scripts/remove @@ -80,6 +80,8 @@ fi # Remove a directory securely ynh_secure_remove "/etc/apt/sources.list.d/onlyoffice.list" +ynh_secure_remove "/etc/apt/sources.list.d/onlyoffice.list" +ynh_secure_remove "/etc/apt/sources.list.d/nodesource.list" # Remove the log files ynh_secure_remove "/var/log/$app/" diff --git a/scripts/upgrade b/scripts/upgrade index 383d979..ef272bf 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -84,14 +84,7 @@ ynh_add_nginx_config "nextclouddomain" #================================================= ynh_print_info "Upgrading dependencies..." -ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server - -#================================================= -# UPGRADE NODEJS -#================================================= -ynh_print_info "Upgrading nodejs..." - -curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - +ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server nodejs #================================================= # UPGRADE ONLYOFFICE From 4f7df0c1b310d8cb010c526f0e0d3c4f6f1125cb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 20:18:42 +0100 Subject: [PATCH 28/88] Fix removal dependencies --- scripts/install | 6 ++++++ scripts/remove | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 7464cdf..d708a64 100644 --- a/scripts/install +++ b/scripts/install @@ -232,6 +232,12 @@ fi ynh_print_info "Reloading nginx web server..." systemctl reload nginx + +#================================================= +# RELOAD ONLYOFFICE +#================================================= +ynh_print_info "Reloading OnlyOffice..." + supervisorctl stop all supervisorctl start all diff --git a/scripts/remove b/scripts/remove index 17aea17..e4325f1 100644 --- a/scripts/remove +++ b/scripts/remove @@ -39,8 +39,6 @@ ynh_psql_remove_db $db_name $db_name ynh_print_info "Removing dependencies" # Remove metapackage and its dependencies -ynh_package_remove onlyoffice-documentserver -ynh_package_remove nodejs ynh_remove_app_dependencies #================================================= @@ -80,7 +78,6 @@ fi # Remove a directory securely ynh_secure_remove "/etc/apt/sources.list.d/onlyoffice.list" -ynh_secure_remove "/etc/apt/sources.list.d/onlyoffice.list" ynh_secure_remove "/etc/apt/sources.list.d/nodesource.list" # Remove the log files From 85c6b30e399216d70b71d9699a38336fad72d3ac Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 20:23:30 +0100 Subject: [PATCH 29/88] Fix scripts/restore --- scripts/restore | 40 +++++++++++++++++++++------------------- scripts/upgrade | 19 ++++++++++--------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/scripts/restore b/scripts/restore index 76668a7..46931f0 100644 --- a/scripts/restore +++ b/scripts/restore @@ -76,49 +76,45 @@ chown -R $app: $final_path #================================================= # SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_print_info "Reinstalling dependencies..." - -# Define and install dependencies -ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server - -#================================================= -# INSTALL NODEJS -#================================================= - -curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - - #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= ynh_print_info "Restoring the PostgreSQL database..." +ynh_package_install postgresql ynh_psql_test_if_first_run ynh_psql_create_db $db_name $db_name $db_pwd ynh_psql_execute_file_as_root ./db.sql "$db_name" #================================================= -# DEFINE PORT +# ADD NODEJS REPOSITORY #================================================= +ynh_print_info "Installing nodejs..." -echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections +curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - #================================================= # ADD ONLYOFFICE REPOSITORY #================================================= +ynh_print_info "Add OnlyOffice repository..." apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list -ynh_package_update #================================================= -# INSTALL ONLYOFFICE +# DEFINE PORT #================================================= +ynh_print_info "Define OnlyOffice server port..." -ynh_package_install onlyoffice-documentserver +echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_print_info "Reinstalling dependencies..." + +# Define and install dependencies +ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server onlyoffice-documentserver #================================================= # GENERIC FINALIZATION @@ -128,6 +124,12 @@ ynh_package_install onlyoffice-documentserver ynh_print_info "Reloading nginx web server..." systemctl reload nginx + +#================================================= +# RELOAD ONLYOFFICE +#================================================= +ynh_print_info "Reloading OnlyOffice..." + supervisorctl stop all supervisorctl start all diff --git a/scripts/upgrade b/scripts/upgrade index ef272bf..23c9ee9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -84,14 +84,7 @@ ynh_add_nginx_config "nextclouddomain" #================================================= ynh_print_info "Upgrading dependencies..." -ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server nodejs - -#================================================= -# UPGRADE ONLYOFFICE -#================================================= -ynh_print_info "Upgrading OnlyOffice..." - -ynh_package_install onlyoffice-documentserver +ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server onlyoffice-documentserver #================================================= # CREATE DEDICATED USER @@ -121,7 +114,7 @@ ynh_system_user_create $app #================================================= # Set permissions on app files -chown -R root: $final_path +#chown -R root: $final_path #================================================= # SETUP SSOWAT @@ -142,6 +135,14 @@ ynh_print_info "Reloading nginx web server..." systemctl reload nginx +#================================================= +# RELOAD ONLYOFFICE +#================================================= +ynh_print_info "Reloading OnlyOffice..." + +supervisorctl stop all +supervisorctl start all + #================================================= # END OF SCRIPT #================================================= From 6dea3eef06ba8c5f73bd1ae634b813ae6fb079ea Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 20:40:50 +0100 Subject: [PATCH 30/88] fix nginx configuration --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index d9826db..20260cf 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -6,7 +6,7 @@ location ^~ __PATH__/ { proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; - add_header X-Frame-Options "ALLOW-FROM https://__NEXTCLOUDDOMAIN__/"; + add_header X-Frame-Options "ALLOW-FROM https://__NEXTCLOUDDOMAIN__" always; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; From be96fcd7fc90a33df2e25d87f52107e425e46adb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 21:54:26 +0100 Subject: [PATCH 31/88] Fix removal --- scripts/remove | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/remove b/scripts/remove index e4325f1..a4ce2ac 100644 --- a/scripts/remove +++ b/scripts/remove @@ -24,6 +24,11 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= # STANDARD REMOVE #================================================= +# STOP ONLYOFFICE +#================================================= +ynh_print_info "Stopping OnlyOffice" + +supervisorctl stop all #================================================= # REMOVE THE POSTGRESQL DATABASE @@ -79,6 +84,9 @@ fi # Remove a directory securely ynh_secure_remove "/etc/apt/sources.list.d/onlyoffice.list" ynh_secure_remove "/etc/apt/sources.list.d/nodesource.list" +ynh_secure_remove "/etc/onlyoffice" +ynh_secure_remove "/var/lib/onlyoffice" +ynh_secure_remove "/var/cache/nginx/onlyoffice" # Remove the log files ynh_secure_remove "/var/log/$app/" From f0b937e57a03e94d1c40e7a5c825ce022e42f58b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 22:19:33 +0100 Subject: [PATCH 32/88] Fix removal --- scripts/remove | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/remove b/scripts/remove index a4ce2ac..9666871 100644 --- a/scripts/remove +++ b/scripts/remove @@ -29,6 +29,7 @@ final_path=$(ynh_app_setting_get $app final_path) ynh_print_info "Stopping OnlyOffice" supervisorctl stop all +service rabbitmq-server stop #================================================= # REMOVE THE POSTGRESQL DATABASE From a3c3a2d124d2a213373d8f4614904a11f7572c7b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 23:02:08 +0100 Subject: [PATCH 33/88] Fix removal --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 9666871..2ad8f7b 100644 --- a/scripts/remove +++ b/scripts/remove @@ -29,7 +29,7 @@ final_path=$(ynh_app_setting_get $app final_path) ynh_print_info "Stopping OnlyOffice" supervisorctl stop all -service rabbitmq-server stop +killall node #================================================= # REMOVE THE POSTGRESQL DATABASE From 46ee12f252eb346e4e0c543d076fc1104c1f40f1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 23:14:34 +0100 Subject: [PATCH 34/88] Fix removal --- scripts/install | 2 +- scripts/remove | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index d708a64..9ecddf7 100644 --- a/scripts/install +++ b/scripts/install @@ -89,7 +89,7 @@ ynh_app_setting_set $app port $port #================================================= # ADD NODEJS REPOSITORY #================================================= -ynh_print_info "Installing nodejs..." +ynh_print_info "Add nodejs repository..." curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - diff --git a/scripts/remove b/scripts/remove index 2ad8f7b..d79a8cb 100644 --- a/scripts/remove +++ b/scripts/remove @@ -29,7 +29,6 @@ final_path=$(ynh_app_setting_get $app final_path) ynh_print_info "Stopping OnlyOffice" supervisorctl stop all -killall node #================================================= # REMOVE THE POSTGRESQL DATABASE @@ -45,6 +44,7 @@ ynh_psql_remove_db $db_name $db_name ynh_print_info "Removing dependencies" # Remove metapackage and its dependencies +killall node ynh_remove_app_dependencies #================================================= From e450e0b28c3618434994ddc412baefff8ae4e500 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 23:21:10 +0100 Subject: [PATCH 35/88] Fix removal --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index d79a8cb..baf7fcb 100644 --- a/scripts/remove +++ b/scripts/remove @@ -44,7 +44,7 @@ ynh_psql_remove_db $db_name $db_name ynh_print_info "Removing dependencies" # Remove metapackage and its dependencies -killall node +ynh_secure_remove /var/lib/dpkg/info/onlyoffice-documentserver-ie.postrm ynh_remove_app_dependencies #================================================= From e130e97b683e40d7a6ec44b77ef4d54aecd6cc65 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 Feb 2019 23:26:58 +0100 Subject: [PATCH 36/88] Fix removal --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index baf7fcb..c828032 100644 --- a/scripts/remove +++ b/scripts/remove @@ -44,7 +44,7 @@ ynh_psql_remove_db $db_name $db_name ynh_print_info "Removing dependencies" # Remove metapackage and its dependencies -ynh_secure_remove /var/lib/dpkg/info/onlyoffice-documentserver-ie.postrm +ynh_secure_remove /var/lib/dpkg/info/onlyoffice-documentserver.prerm ynh_remove_app_dependencies #================================================= From e6782be82fdc90188cf40871950576eac15e50d6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 01:30:47 +0100 Subject: [PATCH 37/88] add subdir --- manifest.json | 12 +++++++++++- scripts/install | 2 +- scripts/remove | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 477abb1..fd17f2f 100644 --- a/manifest.json +++ b/manifest.json @@ -30,7 +30,17 @@ "fr": "Choisissez un nom de domaine pour OnlyOffice" }, "example": "example.com" - }, + }, + { + "name": "path", + "type": "path", + "ask": { + "en": "Choose a path for OnlyOffice", + "fr": "Choisissez un chemin pour OnlyOffice" + }, + "example": "/onlyoffice", + "default": "/onlyoffice" + }, { "name": "nextclouddomain", "type": "string", diff --git a/scripts/install b/scripts/install index 9ecddf7..13f5be6 100644 --- a/scripts/install +++ b/scripts/install @@ -26,7 +26,7 @@ ynh_abort_if_errors #================================================= domain=$YNH_APP_ARG_DOMAIN -path_url="/" +path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC nextclouddomain=$YNH_APP_ARG_NEXTCLOUDDOMAIN diff --git a/scripts/remove b/scripts/remove index c828032..3485d9c 100644 --- a/scripts/remove +++ b/scripts/remove @@ -44,6 +44,7 @@ ynh_psql_remove_db $db_name $db_name ynh_print_info "Removing dependencies" # Remove metapackage and its dependencies +documentserver-prepare4shutdown.sh ynh_secure_remove /var/lib/dpkg/info/onlyoffice-documentserver.prerm ynh_remove_app_dependencies From 55ea5a900058a1adfe8f4bd5ef0fa40d0c6eb1e9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 02:37:58 +0100 Subject: [PATCH 38/88] Fix installation in a sub_path --- conf/nginx.conf | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 20260cf..f5b58b8 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,14 +1,13 @@ location ^~ __PATH__/ { proxy_pass http://127.0.0.1:__PORT__; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $proxy_connection; + proxy_set_header X-Forwarded-Host $server_name__PATH__; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Host $server_name; add_header X-Frame-Options "ALLOW-FROM https://__NEXTCLOUDDOMAIN__" always; - - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; } \ No newline at end of file From 9f4b3eca57977cf6ede23094c62c88a0d2059032 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 03:17:55 +0100 Subject: [PATCH 39/88] Fix sub_path --- conf/nginx.conf | 2 +- scripts/install | 6 ++++++ scripts/upgrade | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index f5b58b8..a299dba 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -3,7 +3,7 @@ location ^~ __PATH__/ { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $proxy_connection; - proxy_set_header X-Forwarded-Host $server_name__PATH__; + proxy_set_header X-Forwarded-Host $server_name__SUB_PATH__; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_redirect off; diff --git a/scripts/install b/scripts/install index 13f5be6..b8d2765 100644 --- a/scripts/install +++ b/scripts/install @@ -163,6 +163,12 @@ ynh_app_setting_set $app final_path $final_path ynh_print_info "Configuring nginx web server..." ### `ynh_add_nginx_config` will use the file conf/nginx.conf +if [ $path = "/" ] +then + ynh_replace_string "__SUB_PATH__" "" "..conf/nginx.conf" +else + ynh_replace_string "__SUB_PATH__" "$path" "..conf/nginx.conf" +fi # Create a dedicated nginx config ynh_add_nginx_config "nextclouddomain" diff --git a/scripts/upgrade b/scripts/upgrade index 23c9ee9..cfe71cf 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -77,6 +77,12 @@ path_url=$(ynh_normalize_url_path $path_url) ynh_print_info "Upgrading nginx web server configuration..." # Create a dedicated nginx config +if [ $path = "/" ] +then + ynh_replace_string "__SUB_PATH__" "" "..conf/nginx.conf" +else + ynh_replace_string "__SUB_PATH__" "$path" "..conf/nginx.conf" +fi ynh_add_nginx_config "nextclouddomain" #================================================= From 0fdfa5510c62f34f3705177d8ca792974b447dd0 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 03:32:04 +0100 Subject: [PATCH 40/88] Fix If --- scripts/install | 3 +-- scripts/upgrade | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index b8d2765..2c0a215 100644 --- a/scripts/install +++ b/scripts/install @@ -163,8 +163,7 @@ ynh_app_setting_set $app final_path $final_path ynh_print_info "Configuring nginx web server..." ### `ynh_add_nginx_config` will use the file conf/nginx.conf -if [ $path = "/" ] -then +if [ $path = "/" ]; then ynh_replace_string "__SUB_PATH__" "" "..conf/nginx.conf" else ynh_replace_string "__SUB_PATH__" "$path" "..conf/nginx.conf" diff --git a/scripts/upgrade b/scripts/upgrade index cfe71cf..c79b405 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -77,8 +77,7 @@ path_url=$(ynh_normalize_url_path $path_url) ynh_print_info "Upgrading nginx web server configuration..." # Create a dedicated nginx config -if [ $path = "/" ] -then +if [ $path = "/" ]; then ynh_replace_string "__SUB_PATH__" "" "..conf/nginx.conf" else ynh_replace_string "__SUB_PATH__" "$path" "..conf/nginx.conf" From b19ae35fc27de201b71ef166245406bc83314962 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 03:37:41 +0100 Subject: [PATCH 41/88] Fix path_url --- scripts/install | 2 +- scripts/upgrade | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 2c0a215..006fd75 100644 --- a/scripts/install +++ b/scripts/install @@ -163,7 +163,7 @@ ynh_app_setting_set $app final_path $final_path ynh_print_info "Configuring nginx web server..." ### `ynh_add_nginx_config` will use the file conf/nginx.conf -if [ $path = "/" ]; then +if [ $path_url = "/" ]; then ynh_replace_string "__SUB_PATH__" "" "..conf/nginx.conf" else ynh_replace_string "__SUB_PATH__" "$path" "..conf/nginx.conf" diff --git a/scripts/upgrade b/scripts/upgrade index c79b405..2882934 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -77,7 +77,8 @@ path_url=$(ynh_normalize_url_path $path_url) ynh_print_info "Upgrading nginx web server configuration..." # Create a dedicated nginx config -if [ $path = "/" ]; then +if [ $path_url = "/" ] +then ynh_replace_string "__SUB_PATH__" "" "..conf/nginx.conf" else ynh_replace_string "__SUB_PATH__" "$path" "..conf/nginx.conf" From 19e6b5a1a1f71630fc930ae2a588011a187aa603 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 03:43:37 +0100 Subject: [PATCH 42/88] Fix nginx path --- scripts/install | 4 ++-- scripts/upgrade | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index 006fd75..2e3a46c 100644 --- a/scripts/install +++ b/scripts/install @@ -164,9 +164,9 @@ ynh_print_info "Configuring nginx web server..." ### `ynh_add_nginx_config` will use the file conf/nginx.conf if [ $path_url = "/" ]; then - ynh_replace_string "__SUB_PATH__" "" "..conf/nginx.conf" + ynh_replace_string "__SUB_PATH__" "" "../conf/nginx.conf" else - ynh_replace_string "__SUB_PATH__" "$path" "..conf/nginx.conf" + ynh_replace_string "__SUB_PATH__" "$path" "../conf/nginx.conf" fi # Create a dedicated nginx config diff --git a/scripts/upgrade b/scripts/upgrade index 2882934..b6ad897 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -79,9 +79,9 @@ ynh_print_info "Upgrading nginx web server configuration..." # Create a dedicated nginx config if [ $path_url = "/" ] then - ynh_replace_string "__SUB_PATH__" "" "..conf/nginx.conf" + ynh_replace_string "__SUB_PATH__" "" "../conf/nginx.conf" else - ynh_replace_string "__SUB_PATH__" "$path" "..conf/nginx.conf" + ynh_replace_string "__SUB_PATH__" "$path" "../conf/nginx.conf" fi ynh_add_nginx_config "nextclouddomain" From 89b13986d5776d4505d1bfe14dca0e9c1ed819e2 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 04:15:30 +0100 Subject: [PATCH 43/88] Fix path_url --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 2e3a46c..e1210ca 100644 --- a/scripts/install +++ b/scripts/install @@ -166,7 +166,7 @@ ynh_print_info "Configuring nginx web server..." if [ $path_url = "/" ]; then ynh_replace_string "__SUB_PATH__" "" "../conf/nginx.conf" else - ynh_replace_string "__SUB_PATH__" "$path" "../conf/nginx.conf" + ynh_replace_string "__SUB_PATH__" "$path_url" "../conf/nginx.conf" fi # Create a dedicated nginx config diff --git a/scripts/upgrade b/scripts/upgrade index b6ad897..2a0a4d9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -81,7 +81,7 @@ if [ $path_url = "/" ] then ynh_replace_string "__SUB_PATH__" "" "../conf/nginx.conf" else - ynh_replace_string "__SUB_PATH__" "$path" "../conf/nginx.conf" + ynh_replace_string "__SUB_PATH__" "$path_url" "../conf/nginx.conf" fi ynh_add_nginx_config "nextclouddomain" From 8ccf728417ae8f01d556c0599bd84e0052d5492d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 05:07:36 +0100 Subject: [PATCH 44/88] Fix nginx --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index a299dba..b38c6d0 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,5 +1,5 @@ location ^~ __PATH__/ { - proxy_pass http://127.0.0.1:__PORT__; + proxy_pass http://127.0.0.1:__PORT__/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $proxy_connection; From 0d6d2cc424cb7ad4e2f7881aeb64506b21f11f6e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 18:22:55 +0100 Subject: [PATCH 45/88] add ynh_systemd_action --- scripts/install | 4 ++-- scripts/remove | 3 ++- scripts/restore | 4 ++-- scripts/upgrade | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/install b/scripts/install index e1210ca..f6ff792 100644 --- a/scripts/install +++ b/scripts/install @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_systemd_action source /usr/share/yunohost/helpers #================================================= @@ -243,8 +244,7 @@ systemctl reload nginx #================================================= ynh_print_info "Reloading OnlyOffice..." -supervisorctl stop all -supervisorctl start all +ynh_systemd_action --service_name=supervisor --action=restart --line_match="INFO success: docservice entered RUNNING state" --log_path="systemd" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 3485d9c..54afadd 100644 --- a/scripts/remove +++ b/scripts/remove @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_systemd_action source /usr/share/yunohost/helpers #================================================= @@ -28,7 +29,7 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= ynh_print_info "Stopping OnlyOffice" -supervisorctl stop all +ynh_systemd_action --service_name=supervisor --action=stop --log_path="systemd" #================================================= # REMOVE THE POSTGRESQL DATABASE diff --git a/scripts/restore b/scripts/restore index 46931f0..e584af3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -7,6 +7,7 @@ #================================================= source ../settings/scripts/_common.sh +source ../settings/scripts/ynh_systemd_action source /usr/share/yunohost/helpers #================================================= @@ -130,8 +131,7 @@ systemctl reload nginx #================================================= ynh_print_info "Reloading OnlyOffice..." -supervisorctl stop all -supervisorctl start all +ynh_systemd_action --service_name=supervisor --action=restart --line_match="INFO success: docservice entered RUNNING state" --log_path="systemd" #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index 2a0a4d9..5ea385d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,6 +7,7 @@ #================================================= source _common.sh +source ynh_systemd_action source /usr/share/yunohost/helpers #================================================= @@ -146,8 +147,7 @@ systemctl reload nginx #================================================= ynh_print_info "Reloading OnlyOffice..." -supervisorctl stop all -supervisorctl start all +ynh_systemd_action --service_name=supervisor --action=restart --line_match="INFO success: docservice entered RUNNING state" --log_path="systemd" #================================================= # END OF SCRIPT From 2059fb3f8015b9f50cea83cf59a192e65b52fac0 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 18:30:14 +0100 Subject: [PATCH 46/88] last example_ynh --- scripts/backup | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/backup b/scripts/backup index cae426f..6c30480 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,6 +6,7 @@ # IMPORT GENERIC 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 From 66c0cf548d26e330f155f170897f8da2eafea143 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 18:37:46 +0100 Subject: [PATCH 47/88] add ynh_systemd_action --- scripts/ynh_systemd_action | 89 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 scripts/ynh_systemd_action diff --git a/scripts/ynh_systemd_action b/scripts/ynh_systemd_action new file mode 100644 index 0000000..6bed6be --- /dev/null +++ b/scripts/ynh_systemd_action @@ -0,0 +1,89 @@ +#!/bin/bash + +# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started +# +# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ] +# | arg: -n, --service_name= - Name of the service to reload. Default : $app +# | arg: -a, --action= - Action to perform with systemctl. Default: start +# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. +# If not defined it don't wait until the service is completely started. +# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log +# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds. +# | arg: -e, --length= - Length of the error log : Default : 20 +ynh_systemd_action() { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= ) + local service_name + local action + local line_match + local length + local log_path + local timeout + + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + local service_name="${service_name:-$app}" + local action=${action:-start} + local log_path="${log_path:-/var/log/$service_name/$service_name.log}" + local length=${length:-20} + local timeout=${timeout:-300} + + # Start to read the log + if [[ -n "${line_match:-}" ]] + then + local templog="$(mktemp)" + # Following the starting of the app in its log + if [ "$log_path" == "systemd" ] ; then + # Read the systemd journal + journalctl -u $service_name -f --since=-45 > "$templog" & + else + # Read the specified log file + tail -F -n0 "$log_path" > "$templog" & + fi + # Get the PID of the tail command + local pid_tail=$! + fi + + echo "${action^} the service $service_name" >&2 + systemctl $action $service_name \ + || ( journalctl --lines=$length -u $service_name >&2 \ + ; test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \ + ; false ) + + # Start the timeout and try to find line_match + if [[ -n "${line_match:-}" ]] + then + local i=0 + for i in $(seq 1 $timeout) + do + # Read the log until the sentence is found, that means the app finished to start. Or run until the timeout + if grep --quiet "$line_match" "$templog" + then + echo "The service $service_name has correctly started." >&2 + break + fi + echo -n "." >&2 + sleep 1 + done + if [ $i -eq $timeout ] + then + echo "The service $service_name didn't fully started before the timeout." >&2 + journalctl --lines=$length -u $service_name >&2 + test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 + fi + + echo "" + ynh_clean_check_starting + fi +} + +# Clean temporary process and file used by ynh_check_starting +# (usually used in ynh_clean_setup scripts) +# +# usage: ynh_clean_check_starting +ynh_clean_check_starting () { + # Stop the execution of tail. + kill -s 15 $pid_tail 2>&1 + ynh_secure_remove "$templog" 2>&1 +} From b43c3e6f5c2d1430ae00f60547618fb411e55e1a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 19:44:09 +0100 Subject: [PATCH 48/88] Fix X-Frame --- scripts/install | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/install b/scripts/install index f6ff792..dfc729c 100644 --- a/scripts/install +++ b/scripts/install @@ -173,6 +173,9 @@ fi # Create a dedicated nginx config ynh_add_nginx_config "nextclouddomain" +# Fix main domain X-Frame-Options +ynh_replace_string "X-Frame-Options : SAMEORIGIN" "X-Frame-Options : ALLOW-FROM https://$nextclouddomain" "/etc/nginx/conf.d/$domain.conf" + #================================================= # CREATE DEDICATED USER #================================================= @@ -246,6 +249,8 @@ ynh_print_info "Reloading OnlyOffice..." ynh_systemd_action --service_name=supervisor --action=restart --line_match="INFO success: docservice entered RUNNING state" --log_path="systemd" +sleep 10 + #================================================= # END OF SCRIPT #================================================= From f484ed6930ada974cac4dfe3b7b88a34086c94ca Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 19:48:29 +0100 Subject: [PATCH 49/88] Add sleep --- scripts/restore | 2 ++ scripts/upgrade | 2 ++ 2 files changed, 4 insertions(+) diff --git a/scripts/restore b/scripts/restore index e584af3..cf61e9f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -133,6 +133,8 @@ ynh_print_info "Reloading OnlyOffice..." ynh_systemd_action --service_name=supervisor --action=restart --line_match="INFO success: docservice entered RUNNING state" --log_path="systemd" +sleep 10 + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 5ea385d..5a73fd1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -149,6 +149,8 @@ ynh_print_info "Reloading OnlyOffice..." ynh_systemd_action --service_name=supervisor --action=restart --line_match="INFO success: docservice entered RUNNING state" --log_path="systemd" +sleep 10 + #================================================= # END OF SCRIPT #================================================= From 2f37994b4b6ac8f1d3088ba0c15692baea7e535f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 20:05:30 +0100 Subject: [PATCH 50/88] Fix dependencies --- scripts/install | 55 ++++++++++++++++++++++++++----------------------- scripts/remove | 10 +++++++-- scripts/restore | 39 ++++++++++++++++++++++------------- scripts/upgrade | 10 +++++++-- 4 files changed, 70 insertions(+), 44 deletions(-) diff --git a/scripts/install b/scripts/install index dfc729c..c510bec 100644 --- a/scripts/install +++ b/scripts/install @@ -95,12 +95,18 @@ ynh_print_info "Add nodejs repository..." curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - #================================================= -# ADD ONLYOFFICE REPOSITORY +# INSTALL DEPENDENCIES #================================================= -ynh_print_info "Add OnlyOffice repository..." +ynh_print_info "Installing dependencies..." -apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 -echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list +### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. +### Those deb packages will be installed as dependencies of this package. +### If you're not using this helper: +### - Remove the section "REMOVE DEPENDENCIES" in the remove script +### - As well as the section "REINSTALL DEPENDENCIES" in the restore script +### - And the section "UPGRADE DEPENDENCIES" in the upgrade script + +ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server #================================================= # CREATE A POSTGRESQL DATABASE @@ -124,27 +130,6 @@ ynh_app_setting_set $app db_pwd $db_pwd ynh_psql_test_if_first_run ynh_psql_create_db $db_name $db_name $db_pwd -#================================================= -# DEFINE PORT -#================================================= -ynh_print_info "Define OnlyOffice server port..." - -echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections - -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_print_info "Installing dependencies..." - -### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. -### Those deb packages will be installed as dependencies of this package. -### If you're not using this helper: -### - Remove the section "REMOVE DEPENDENCIES" in the remove script -### - As well as the section "REINSTALL DEPENDENCIES" in the restore script -### - And the section "UPGRADE DEPENDENCIES" in the upgrade script - -ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server onlyoffice-documentserver - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -187,8 +172,26 @@ ynh_system_user_create $app $final_path #================================================= # SPECIFIC SETUP #================================================= -# ... +# DEFINE PORT #================================================= +ynh_print_info "Define OnlyOffice server port..." + +echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections + +#================================================= +# ADD ONLYOFFICE REPOSITORY +#================================================= +ynh_print_info "Add OnlyOffice repository..." + +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 +echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list + +#================================================= +# INSTALL ONLYOFFICE +#================================================= +ynh_print_info "Install OnlyOffice..." + +ynh_package_install onlyoffice-documentserver #================================================= # MODIFY A CONFIG FILE diff --git a/scripts/remove b/scripts/remove index 54afadd..50aa37e 100644 --- a/scripts/remove +++ b/scripts/remove @@ -39,14 +39,20 @@ ynh_print_info "Removing the PostgreSQL database" # Remove a database if it exists, along with the associated user ynh_psql_remove_db $db_name $db_name +#================================================= +# REMOVE ONLYOFFICE +#================================================= +ynh_print_info "Removing OnlyOffice" + +ynh_secure_remove /var/lib/dpkg/info/onlyoffice-documentserver.prerm +ynh_package_autoremove onlyoffice-documentserver + #================================================= # REMOVE DEPENDENCIES #================================================= ynh_print_info "Removing dependencies" # Remove metapackage and its dependencies -documentserver-prepare4shutdown.sh -ynh_secure_remove /var/lib/dpkg/info/onlyoffice-documentserver.prerm ynh_remove_app_dependencies #================================================= diff --git a/scripts/restore b/scripts/restore index cf61e9f..4b3d418 100644 --- a/scripts/restore +++ b/scripts/restore @@ -34,6 +34,7 @@ final_path=$(ynh_app_setting_get $app final_path) db_name=$(ynh_app_setting_get $app db_name) db_pwd=$(ynh_app_setting_get $app db_pwd) port=$(ynh_app_setting_get $app port) +nextclouddomain=$(ynh_app_setting_get $app nextclouddomain) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -53,6 +54,9 @@ test ! -d $final_path \ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" +# Fix main domain X-Frame-Options +ynh_replace_string "X-Frame-Options : SAMEORIGIN" "X-Frame-Options : ALLOW-FROM https://$nextclouddomain" "/etc/nginx/conf.d/$domain.conf" + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -77,6 +81,21 @@ chown -R $app: $final_path #================================================= # SPECIFIC RESTORATION +#================================================= +# ADD NODEJS REPOSITORY +#================================================= +ynh_print_info "Add nodejs repository..." + +curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - + +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_print_info "Reinstalling dependencies..." + +# Define and install dependencies +ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server + #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= @@ -88,11 +107,11 @@ ynh_psql_create_db $db_name $db_name $db_pwd ynh_psql_execute_file_as_root ./db.sql "$db_name" #================================================= -# ADD NODEJS REPOSITORY +# DEFINE PORT #================================================= -ynh_print_info "Installing nodejs..." +ynh_print_info "Define OnlyOffice server port..." -curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - +echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections #================================================= # ADD ONLYOFFICE REPOSITORY @@ -103,19 +122,11 @@ apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list #================================================= -# DEFINE PORT +# REINSTALL ONLYOFFICE #================================================= -ynh_print_info "Define OnlyOffice server port..." +ynh_print_info "Reinstalling OnlyOffice..." -echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections - -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_print_info "Reinstalling dependencies..." - -# Define and install dependencies -ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server onlyoffice-documentserver +ynh_package_install onlyoffice-documentserver #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 5a73fd1..23ef060 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -86,12 +86,15 @@ else fi ynh_add_nginx_config "nextclouddomain" +# Fix main domain X-Frame-Options +ynh_replace_string "X-Frame-Options : SAMEORIGIN" "X-Frame-Options : ALLOW-FROM https://$nextclouddomain" "/etc/nginx/conf.d/$domain.conf" + #================================================= # UPGRADE DEPENDENCIES #================================================= ynh_print_info "Upgrading dependencies..." -ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server onlyoffice-documentserver +ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server #================================================= # CREATE DEDICATED USER @@ -104,8 +107,11 @@ ynh_system_user_create $app #================================================= # SPECIFIC UPGRADE #================================================= -# ... +# UPGRADE ONLYOFFICE #================================================= +ynh_print_info "Upgrading OnlyOffice..." + +ynh_package_install onlyoffice-documentserver ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. From 1fc80dd007280f23520ca9a5c31115fd24980913 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 20:09:18 +0100 Subject: [PATCH 51/88] add autopurge --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 50aa37e..a80e3f6 100644 --- a/scripts/remove +++ b/scripts/remove @@ -45,7 +45,7 @@ ynh_psql_remove_db $db_name $db_name ynh_print_info "Removing OnlyOffice" ynh_secure_remove /var/lib/dpkg/info/onlyoffice-documentserver.prerm -ynh_package_autoremove onlyoffice-documentserver +ynh_package_autopurge onlyoffice-documentserver #================================================= # REMOVE DEPENDENCIES From 3e3cc1583cef975a4c3b90b3e8d8a6b512eb0d15 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 20:15:40 +0100 Subject: [PATCH 52/88] Fix nginx --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index b38c6d0..ff0c108 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -9,5 +9,5 @@ location ^~ __PATH__/ { proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; - add_header X-Frame-Options "ALLOW-FROM https://__NEXTCLOUDDOMAIN__" always; + add_header X-Frame-Options "ALLOW-FROM https://__NEXTCLOUDDOMAIN__"; } \ No newline at end of file From acc3255c7e04179f34034647295d6a2bd9dfd835 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 20:20:14 +0100 Subject: [PATCH 53/88] Fix nginx --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index ff0c108..b81566c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,7 +2,7 @@ location ^~ __PATH__/ { proxy_pass http://127.0.0.1:__PORT__/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $proxy_connection; + #proxy_set_header Connection $proxy_connection; proxy_set_header X-Forwarded-Host $server_name__SUB_PATH__; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; From 70b48b7878a02e09331699f4dc4271e23516c650 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 20:25:08 +0100 Subject: [PATCH 54/88] Fix package update --- scripts/install | 2 ++ scripts/restore | 2 ++ 2 files changed, 4 insertions(+) diff --git a/scripts/install b/scripts/install index c510bec..7cd34b1 100644 --- a/scripts/install +++ b/scripts/install @@ -93,6 +93,7 @@ ynh_app_setting_set $app port $port ynh_print_info "Add nodejs repository..." curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - +ynh_package_update #================================================= # INSTALL DEPENDENCIES @@ -185,6 +186,7 @@ ynh_print_info "Add OnlyOffice repository..." apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list +ynh_package_update #================================================= # INSTALL ONLYOFFICE diff --git a/scripts/restore b/scripts/restore index 4b3d418..d6508b3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -87,6 +87,7 @@ chown -R $app: $final_path ynh_print_info "Add nodejs repository..." curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - +ynh_package_update #================================================= # REINSTALL DEPENDENCIES @@ -120,6 +121,7 @@ ynh_print_info "Add OnlyOffice repository..." apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list +ynh_package_update #================================================= # REINSTALL ONLYOFFICE From 832d43d1e7275dc4852a7d2c26fb4e6ec954ac31 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 20:38:31 +0100 Subject: [PATCH 55/88] remove ynh_package_install postgresql --- scripts/install | 19 ++++++++----------- scripts/restore | 19 ++++++++----------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/scripts/install b/scripts/install index 7cd34b1..89b7b88 100644 --- a/scripts/install +++ b/scripts/install @@ -93,7 +93,14 @@ ynh_app_setting_set $app port $port ynh_print_info "Add nodejs repository..." curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - -ynh_package_update + +#================================================= +# ADD ONLYOFFICE REPOSITORY +#================================================= +ynh_print_info "Add OnlyOffice repository..." + +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 +echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list #================================================= # INSTALL DEPENDENCIES @@ -123,7 +130,6 @@ ynh_print_info "Creating a PostgreSQL database..." ### - Remove also the section "REMOVE THE POSTGRESQL DATABASE" in the remove script ### - As well as the section "RESTORE THE POSTGRESQL DATABASE" in the restore script -ynh_package_install postgresql db_name=$(ynh_sanitize_dbid $app) db_pwd="onlyoffice" ynh_app_setting_set $app db_name $db_name @@ -179,15 +185,6 @@ ynh_print_info "Define OnlyOffice server port..." echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections -#================================================= -# ADD ONLYOFFICE REPOSITORY -#================================================= -ynh_print_info "Add OnlyOffice repository..." - -apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 -echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list -ynh_package_update - #================================================= # INSTALL ONLYOFFICE #================================================= diff --git a/scripts/restore b/scripts/restore index d6508b3..92ed69a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -87,7 +87,14 @@ chown -R $app: $final_path ynh_print_info "Add nodejs repository..." curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - -ynh_package_update + +#================================================= +# ADD ONLYOFFICE REPOSITORY +#================================================= +ynh_print_info "Add OnlyOffice repository..." + +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 +echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list #================================================= # REINSTALL DEPENDENCIES @@ -102,7 +109,6 @@ ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server #================================================= ynh_print_info "Restoring the PostgreSQL database..." -ynh_package_install postgresql ynh_psql_test_if_first_run ynh_psql_create_db $db_name $db_name $db_pwd ynh_psql_execute_file_as_root ./db.sql "$db_name" @@ -114,15 +120,6 @@ ynh_print_info "Define OnlyOffice server port..." echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf-set-selections -#================================================= -# ADD ONLYOFFICE REPOSITORY -#================================================= -ynh_print_info "Add OnlyOffice repository..." - -apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 -echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list -ynh_package_update - #================================================= # REINSTALL ONLYOFFICE #================================================= From 16963b154b0015678a487c320baae617c2a92788 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 20:40:32 +0100 Subject: [PATCH 56/88] Fix nginx.conf --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index b81566c..ff0c108 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,7 +2,7 @@ location ^~ __PATH__/ { proxy_pass http://127.0.0.1:__PORT__/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; - #proxy_set_header Connection $proxy_connection; + proxy_set_header Connection $proxy_connection; proxy_set_header X-Forwarded-Host $server_name__SUB_PATH__; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; From 93c7b5f99b1cc70f21e9f114fe0b909b41b65d5d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 20:45:32 +0100 Subject: [PATCH 57/88] Fix nginx.conf --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index ff0c108..b81566c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,7 +2,7 @@ location ^~ __PATH__/ { proxy_pass http://127.0.0.1:__PORT__/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $proxy_connection; + #proxy_set_header Connection $proxy_connection; proxy_set_header X-Forwarded-Host $server_name__SUB_PATH__; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; From c5b85010699eee92474b26fff36cd5d96936a47a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 20:58:13 +0100 Subject: [PATCH 58/88] Fix service reload --- scripts/install | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 89b7b88..e5040f7 100644 --- a/scripts/install +++ b/scripts/install @@ -249,7 +249,9 @@ systemctl reload nginx #================================================= ynh_print_info "Reloading OnlyOffice..." -ynh_systemd_action --service_name=supervisor --action=restart --line_match="INFO success: docservice entered RUNNING state" --log_path="systemd" +supervisorctl stop all +supervisorctl start all +#ynh_systemd_action --service_name=supervisor --action=restart --line_match="INFO success: docservice entered RUNNING state" --log_path="systemd" sleep 10 From e83047513a7531c0b04ea7e3a3ea2fd108e7a957 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 21:07:42 +0100 Subject: [PATCH 59/88] Fix install --- conf/nginx.conf | 2 +- scripts/install | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index b81566c..ff0c108 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,7 +2,7 @@ location ^~ __PATH__/ { proxy_pass http://127.0.0.1:__PORT__/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; - #proxy_set_header Connection $proxy_connection; + proxy_set_header Connection $proxy_connection; proxy_set_header X-Forwarded-Host $server_name__SUB_PATH__; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; diff --git a/scripts/install b/scripts/install index e5040f7..0991ea1 100644 --- a/scripts/install +++ b/scripts/install @@ -166,7 +166,7 @@ fi ynh_add_nginx_config "nextclouddomain" # Fix main domain X-Frame-Options -ynh_replace_string "X-Frame-Options : SAMEORIGIN" "X-Frame-Options : ALLOW-FROM https://$nextclouddomain" "/etc/nginx/conf.d/$domain.conf" +#ynh_replace_string "X-Frame-Options : SAMEORIGIN" "X-Frame-Options : ALLOW-FROM https://$nextclouddomain" "/etc/nginx/conf.d/$domain.conf" #================================================= # CREATE DEDICATED USER From 66c2739a7d585dafe8e6a64f5a9cfb291ff22bf4 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 21:19:52 +0100 Subject: [PATCH 60/88] Fix nginx.conf --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index ff0c108..b38c6d0 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -9,5 +9,5 @@ location ^~ __PATH__/ { proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; - add_header X-Frame-Options "ALLOW-FROM https://__NEXTCLOUDDOMAIN__"; + add_header X-Frame-Options "ALLOW-FROM https://__NEXTCLOUDDOMAIN__" always; } \ No newline at end of file From 00eb6d4667352a1684c82946801fbf6d6a99f96a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 21:26:47 +0100 Subject: [PATCH 61/88] fix nginx.conf --- conf/nginx.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index b38c6d0..d225572 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -2,7 +2,8 @@ location ^~ __PATH__/ { proxy_pass http://127.0.0.1:__PORT__/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $proxy_connection; + #proxy_set_header Connection $proxy_connection; + proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-Host $server_name__SUB_PATH__; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; From 66f2758ad05ef6ca5140a8ec234bc4d511b7544e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 21:39:40 +0100 Subject: [PATCH 62/88] Fix remove --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index a80e3f6..50aa37e 100644 --- a/scripts/remove +++ b/scripts/remove @@ -45,7 +45,7 @@ ynh_psql_remove_db $db_name $db_name ynh_print_info "Removing OnlyOffice" ynh_secure_remove /var/lib/dpkg/info/onlyoffice-documentserver.prerm -ynh_package_autopurge onlyoffice-documentserver +ynh_package_autoremove onlyoffice-documentserver #================================================= # REMOVE DEPENDENCIES From 23decfca5a9f0921fd22a2cff0b764366ca40d25 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 21:42:11 +0100 Subject: [PATCH 63/88] Fix main domain --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 0991ea1..e5040f7 100644 --- a/scripts/install +++ b/scripts/install @@ -166,7 +166,7 @@ fi ynh_add_nginx_config "nextclouddomain" # Fix main domain X-Frame-Options -#ynh_replace_string "X-Frame-Options : SAMEORIGIN" "X-Frame-Options : ALLOW-FROM https://$nextclouddomain" "/etc/nginx/conf.d/$domain.conf" +ynh_replace_string "X-Frame-Options : SAMEORIGIN" "X-Frame-Options : ALLOW-FROM https://$nextclouddomain" "/etc/nginx/conf.d/$domain.conf" #================================================= # CREATE DEDICATED USER From 1f2fdd395f5aa245cf0c59f0c5faa4793f9d254c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 22:04:42 +0100 Subject: [PATCH 64/88] remove ynh_systemd_action --- scripts/install | 2 - scripts/remove | 3 +- scripts/restore | 4 +- scripts/upgrade | 4 +- scripts/ynh_systemd_action | 89 -------------------------------------- 5 files changed, 5 insertions(+), 97 deletions(-) delete mode 100644 scripts/ynh_systemd_action diff --git a/scripts/install b/scripts/install index e5040f7..21c3315 100644 --- a/scripts/install +++ b/scripts/install @@ -7,7 +7,6 @@ #================================================= source _common.sh -source ynh_systemd_action source /usr/share/yunohost/helpers #================================================= @@ -251,7 +250,6 @@ ynh_print_info "Reloading OnlyOffice..." supervisorctl stop all supervisorctl start all -#ynh_systemd_action --service_name=supervisor --action=restart --line_match="INFO success: docservice entered RUNNING state" --log_path="systemd" sleep 10 diff --git a/scripts/remove b/scripts/remove index 50aa37e..32ae68f 100644 --- a/scripts/remove +++ b/scripts/remove @@ -7,7 +7,6 @@ #================================================= source _common.sh -source ynh_systemd_action source /usr/share/yunohost/helpers #================================================= @@ -29,7 +28,7 @@ final_path=$(ynh_app_setting_get $app final_path) #================================================= ynh_print_info "Stopping OnlyOffice" -ynh_systemd_action --service_name=supervisor --action=stop --log_path="systemd" +supervisorctl stop all #================================================= # REMOVE THE POSTGRESQL DATABASE diff --git a/scripts/restore b/scripts/restore index 92ed69a..3ac286d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -7,7 +7,6 @@ #================================================= source ../settings/scripts/_common.sh -source ../settings/scripts/ynh_systemd_action source /usr/share/yunohost/helpers #================================================= @@ -141,7 +140,8 @@ systemctl reload nginx #================================================= ynh_print_info "Reloading OnlyOffice..." -ynh_systemd_action --service_name=supervisor --action=restart --line_match="INFO success: docservice entered RUNNING state" --log_path="systemd" +supervisorctl stop all +supervisorctl start all sleep 10 diff --git a/scripts/upgrade b/scripts/upgrade index 23ef060..f4e9810 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,7 +7,6 @@ #================================================= source _common.sh -source ynh_systemd_action source /usr/share/yunohost/helpers #================================================= @@ -153,7 +152,8 @@ systemctl reload nginx #================================================= ynh_print_info "Reloading OnlyOffice..." -ynh_systemd_action --service_name=supervisor --action=restart --line_match="INFO success: docservice entered RUNNING state" --log_path="systemd" +supervisorctl stop all +supervisorctl start all sleep 10 diff --git a/scripts/ynh_systemd_action b/scripts/ynh_systemd_action deleted file mode 100644 index 6bed6be..0000000 --- a/scripts/ynh_systemd_action +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash - -# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started -# -# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ] -# | arg: -n, --service_name= - Name of the service to reload. Default : $app -# | arg: -a, --action= - Action to perform with systemctl. Default: start -# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. -# If not defined it don't wait until the service is completely started. -# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log -# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds. -# | arg: -e, --length= - Length of the error log : Default : 20 -ynh_systemd_action() { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= ) - local service_name - local action - local line_match - local length - local log_path - local timeout - - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - local service_name="${service_name:-$app}" - local action=${action:-start} - local log_path="${log_path:-/var/log/$service_name/$service_name.log}" - local length=${length:-20} - local timeout=${timeout:-300} - - # Start to read the log - if [[ -n "${line_match:-}" ]] - then - local templog="$(mktemp)" - # Following the starting of the app in its log - if [ "$log_path" == "systemd" ] ; then - # Read the systemd journal - journalctl -u $service_name -f --since=-45 > "$templog" & - else - # Read the specified log file - tail -F -n0 "$log_path" > "$templog" & - fi - # Get the PID of the tail command - local pid_tail=$! - fi - - echo "${action^} the service $service_name" >&2 - systemctl $action $service_name \ - || ( journalctl --lines=$length -u $service_name >&2 \ - ; test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \ - ; false ) - - # Start the timeout and try to find line_match - if [[ -n "${line_match:-}" ]] - then - local i=0 - for i in $(seq 1 $timeout) - do - # Read the log until the sentence is found, that means the app finished to start. Or run until the timeout - if grep --quiet "$line_match" "$templog" - then - echo "The service $service_name has correctly started." >&2 - break - fi - echo -n "." >&2 - sleep 1 - done - if [ $i -eq $timeout ] - then - echo "The service $service_name didn't fully started before the timeout." >&2 - journalctl --lines=$length -u $service_name >&2 - test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 - fi - - echo "" - ynh_clean_check_starting - fi -} - -# Clean temporary process and file used by ynh_check_starting -# (usually used in ynh_clean_setup scripts) -# -# usage: ynh_clean_check_starting -ynh_clean_check_starting () { - # Stop the execution of tail. - kill -s 15 $pid_tail 2>&1 - ynh_secure_remove "$templog" 2>&1 -} From 255717689a71105b3a8e4bb1cb2a95f635a416ce Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 22:39:41 +0100 Subject: [PATCH 65/88] Fix restore --- scripts/install | 1 - scripts/restore | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 21c3315..0352c37 100644 --- a/scripts/install +++ b/scripts/install @@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers ynh_clean_setup () { ### Remove this function if there's nothing to clean before calling the remove script. - read -p "Press any key..." true } # Exit if an error occurs during the execution of the script diff --git a/scripts/restore b/scripts/restore index 3ac286d..13d02b4 100644 --- a/scripts/restore +++ b/scripts/restore @@ -15,6 +15,7 @@ source /usr/share/yunohost/helpers ynh_clean_setup () { #### Remove this function if there's nothing to clean before calling the remove script. + read -p "Press any key..." true } # Exit if an error occurs during the execution of the script From 913d44d5b781a6e460bff175e49360bdf1d72510 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 23:02:59 +0100 Subject: [PATCH 66/88] Fix restore --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 13d02b4..5e84b99 100644 --- a/scripts/restore +++ b/scripts/restore @@ -70,7 +70,7 @@ ynh_restore_file "$final_path" ynh_print_info "Recreating the dedicated system user..." # Create the dedicated user (if not existing) -ynh_system_user_create $app +ynh_system_user_create $app $final_path #================================================= # RESTORE USER RIGHTS From 64356e5e357e44963c6b9ffb3decbfc831370dae Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 23:13:03 +0100 Subject: [PATCH 67/88] Fix backup/restore of the configuration --- scripts/backup | 7 +++++++ scripts/restore | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/scripts/backup b/scripts/backup index 6c30480..ef4feed 100644 --- a/scripts/backup +++ b/scripts/backup @@ -55,6 +55,13 @@ ynh_print_info "Backing up the PostgreSQL database..." ynh_psql_dump_db "$db_name" > db.sql +#================================================= +# SPECIFIC BACKUP +#================================================= +ynh_print_info "Backing up the configuration..." + +ynh_backup "/etc/onlyoffice" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index 5e84b99..8345b3a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -81,6 +81,13 @@ chown -R $app: $final_path #================================================= # SPECIFIC RESTORATION +#================================================= +# RESTORE THE CONFIGURATION +#================================================= +ynh_print_info "Restoring the configuration..." + +ynh_restore_file "/etc/onlyoffice" + #================================================= # ADD NODEJS REPOSITORY #================================================= From 5f10ae8e2db96464e897791cf30216bbb10eadba Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 23:42:29 +0100 Subject: [PATCH 68/88] Fix upgrade --- scripts/upgrade | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index f4e9810..b542620 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -74,15 +74,16 @@ path_url=$(ynh_normalize_url_path $path_url) #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Upgrading nginx web server configuration..." +ynh_print_info "Configuring nginx web server..." -# Create a dedicated nginx config -if [ $path_url = "/" ] -then +### `ynh_add_nginx_config` will use the file conf/nginx.conf +if [ $path_url = "/" ]; then ynh_replace_string "__SUB_PATH__" "" "../conf/nginx.conf" else ynh_replace_string "__SUB_PATH__" "$path_url" "../conf/nginx.conf" fi + +# Create a dedicated nginx config ynh_add_nginx_config "nextclouddomain" # Fix main domain X-Frame-Options From 754b3aac5405bcf50bb5b58f86e5d4972eae0eee Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 23:45:12 +0100 Subject: [PATCH 69/88] Fix upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index b542620..08c1653 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -102,7 +102,7 @@ ynh_install_app_dependencies postgresql libstdc++6 redis-server rabbitmq-server ynh_print_info "Making sure dedicated system user exists..." # Create a dedicated user (if not existing) -ynh_system_user_create $app +ynh_system_user_create $app $final_path #================================================= # SPECIFIC UPGRADE From 5f5cc96d5c55649b257b8fb64285956b6beabc83 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 Feb 2019 23:52:12 +0100 Subject: [PATCH 70/88] Fix upgrade --- scripts/restore | 1 - scripts/upgrade | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 8345b3a..bfc5b50 100644 --- a/scripts/restore +++ b/scripts/restore @@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers ynh_clean_setup () { #### Remove this function if there's nothing to clean before calling the remove script. - read -p "Press any key..." true } # Exit if an error occurs during the execution of the script diff --git a/scripts/upgrade b/scripts/upgrade index 08c1653..516f780 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -57,6 +57,7 @@ ynh_print_info "Backing up the app before upgrading (may take a while)..." ynh_backup_before_upgrade ynh_clean_setup () { # restore it if the upgrade fails + read -p "Press any key..." ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script From 436fbb38939498c28ee88bca97fe49119cdda181 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 28 Feb 2019 00:20:45 +0100 Subject: [PATCH 71/88] fix upgrade --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index 516f780..85cf849 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,6 +20,7 @@ domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) is_public=$(ynh_app_setting_get $app is_public) db_name=$(ynh_app_setting_get $app db_name) +port=$(ynh_app_setting_get $app port) nextclouddomain=$(ynh_app_setting_get $app nextclouddomain) #================================================= From 000cd01a82c3aabd03e023f8413c4baf0d549e23 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 28 Feb 2019 01:19:45 +0100 Subject: [PATCH 72/88] Add sub_dir check_process --- check_process | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/check_process b/check_process index 721161c..820b35c 100644 --- a/check_process +++ b/check_process @@ -6,11 +6,12 @@ ;; Test complet ; Manifest domain="domain.tld" (DOMAIN) + path="/path" (PATH) nextclouddomain="domain.tld" is_public=1 (PUBLIC|public=1|private=0) ; Checks pkg_linter=1 - setup_sub_dir=0 + setup_sub_dir=1 setup_root=1 setup_nourl=0 setup_private=1 From f70a6a981ede3a6a658f27c71c86c8de6eaed18a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 28 Feb 2019 01:29:46 +0100 Subject: [PATCH 73/88] sleep 30 --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 0352c37..730e665 100644 --- a/scripts/install +++ b/scripts/install @@ -250,7 +250,7 @@ ynh_print_info "Reloading OnlyOffice..." supervisorctl stop all supervisorctl start all -sleep 10 +sleep 30 #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index bfc5b50..975413d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -150,7 +150,7 @@ ynh_print_info "Reloading OnlyOffice..." supervisorctl stop all supervisorctl start all -sleep 10 +sleep 30 #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index 85cf849..b153f64 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -158,7 +158,7 @@ ynh_print_info "Reloading OnlyOffice..." supervisorctl stop all supervisorctl start all -sleep 10 +sleep 30 #================================================= # END OF SCRIPT From 4e1d25f45d51f910907728579eb84b6743bc9d14 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 28 Feb 2019 15:30:24 +0100 Subject: [PATCH 74/88] Disable multi-instance check --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 820b35c..d012dbd 100644 --- a/check_process +++ b/check_process @@ -18,7 +18,7 @@ setup_public=1 upgrade=1 backup_restore=1 - multi_instance=1 + multi_instance=0 incorrect_path=1 port_already_use=0 change_url=1 From 7a8dfcaba52c7a024746050d2cfe9243ca9d7932 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 28 Feb 2019 22:38:27 +0100 Subject: [PATCH 75/88] add change_url --- scripts/change_url | 111 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 scripts/change_url diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..93a67da --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,111 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +old_domain=$YNH_APP_OLD_DOMAIN +old_path=$YNH_APP_OLD_PATH + +new_domain=$YNH_APP_NEW_DOMAIN +new_path=$YNH_APP_NEW_PATH + +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info "Loading installation settings..." + +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get $app final_path) + +# Add settings here as needed by your application +#db_name=$(ynh_app_setting_get "$app" db_name) +#db_pwd=$(ynh_app_setting_get $app db_pwd) + +#================================================= +# CHECK THE SYNTAX OF THE PATHS +#================================================= + +test -n "$old_path" || old_path="/" +test -n "$new_path" || new_path="/" +new_path=$(ynh_normalize_url_path $new_path) +old_path=$(ynh_normalize_url_path $old_path) + +#================================================= +# CHECK WHICH PARTS SHOULD BE CHANGED +#================================================= + +change_domain=0 +if [ "$old_domain" != "$new_domain" ] +then + change_domain=1 +fi + +change_path=0 +if [ "$old_path" != "$new_path" ] +then + change_path=1 +fi + +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_print_info "Updating nginx web server configuration..." + +nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf + +# Change the path in the nginx config file +if [ $change_path -eq 1 ] +then + # Make a backup of the original nginx config file if modified + ynh_backup_if_checksum_is_different "$nginx_conf_path" + # Set global variables for nginx helper + domain="$old_domain" + path_url="$new_path" + # Create a dedicated nginx config + ynh_add_nginx_config +fi + +# Change the domain for nginx +if [ $change_domain -eq 1 ] +then + # Delete file checksum for the old conf file location + ynh_delete_file_checksum "$nginx_conf_path" + mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf + # Store file checksum for the new config file location + ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" +fi + +#================================================= +# SPECIFIC MODIFICATIONS +#================================================= +# ... +#================================================= + +#================================================= +# GENERIC FINALISATION +#================================================= +# RELOAD NGINX +#================================================= +ynh_print_info "Reloading nginx web server..." + +systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Change of URL completed for $app" From 875b13bdaefeaa42681cdca2a3785c27b2c3e8e0 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 28 Feb 2019 22:44:25 +0100 Subject: [PATCH 76/88] Fix install --- scripts/install | 1 + scripts/upgrade | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 730e665..048ae97 100644 --- a/scripts/install +++ b/scripts/install @@ -15,6 +15,7 @@ source /usr/share/yunohost/helpers ynh_clean_setup () { ### Remove this function if there's nothing to clean before calling the remove script. + read -p "Press any key..." true } # Exit if an error occurs during the execution of the script diff --git a/scripts/upgrade b/scripts/upgrade index b153f64..3cc0254 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -58,7 +58,6 @@ ynh_print_info "Backing up the app before upgrading (may take a while)..." ynh_backup_before_upgrade ynh_clean_setup () { # restore it if the upgrade fails - read -p "Press any key..." ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script From efb73ed9104e131383bd3c78c5b12862799bbb95 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 28 Feb 2019 23:27:58 +0100 Subject: [PATCH 77/88] Fix removal --- scripts/remove | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/remove b/scripts/remove index 32ae68f..cfc5c66 100644 --- a/scripts/remove +++ b/scripts/remove @@ -30,14 +30,6 @@ ynh_print_info "Stopping OnlyOffice" supervisorctl stop all -#================================================= -# REMOVE THE POSTGRESQL DATABASE -#================================================= -ynh_print_info "Removing the PostgreSQL database" - -# Remove a database if it exists, along with the associated user -ynh_psql_remove_db $db_name $db_name - #================================================= # REMOVE ONLYOFFICE #================================================= @@ -46,6 +38,14 @@ ynh_print_info "Removing OnlyOffice" ynh_secure_remove /var/lib/dpkg/info/onlyoffice-documentserver.prerm ynh_package_autoremove onlyoffice-documentserver +#================================================= +# REMOVE THE POSTGRESQL DATABASE +#================================================= +ynh_print_info "Removing the PostgreSQL database" + +# Remove a database if it exists, along with the associated user +ynh_psql_remove_db $db_name $db_name + #================================================= # REMOVE DEPENDENCIES #================================================= From dda37ec528e6251a784599d796b797b5ee8a0803 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 28 Feb 2019 23:38:01 +0100 Subject: [PATCH 78/88] Fix removal --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index cfc5c66..44aa417 100644 --- a/scripts/remove +++ b/scripts/remove @@ -36,7 +36,7 @@ supervisorctl stop all ynh_print_info "Removing OnlyOffice" ynh_secure_remove /var/lib/dpkg/info/onlyoffice-documentserver.prerm -ynh_package_autoremove onlyoffice-documentserver +ynh_package_autopurge onlyoffice-documentserver #================================================= # REMOVE THE POSTGRESQL DATABASE From ca2353e2213eff4ce41ac75274200b43998edf24 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 1 Mar 2019 00:08:37 +0100 Subject: [PATCH 79/88] Fix change url --- scripts/change_url | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index 93a67da..42c27eb 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -28,6 +28,8 @@ ynh_print_info "Loading installation settings..." # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get $app final_path) +port=$(ynh_app_setting_get $app port) +nextclouddomain=$(ynh_app_setting_get $app nextclouddomain) # Add settings here as needed by your application #db_name=$(ynh_app_setting_get "$app" db_name) @@ -75,8 +77,16 @@ then # Set global variables for nginx helper domain="$old_domain" path_url="$new_path" + + ### `ynh_add_nginx_config` will use the file conf/nginx.conf + if [ $new_path = "/" ]; then + ynh_replace_string "__SUB_PATH__" "" "../conf/nginx.conf" + else + ynh_replace_string "__SUB_PATH__" "$new_path" "../conf/nginx.conf" + fi + # Create a dedicated nginx config - ynh_add_nginx_config + ynh_add_nginx_config "nextclouddomain" fi # Change the domain for nginx @@ -87,6 +97,8 @@ then mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" + ynh_replace_string "X-Frame-Options : ALLOW-FROM https://$nextclouddomain" "X-Frame-Options : SAMEORIGIN" "/etc/nginx/conf.d/$old_domain.conf" + ynh_replace_string "X-Frame-Options : SAMEORIGIN" "X-Frame-Options : ALLOW-FROM https://$nextclouddomain" "/etc/nginx/conf.d/$new_domain.conf" fi #================================================= From 6788f3dd5957d157e662726356f894af7a0264b2 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 1 Mar 2019 00:22:03 +0100 Subject: [PATCH 80/88] Cleanup --- conf/default.json | 244 ---------------------------- conf/fakenode-deps.control | 7 - conf/fakepostgres-deps.control | 7 - conf/onlyoffice-documentserver.conf | 70 -------- scripts/install | 7 +- 5 files changed, 4 insertions(+), 331 deletions(-) delete mode 100644 conf/default.json delete mode 100644 conf/fakenode-deps.control delete mode 100644 conf/fakepostgres-deps.control delete mode 100644 conf/onlyoffice-documentserver.conf diff --git a/conf/default.json b/conf/default.json deleted file mode 100644 index e02588f..0000000 --- a/conf/default.json +++ /dev/null @@ -1,244 +0,0 @@ -{ - "statsd": { - "useMetrics": false, - "host": "localhost", - "port": "8125", - "prefix": "ds." - }, - "log": { - "filePath": "", - "options": { - "reloadSecs": 60, - "replaceConsole": true - } - }, - "queue": { - "visibilityTimeout": 300, - "retentionPeriod": 900 - }, - "storage": { - "name": "storage-fs", - "fs": { - "folderPath": "", - "urlExpires": 900, - "secretString": "onlyoffice" - }, - "region": "", - "endpoint": "http://localhost/s3", - "bucketName": "cache", - "storageFolderName": "files", - "urlExpires": 604800, - "accessKeyId": "AKID", - "secretAccessKey": "SECRET", - "useRequestToGetUrl": false, - "useSignedUrl": false, - "externalHost": "" - }, - "rabbitmq": { - "url": "amqp://guest:guest@localhost:5672", - "socketOptions": {}, - "exchangepubsub": "ds.pubsub", - "queueconverttask": "ds.converttask", - "queueconvertresponse": "ds.convertresponse", - "exchangeconvertdead": "ds.exchangeconvertdead", - "queueconvertdead": "ds.convertdead" - }, - "dnscache": { - "enable" : true, - "ttl" : 300, - "cachesize" : 1000 - }, - "services": { - "CoAuthoring": { - "server": { - "port": 8000, - "workerpercpu": 1, - "mode": "development", - "limits_tempfile_upload": 104857600, - "limits_image_size": 26214400, - "limits_image_download_timeout": 120, - "callbackRequestTimeout": 120, - "healthcheckfilepath": "../public/healthcheck.docx", - "savetimeoutdelay": 5000, - "edit_singleton": false, - "forgottenfiles": "forgotten", - "forgottenfilesname": "output", - "maxRequestChanges": 20000, - "openProtectedFile": true - }, - "requestDefaults": { - "headers": { - "userAgent": "Node.js/6.13" - }, - "rejectUnauthorized": false - }, - "autoAssembly": { - "enable": false, - "interval": "5m", - "step": "1m" - }, - "utils": { - "utils_common_fontdir": "null", - "utils_fonts_search_patterns": "*.ttf;*.ttc;*.otf", - "resource_expires": 31536000, - "limits_image_types_upload": "jpg;png;gif;bmp" - }, - "sql": { - "type": "postgres", - "tableChanges": "doc_changes", - "tableResult": "task_result", - "dbHost": "localhost", - "dbPort": 5432, - "dbName": "onlyoffice", - "dbUser": "onlyoffice", - "dbPass": "onlyoffice", - "charset": "utf8", - "connectionlimit": 10, - "max_allowed_packet": 1048575 - }, - "redis": { - "name": "redis", - "prefix": "ds:", - "host": "localhost", - "port": 6379 - }, - "pubsub": { - "name": "pubsubRabbitMQ", - "maxChanges": 1000 - }, - "expire": { - "saveLock": 60, - "presence": 300, - "locks": 604800, - "changeindex": 86400, - "lockDoc": 30, - "message": 86400, - "lastsave": 604800, - "forcesave": 604800, - "saved": 3600, - "documentsCron": "0 */2 * * * *", - "files": 86400, - "filesCron": "00 00 */1 * * *", - "filesremovedatonce": 100, - "sessionidle": "0", - "sessionabsolute": "30d", - "sessionclosecommand": "2m", - "pemStdTTL": "1h", - "pemCheckPeriod": "10m", - "updateVersionStatus": "5m" - }, - "ipfilter": { - "rules": [{"address": "*", "allowed": true}], - "useforrequest": false, - "errorcode": 401 - }, - "secret": { - "browser": {"string": "secret", "file": "", "tenants": {}}, - "inbox": {"string": "secret", "file": "", "tenants": {}}, - "outbox": {"string": "secret", "file": ""}, - "session": {"string": "secret", "file": ""} - }, - "token": { - "enable": { - "browser": false, - "request": { - "inbox": false, - "outbox": true - } - }, - "browser": { - "secretFromInbox": true - }, - "inbox": { - "header": "Authorization", - "prefix": "Bearer ", - "inBody": false - }, - "outbox": { - "header": "Authorization", - "prefix": "Bearer ", - "algorithm": "HS256", - "expires": "5m", - "inBody": false - }, - "session": { - "algorithm": "HS256", - "expires": "30d" - } - }, - "plugins": { - "uri": "/sdkjs-plugins", - "autostart": [] - }, - "editor":{ - "spellcheckerUrl": "/spellchecker", - "reconnection":{ - "attempts": 50, - "delay": "2s" - } - }, - "sockjs": { - "sockjs_url": "", - "websocket": true - } - } - }, - "license" : { - "license_file": "", - "warning_limit_percents": "70" - }, - "FileConverter": { - "converter": { - "maxDownloadBytes": 104857600, - "downloadTimeout": 120, - "downloadAttemptMaxCount": 3, - "downloadAttemptDelay": 1000, - "maxprocesscount": 1, - "fontDir": "null", - "presentationThemesDir": "null", - "x2tPath": "null", - "docbuilderPath": "null", - "docbuilderAllFontsPath": "null", - "args": "", - "spawnOptions": {}, - "errorfiles": "", - "streamWriterBufferSize": 8388608, - "maxRedeliveredCount": 2, - "inputLimits": [ - { - "type": "docx;dotx;docm;dotm", - "zip": { - "uncompressed": "50MB", - "template": "*.xml" - } - }, - { - "type": "xlsx;xltx;xlsm;xltm", - "zip": { - "uncompressed": "300MB", - "template": "*.xml" - } - }, - { - "type": "pptx;ppsx;potx;pptm;ppsm;potm", - "zip": { - "uncompressed": "50MB", - "template": "*.xml" - } - } - ] - } - }, - "FileStorage": { - "host": "", - "port": 4567, - "directory": "", - "silent": true - }, - "SpellChecker": { - "server": { - "port": 8080, - "mode": "development" - } - } -} diff --git a/conf/fakenode-deps.control b/conf/fakenode-deps.control deleted file mode 100644 index d2e2a26..0000000 --- a/conf/fakenode-deps.control +++ /dev/null @@ -1,7 +0,0 @@ -Section: misc -Priority: optional -Package: nodejs -Version: 8.0.0 -Depends: -Architecture: all -Description: Fake package for nodejs \ No newline at end of file diff --git a/conf/fakepostgres-deps.control b/conf/fakepostgres-deps.control deleted file mode 100644 index 150e26f..0000000 --- a/conf/fakepostgres-deps.control +++ /dev/null @@ -1,7 +0,0 @@ -Section: misc -Priority: optional -Package: postgresql-client -Version: 9.1 -Depends: -Architecture: all -Description: Fake package for postgresql-client diff --git a/conf/onlyoffice-documentserver.conf b/conf/onlyoffice-documentserver.conf deleted file mode 100644 index 153d2f7..0000000 --- a/conf/onlyoffice-documentserver.conf +++ /dev/null @@ -1,70 +0,0 @@ -include /etc/nginx/includes/onlyoffice-http.conf; - -## Normal HTTP host -server { - listen 0.0.0.0:80; - listen [::]:80 default_server; - server_name _; - server_tokens off; - - ## Redirects all traffic to the HTTPS host - root /nowhere; ## root doesn't have to be a valid path since we are redirecting - rewrite ^ https://$host$request_uri? permanent; -} - -#HTTP host for internal services -server { - listen 127.0.0.1:80; - listen [::1]:80; - server_name localhost; - server_tokens off; - - include /etc/nginx/includes/onlyoffice-documentserver-common.conf; - include /etc/nginx/includes/onlyoffice-documentserver-docservice.conf; -} - -## HTTPS host -server { - listen 0.0.0.0:443 ssl; - listen [::]:443 ssl default_server; - server_tokens off; - root /usr/share/nginx/html; - - ## Strong SSL Security - ## https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html - ssl on; - ssl_certificate {{SSL_CERTIFICATE_PATH}}; - ssl_certificate_key {{SSL_KEY_PATH}}; - ssl_verify_client off; - - ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"; - - ssl_protocols TLSv1 TLSv1.1 TLSv1.2; - ssl_session_cache builtin:1000 shared:SSL:10m; - - ssl_prefer_server_ciphers on; - - add_header Strict-Transport-Security max-age=31536000; - # add_header X-Frame-Options SAMEORIGIN; - add_header X-Content-Type-Options nosniff; - - ## [Optional] If your certficate has OCSP, enable OCSP stapling to reduce the overhead and latency of running SSL. - ## Replace with your ssl_trusted_certificate. For more info see: - ## - https://medium.com/devops-programming/4445f4862461 - ## - https://www.ruby-forum.com/topic/4419319 - ## - https://www.digitalocean.com/community/tutorials/how-to-configure-ocsp-stapling-on-apache-and-nginx - # ssl_stapling on; - # ssl_stapling_verify on; - # ssl_trusted_certificate /etc/nginx/ssl/stapling.trusted.crt; - # resolver 208.67.222.222 208.67.222.220 valid=300s; # Can change to your DNS resolver if desired - # resolver_timeout 10s; - - ## [Optional] Generate a stronger DHE parameter: - ## cd /etc/ssl/certs - ## sudo openssl dhparam -out dhparam.pem 4096 - ## - # ssl_dhparam /etc/ssl/certs/dhparam.pem; - - include /etc/nginx/includes/onlyoffice-documentserver-*.conf; - -} diff --git a/scripts/install b/scripts/install index 048ae97..daead8f 100644 --- a/scripts/install +++ b/scripts/install @@ -194,10 +194,11 @@ ynh_package_install onlyoffice-documentserver #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_print_info "Fix config file..." -# Fix https://github.com/ONLYOFFICE/onlyoffice-owncloud/issues/172#issuecomment-411746394 -#cp -f ../conf/default.json /etc/onlyoffice/documentserver/default.json +### `ynh_replace_string` is used to replace a string in a file. +### (It's compatible with sed regular expressions syntax) + +#ynh_replace_string "match_string" "replace_string" "$final_path/CONFIG_FILE" #================================================= # STORE THE CONFIG FILE CHECKSUM From cbc5ff7178a44ca8f46ed93b4c70b21fcd9293ab Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 1 Mar 2019 11:04:49 +0100 Subject: [PATCH 81/88] Update README.md --- README.md | 35 ----------------------------------- scripts/install | 1 - 2 files changed, 36 deletions(-) diff --git a/README.md b/README.md index f3f4e35..cb4339f 100644 --- a/README.md +++ b/README.md @@ -9,49 +9,14 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to ## Overview OnlyOffice Document Server -**Shipped version:** 1.0 - -## Screenshots - -![](http://kaosenlared.net/wp-content/uploads/2016/10/onlyoffyce-2.jpg) - -## Demo - -* [Official demo](Link to a demo site for this app) - -## Configuration - -How to configure this app: by an admin panel, a plain file with SSH, or any other way. - -## Documentation - - * Official documentation: Link to the official documentation of this app - * YunoHost documentation: If specific documentation is needed, feel free to contribute. - ## YunoHost specific features -#### Multi-users support - -Are LDAP and HTTP auth supported? -Can the app be used by multiple users? - #### Supported architectures * x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/onlyoffice%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/onlyoffice/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/onlyoffice%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/onlyoffice/) * Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/onlyoffice%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/onlyoffice/) -## Limitations - -* Any known limitations. - -## Additional information - -* Other information you would add about this application - -**More information on the documentation page:** -https://yunohost.org/packaging_apps - ## Links * Report a bug: https://github.com/YunoHost-Apps/onlyoffice_ynh/issues diff --git a/scripts/install b/scripts/install index daead8f..d4d1009 100644 --- a/scripts/install +++ b/scripts/install @@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers ynh_clean_setup () { ### Remove this function if there's nothing to clean before calling the remove script. - read -p "Press any key..." true } # Exit if an error occurs during the execution of the script From 4c3d33fd691c83856ce372974931226e587a6d97 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 1 Mar 2019 11:27:32 +0100 Subject: [PATCH 82/88] Fix release --- README.md | 2 ++ manifest.json | 2 +- scripts/_common.sh | 2 ++ scripts/install | 11 ++--------- scripts/restore | 11 ++--------- scripts/upgrade | 3 ++- 6 files changed, 11 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index cb4339f..8a5aeab 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to ## Overview OnlyOffice Document Server +**Shipped version:** 5.2.8 + ## YunoHost specific features #### Supported architectures diff --git a/manifest.json b/manifest.json index fd17f2f..08763d2 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "OnlyOffice Document Server.", "fr": "Serveur de documents OnlyOffice." }, - "version": "1.0~ynh1", + "version": "5.2.8~ynh1", "url": "https://www.onlyoffice.com", "license": "GPL-3.0-or-later", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index b905339..252d16c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,6 +3,8 @@ #================================================= # PERSONAL HELPERS #================================================= +source="https://github.com/ONLYOFFICE/DocumentServer/releases/download/ONLYOFFICE-DocumentServer-5.2.8/onlyoffice-documentserver_amd64.deb" +version="5.2.8" #================================================= # EXPERIMENTAL HELPERS diff --git a/scripts/install b/scripts/install index d4d1009..46aba29 100644 --- a/scripts/install +++ b/scripts/install @@ -92,14 +92,6 @@ ynh_print_info "Add nodejs repository..." curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - -#================================================= -# ADD ONLYOFFICE REPOSITORY -#================================================= -ynh_print_info "Add OnlyOffice repository..." - -apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 -echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list - #================================================= # INSTALL DEPENDENCIES #================================================= @@ -188,7 +180,8 @@ echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf- #================================================= ynh_print_info "Install OnlyOffice..." -ynh_package_install onlyoffice-documentserver +wget $source +ynh_package_install onlyoffice-documentserver_amd64.deb #================================================= # MODIFY A CONFIG FILE diff --git a/scripts/restore b/scripts/restore index 975413d..caf8c67 100644 --- a/scripts/restore +++ b/scripts/restore @@ -94,14 +94,6 @@ ynh_print_info "Add nodejs repository..." curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - -#================================================= -# ADD ONLYOFFICE REPOSITORY -#================================================= -ynh_print_info "Add OnlyOffice repository..." - -apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 -echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list - #================================================= # REINSTALL DEPENDENCIES #================================================= @@ -131,7 +123,8 @@ echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf- #================================================= ynh_print_info "Reinstalling OnlyOffice..." -ynh_package_install onlyoffice-documentserver +wget $source +ynh_package_install onlyoffice-documentserver_amd64.deb #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 3cc0254..e467898 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -112,7 +112,8 @@ ynh_system_user_create $app $final_path #================================================= ynh_print_info "Upgrading OnlyOffice..." -ynh_package_install onlyoffice-documentserver +wget $source +ynh_package_install onlyoffice-documentserver_amd64.deb ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. From b7b11933cc62b7142542787fce3f91870006dfff Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 1 Mar 2019 11:32:49 +0100 Subject: [PATCH 83/88] Fix .deb install --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 46aba29..ad78653 100644 --- a/scripts/install +++ b/scripts/install @@ -181,7 +181,7 @@ echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf- ynh_print_info "Install OnlyOffice..." wget $source -ynh_package_install onlyoffice-documentserver_amd64.deb +dpkg -i onlyoffice-documentserver_amd64.deb #================================================= # MODIFY A CONFIG FILE diff --git a/scripts/restore b/scripts/restore index caf8c67..dc588a5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -124,7 +124,7 @@ echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf- ynh_print_info "Reinstalling OnlyOffice..." wget $source -ynh_package_install onlyoffice-documentserver_amd64.deb +dpkg -i onlyoffice-documentserver_amd64.deb #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index e467898..9995559 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -113,7 +113,7 @@ ynh_system_user_create $app $final_path ynh_print_info "Upgrading OnlyOffice..." wget $source -ynh_package_install onlyoffice-documentserver_amd64.deb +dpkg -i onlyoffice-documentserver_amd64.deb ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. From d7a43b92d084108a5bc3dd4bed1b7aed5ba84156 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 1 Mar 2019 11:39:31 +0100 Subject: [PATCH 84/88] Add documentserver repository --- scripts/install | 8 ++++++++ scripts/restore | 8 ++++++++ scripts/upgrade | 15 +++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/scripts/install b/scripts/install index ad78653..8bf82dd 100644 --- a/scripts/install +++ b/scripts/install @@ -92,6 +92,14 @@ ynh_print_info "Add nodejs repository..." curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - +#================================================= +# ADD ONLYOFFICE REPOSITORY +#================================================= +ynh_print_info "Add OnlyOffice repository..." + +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 +echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list + #================================================= # INSTALL DEPENDENCIES #================================================= diff --git a/scripts/restore b/scripts/restore index dc588a5..0b13ac4 100644 --- a/scripts/restore +++ b/scripts/restore @@ -94,6 +94,14 @@ ynh_print_info "Add nodejs repository..." curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - +#================================================= +# ADD ONLYOFFICE REPOSITORY +#================================================= +ynh_print_info "Add OnlyOffice repository..." + +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 +echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list + #================================================= # REINSTALL DEPENDENCIES #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 9995559..0fb2214 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -107,6 +107,21 @@ ynh_system_user_create $app $final_path #================================================= # SPECIFIC UPGRADE +#================================================= +# ADD NODEJS REPOSITORY +#================================================= +ynh_print_info "Add nodejs repository..." + +curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - + +#================================================= +# ADD ONLYOFFICE REPOSITORY +#================================================= +ynh_print_info "Add OnlyOffice repository..." + +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 +echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list + #================================================= # UPGRADE ONLYOFFICE #================================================= From 597d0a4147fc2c2d4c0d5e6f6f14e8870f0230ff Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 1 Mar 2019 12:04:31 +0100 Subject: [PATCH 85/88] fix install --- scripts/install | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install b/scripts/install index 8bf82dd..d3d39f0 100644 --- a/scripts/install +++ b/scripts/install @@ -100,6 +100,8 @@ ynh_print_info "Add OnlyOffice repository..." apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list +ynh_package_update + #================================================= # INSTALL DEPENDENCIES #================================================= From 0dc1c6aca8d676a170303acba148b7248d15b7e8 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 1 Mar 2019 12:16:39 +0100 Subject: [PATCH 86/88] Fix install --- scripts/install | 4 +--- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index d3d39f0..219826c 100644 --- a/scripts/install +++ b/scripts/install @@ -100,8 +100,6 @@ ynh_print_info "Add OnlyOffice repository..." apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list -ynh_package_update - #================================================= # INSTALL DEPENDENCIES #================================================= @@ -191,7 +189,7 @@ echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf- ynh_print_info "Install OnlyOffice..." wget $source -dpkg -i onlyoffice-documentserver_amd64.deb +apt install ./onlyoffice-documentserver_amd64.deb #================================================= # MODIFY A CONFIG FILE diff --git a/scripts/restore b/scripts/restore index 0b13ac4..6b4a36b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -132,7 +132,7 @@ echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf- ynh_print_info "Reinstalling OnlyOffice..." wget $source -dpkg -i onlyoffice-documentserver_amd64.deb +apt install ./onlyoffice-documentserver_amd64.deb #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 0fb2214..ac82c80 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -128,7 +128,7 @@ echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /e ynh_print_info "Upgrading OnlyOffice..." wget $source -dpkg -i onlyoffice-documentserver_amd64.deb +apt install ./onlyoffice-documentserver_amd64.deb ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. From 6a76112b8328ad871c258697b0b937148ddfe45d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 1 Mar 2019 12:22:49 +0100 Subject: [PATCH 87/88] Fix install --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 219826c..ce6f218 100644 --- a/scripts/install +++ b/scripts/install @@ -189,7 +189,7 @@ echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf- ynh_print_info "Install OnlyOffice..." wget $source -apt install ./onlyoffice-documentserver_amd64.deb +apt install -y ./onlyoffice-documentserver_amd64.deb #================================================= # MODIFY A CONFIG FILE diff --git a/scripts/restore b/scripts/restore index 6b4a36b..393921e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -132,7 +132,7 @@ echo onlyoffice-documentserver onlyoffice/ds-port select ${port} | sudo debconf- ynh_print_info "Reinstalling OnlyOffice..." wget $source -apt install ./onlyoffice-documentserver_amd64.deb +apt install -y ./onlyoffice-documentserver_amd64.deb #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index ac82c80..039ce11 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -128,7 +128,7 @@ echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /e ynh_print_info "Upgrading OnlyOffice..." wget $source -apt install ./onlyoffice-documentserver_amd64.deb +apt install -y ./onlyoffice-documentserver_amd64.deb ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. From 3504f7955a98bf8be24db6e5bd7d1ce62fbb32c2 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 4 Mar 2019 19:06:36 +0100 Subject: [PATCH 88/88] Adding test the upgrade from the old version to this new one --- check_process | 1 + 1 file changed, 1 insertion(+) diff --git a/check_process b/check_process index d012dbd..2dcee81 100644 --- a/check_process +++ b/check_process @@ -17,6 +17,7 @@ setup_private=1 setup_public=1 upgrade=1 + upgrade=1 from_commit=c7d09d7f15a01e85e0354561d737523e1cb18749 backup_restore=1 multi_instance=0 incorrect_path=1