1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/onlyoffice_ynh.git synced 2024-09-03 19:56:11 +02:00

Apply example_ynh

This commit is contained in:
yalh76 2019-02-25 19:45:11 +01:00
parent c7d09d7f15
commit 6474f21db6
9 changed files with 452 additions and 210 deletions

View file

@ -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 OnlyOffice Document Server
- [Yunohost project](https://yunohost.org) **Shipped version:** 1.0
- [OnlyOffice website](https://www.onlyoffice.com)
## Screenshots
![](http://kaosenlared.net/wp-content/uploads/2016/10/onlyoffyce-2.jpg) ![](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) ## Demo
[![Install OnlyOffice with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=onlyoffice)
### 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 #### Multi-users support
$ sudo yunohost app install --debug https://github.com/YunoHost-Apps/onlyoffice_ynh
2. Need to restart yunohost.
### Upgrade this package:
$ 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
```

View file

@ -28,9 +28,8 @@
Level 1=auto Level 1=auto
Level 2=auto Level 2=auto
Level 3=auto Level 3=auto
# Level 4: # Level 4: (This app supports the Nextcloud LDAP auth)
Level 4=1 (This app supports the Nextcloud LDAP auth) Level 4=1
# Level 5:
Level 5=auto Level 5=auto
Level 6=auto Level 6=auto
Level 7=auto Level 7=auto

View file

@ -3,23 +3,22 @@
"id": "onlyoffice", "id": "onlyoffice",
"packaging_format": 1, "packaging_format": 1,
"description": { "description": {
"en": "OnlyOffice package for YunoHost.", "en": "OnlyOffice Document Server.",
"fr": "OnlyOffice pour YunoHost." "fr": "Serveur de documents OnlyOffice."
}, },
"url": "https://www.plex.tv/", "version": "1.0~ynh1",
"license": "free", "url": "https://www.onlyoffice.com",
"license": "GPL-3.0-or-later",
"maintainer": { "maintainer": {
"name": "liberodark", "name": "liberodark",
"email": "liberodark@gmail.com" "email": "liberodark@gmail.com"
}, },
"requirements": { "requirements": {
"yunohost": ">= 2.7.2" "yunohost": ">= 3.4"
}, },
"multi_instance": false, "multi_instance": false,
"services": [ "services": [
"nginx", "nginx"
"php5-fpm",
"mysql"
], ],
"arguments": { "arguments": {
"install": [{ "install": [{
@ -42,26 +41,15 @@
"example": "example.com", "example": "example.com",
"default": "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", "name": "is_public",
"type": "boolean", "type": "boolean",
"ask": { "ask": {
"en": "Is it a public site ?", "en": "Is it a public application?",
"fr": "Est-ce un site public ?" "fr": "Est-ce une application publique ?"
}, },
"default": "true" "default": true
} }
] ]
} }

View file

@ -1 +1,13 @@
#!/bin/bash #!/bin/bash
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

View file

@ -1,34 +1,63 @@
#!/bin/bash #!/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 source ../settings/scripts/_common.sh
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Backup sources & data #=================================================
# Note: the last argument is where to save this path, see the restore script. # MANAGE SCRIPT FAILURE
ynh_backup "/var/www/${app}" "sources" #=================================================
### MySQL (remove if not used) ### ynh_clean_setup () {
# If a MySQL database is used: ### Remove this function if there's nothing to clean before calling the remove script.
# # Dump the database true
# dbname=$app }
# dbuser=$app # Exit if an error occurs during the execution of the script
# dbpass=$(ynh_app_setting_get "$app" mysqlpwd) ynh_abort_if_errors
# mysqldump -u "$dbuser" -p"$dbpass" --no-create-db "$dbname" > ./dump.sql
### MySQL end ###
# Copy NGINX configuration #=================================================
domain=$(ynh_app_setting_get "$app" domain) # LOAD SETTINGS
ynh_backup "/etc/nginx/conf.d/${domain}.d/${app}.conf" "nginx.conf" #=================================================
ynh_backup "/etc/onlyoffice/documentserver/default.json" ynh_print_info "Loading installation settings..."
### PHP (remove if not used) ### app=$YNH_APP_INSTANCE_NAME
# If a dedicated php-fpm process is used:
# # Copy PHP-FPM pool configuration final_path=$(ynh_app_setting_get $app final_path)
# ynh_backup "/etc/php5/fpm/pool.d/${app}.conf" "php-fpm.conf" domain=$(ynh_app_setting_get $app domain)
### PHP end ### 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)."

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
#source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -26,7 +26,7 @@ ynh_abort_if_errors
# Retrieve arguments # Retrieve arguments
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH path_url="/"
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
nextclouddomain=$YNH_APP_ARG_NEXTCLOUDDOMAIN nextclouddomain=$YNH_APP_ARG_NEXTCLOUDDOMAIN
@ -45,6 +45,7 @@ app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # 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 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" ### 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 # Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url) path_url=$(ynh_normalize_url_path $path_url)
# Check web path availability
ynh_webpath_available $domain $path_url
# Register (book) web path # Register (book) web path
ynh_webpath_register $app $domain $path_url ynh_webpath_register $app $domain $path_url
#================================================= #=================================================
# STORE SETTINGS FROM MANIFEST # STORE SETTINGS FROM MANIFEST
#================================================= #=================================================
ynh_print_info "Storing installation settings..."
ynh_app_setting_set $app domain $domain ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app nextclouddomain $nextclouddomain ynh_app_setting_set $app nextclouddomain $nextclouddomain
ynh_app_setting_set $app path $path_url ynh_app_setting_set $app path $path_url
ynh_app_setting_set $app is_public $is_public ynh_app_setting_set $app is_public $is_public
#=================================================
# STANDARD MODIFICATIONS
#================================================= #=================================================
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
ynh_print_info "Configuring firewall..."
### Use these lines if you have to open a port for the application ### 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. ### `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 # Find a free port
port=$(ynh_find_port 9980) port=$(ynh_find_port 9980)
# Open this port # 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 ynh_app_setting_set $app port $port
#============================================== #=================================================
# INSTALL POSTGRES # INSTALL DEPENDENCIES
#============================================== #=================================================
ynh_print_info "Installing dependencies..."
#Master ynh_install_app_dependencies postgresql libstdc redis-server rabbitmq-server
#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
#================================================= #=================================================
# INSTALL NODEJS # 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..."
#=============================================== ### Use these lines if you need a database for the application.
# ADD ONLYOFFCE REPOSITORY ### `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 db_name=$(ynh_sanitize_dbid $app)
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5 db_pwd=$(ynh_string_random 30)
echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list ynh_app_setting_set $app db_name $db_name
ynh_package_update 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
# 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
#================================================= #=================================================
# NGINX CONFIGURATION # 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 # Create a dedicated nginx config
ynh_add_nginx_config "nextclouddomain" ynh_add_nginx_config "nextclouddomain"
@ -154,11 +133,32 @@ ynh_add_nginx_config "nextclouddomain"
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Configuring system user..."
# Create a system user # Create a system user
ynh_system_user_create $app 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 # MODIFY A CONFIG FILE
#================================================= #=================================================
@ -200,13 +200,25 @@ cp -a ../conf/default.json /etc/onlyoffice/documentserver/default.json
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_print_info "Configuring SSOwat..."
# If app is public, add url to SSOWat conf as skipped_uris # Make app public if necessary
if [ $is_public -eq 1 ]; then if [ $is_public -eq 1 ]
# unprotected_uris allows SSO credentials to be passed anyway. then
ynh_app_setting_set "$app" unprotected_uris "/" # unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set $app unprotected_uris "/"
fi fi
# Reload services #=================================================
# RELOAD NGINX
#=================================================
ynh_print_info "Reloading nginx web server..."
systemctl reload nginx systemctl reload nginx
supervisorctl restart all supervisorctl restart all
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Installation of $app completed"

View file

@ -12,19 +12,31 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_print_info "Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
port=$(ynh_app_setting_get $app port) 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) final_path=$(ynh_app_setting_get $app final_path)
#================================================= #=================================================
# STANDARD REMOVE # 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 # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_print_info "Removing dependencies"
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies ynh_remove_app_dependencies
@ -32,6 +44,7 @@ ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_print_info "Removing app main directory"
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove "$final_path" ynh_secure_remove "$final_path"
@ -39,6 +52,7 @@ ynh_secure_remove "$final_path"
#================================================= #=================================================
# REMOVE NGINX CONFIGURATION # REMOVE NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Removing nginx web server configuration"
# Remove the dedicated nginx config # Remove the dedicated nginx config
ynh_remove_nginx_config ynh_remove_nginx_config
@ -49,8 +63,8 @@ ynh_remove_nginx_config
if yunohost firewall list | grep -q "\- $port$" if yunohost firewall list | grep -q "\- $port$"
then then
echo "Close port $port" >&2 ynh_print_info "Closing port $port"
yunohost firewall disallow TCP $port 2>&1 ynh_exec_warn_less yunohost firewall disallow TCP $port
fi fi
#================================================= #=================================================
@ -65,10 +79,6 @@ ynh_secure_remove "/etc/cron.d/$app"
# Remove a directory securely # Remove a directory securely
ynh_secure_remove "/etc/apt/sources.list.d/onlyoffice.list" 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 # Remove the log files
ynh_secure_remove "/var/log/$app/" ynh_secure_remove "/var/log/$app/"
@ -77,6 +87,13 @@ ynh_secure_remove "/var/log/$app/"
#================================================= #=================================================
# REMOVE DEDICATED USER # REMOVE DEDICATED USER
#================================================= #=================================================
ynh_print_info "Removing the dedicated system user"
# Delete a system user # Delete a system user
ynh_system_user_delete $app ynh_system_user_delete $app
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Removal of $app completed"

View file

@ -1,52 +1,111 @@
#!/bin/bash #!/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 source ../settings/scripts/_common.sh
set -eu
# See comments in install script
app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
# Retrieve old app settings #=================================================
domain=$(ynh_app_setting_get "$app" domain) # MANAGE SCRIPT FAILURE
path_url=$(ynh_app_setting_get "$app" path_url) #=================================================
# Check domain/path availability ynh_clean_setup () {
sudo yunohost app checkurl "${domain}${path_url}" -a "$app" \ #### Remove this function if there's nothing to clean before calling the remove script.
|| ynh_die "Path not available: ${domain}${path_url}" true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
# Restore sources & data #=================================================
src_path="/var/www/${app}" # LOAD SETTINGS
sudo cp -a ./sources "$src_path" #=================================================
ynh_print_info "Loading settings..."
# Restore permissions to app files app=$YNH_APP_INSTANCE_NAME
# you may need to make some file and/or directory writeable by www-data (nginx user)
sudo chown -R root: "$src_path"
### MySQL (remove if not used) ### domain=$(ynh_app_setting_get $app domain)
# If a MySQL database is used: path_url=$(ynh_app_setting_get $app path)
# # Create and restore the database final_path=$(ynh_app_setting_get $app final_path)
# dbname=$app db_name=$(ynh_app_setting_get $app db_name)
# dbuser=$app db_pwd=$(ynh_app_setting_get $app db_pwd)
# 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 ###
# 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) ### ynh_webpath_available $domain $path_url \
# If a dedicated php-fpm process is used: || ynh_die "Path not available: ${domain}${path_url}"
# # Copy PHP-FPM pool configuration and reload the service test ! -d $final_path \
# sudo cp -a ./php-fpm.conf "/etc/php5/fpm/pool.d/${app}.conf" || ynh_die "There is already a directory: $final_path "
# sudo service php5-fpm reload
### PHP end ###
# 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"

View file

@ -1,57 +1,142 @@
#!/bin/bash #!/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 app=$YNH_APP_INSTANCE_NAME
# Source YunoHost helpers domain=$(ynh_app_setting_get $app domain)
source /usr/share/yunohost/helpers path_url=$(ynh_app_setting_get $app path)
source _common.sh is_public=$(ynh_app_setting_get $app is_public)
db_name=$(ynh_app_setting_get $app db_name)
# Retrieve app settings nextclouddomain=$(ynh_app_setting_get $app nextclouddomain)
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
#================================================= #=================================================
# UPGRADE COLLABORA # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_package_update ynh_print_info "Ensuring downward compatibility..."
ynh_install_app_dependencies loolwsd code-brand
# 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 # NGINX CONFIGURATION
#================================================= #=================================================
ynh_print_info "Upgrading nginx web server configuration..."
# Create a dedicated nginx config # Create a dedicated nginx config
ynh_add_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_print_info "Making sure dedicated system user exists..."
ynh_replace_string "__NEXTCLOUDDOMAIN__" "$nextcloud_domain" "/etc/loolwsd/loolwsd.xml"
ynh_replace_string "__PASSWORD__" "$password" "/etc/loolwsd/loolwsd.xml" # Create a dedicated user (if not existing)
systemctl restart loolwsd 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 # Set permissions on app files
if [[ $is_public -eq 1 ]]; then chown -R root: $final_path
# See install script
ynh_app_setting_set "$app" unprotected_uris "/" #=================================================
# 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 fi
# Reload nginx service #=================================================
systemctl restart nginx # RELOAD NGINX
systemctl restart loolwsd #=================================================
ynh_print_info "Reloading nginx web server..."
systemctl reload nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info "Upgrade of $app completed"