1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/luckysheet_ynh.git synced 2024-09-03 19:36:21 +02:00

Merge pull request #13 from YunoHost-Apps/service

Service
This commit is contained in:
Éric Gaspar 2022-06-25 07:23:49 +02:00 committed by GitHub
commit 8c616f3f97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 208 additions and 343 deletions

View file

@ -1,6 +1,11 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand.
-->
# Luckysheet for YunoHost
[![Integration level](https://dash.yunohost.org/integration/luckysheet.svg)](https://dash.yunohost.org/appci/app/luckysheet) ![](https://ci-apps.yunohost.org/ci/badges/luckysheet.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/luckysheet.maintain.svg)
[![Integration level](https://dash.yunohost.org/integration/luckysheet.svg)](https://dash.yunohost.org/appci/app/luckysheet) ![Working status](https://ci-apps.yunohost.org/ci/badges/luckysheet.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/luckysheet.maintain.svg)
[![Install Luckysheet with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=luckysheet)
*[Lire ce readme en français.](./README_fr.md)*
@ -9,52 +14,36 @@
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview
Luckysheet is an online spreadsheet that is powerful, simple to configure, and completely open source.
**Shipped version:** 2.0.0
## Screenshot
**Shipped version:** 2.1.13~ynh1
![](https://raw.githubusercontent.com/mengshukeji/Luckysheet/master/docs/.vuepress/public/img/LuckysheetDemo.gif)
**Demo:** https://mengshukeji.github.io/LuckysheetDemo/
## Demo
## Screenshots
* [Official demo](https://mengshukeji.github.io/LuckysheetDemo/)
![Screenshot of Luckysheet](./doc/screenshots/screenshot.gif)
## Configuration
## Documentation and resources
## Documentation
* Official documentation: https://mengshukeji.github.io/LuckysheetDocs/guide/
* YunoHost documentation:
## YunoHost specific features
#### Multi-user support
* Is LDAP supported?
* Can the app be used by multiple users?
#### Supported architectures
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/luckysheet.svg)](https://ci-apps.yunohost.org/ci/apps/luckysheet/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/luckysheet.svg)](https://ci-apps-arm.yunohost.org/ci/apps/luckysheet/)
## Links
* Report a bug: https://github.com/YunoHost-Apps/luckysheet_ynh/issues
* Upstream app repository: https://github.com/mengshukeji/Luckysheet
* YunoHost website: https://yunohost.org/
---
* Official app website: <https://github.com/mengshukeji/Luckysheet>
* Official admin documentation: <https://mengshukeji.github.io/LuckysheetDocs/guide/>
* Upstream app code repository: <https://github.com/mengshukeji/Luckysheet>
* YunoHost documentation for this app: <https://yunohost.org/app_luckysheet>
* Report a bug: <https://github.com/YunoHost-Apps/luckysheet_ynh/issues>
## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/luckysheet_ynh/tree/testing).
To try the testing branch, please proceed like that.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/luckysheet_ynh/tree/testing --debug
or
sudo yunohost app upgrade luckysheet -u https://github.com/YunoHost-Apps/luckysheet_ynh/tree/testing --debug
```
**More info regarding app packaging:** <https://yunohost.org/packaging_apps>

View file

@ -1,61 +1,49 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand.
-->
# Luckysheet pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/luckysheet.svg)](https://dash.yunohost.org/appci/app/luckysheet) ![](https://ci-apps.yunohost.org/ci/badges/luckysheet.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/luckysheet.maintain.svg)
[![Niveau d'intégration](https://dash.yunohost.org/integration/luckysheet.svg)](https://dash.yunohost.org/appci/app/luckysheet) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/luckysheet.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/luckysheet.maintain.svg)
[![Installer Luckysheet avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=luckysheet)
*[Read this readme in english.](./README.md)*
> *Ce package vous permet d'installer Luckysheet rapidement et simplement sur un serveur YunoHost.
Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.*
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
## Vue d'ensemble
Luckysheet est une feuille de calcul en ligne, puissante, simple à configurer et complètement open source.
**Version incluse :** 2.0.0
**Version incluse :** 2.1.13~ynh1
**Démo :** https://mengshukeji.github.io/LuckysheetDemo/
## Captures d'écran
![](https://raw.githubusercontent.com/mengshukeji/Luckysheet/master/docs/.vuepress/public/img/LuckysheetDemo.gif)
![Capture d'écran de Luckysheet](./doc/screenshots/screenshot.gif)
## Démo
## Documentations et ressources
* [Démo officielle](https://mengshukeji.github.io/LuckysheetDemo/)
## Configuration
## Documentation
* Documentation officielle : https://mengshukeji.github.io/LuckysheetDocs/guide/
* Documentation YunoHost :
## Caractéristiques spécifiques YunoHost
#### Support multi-utilisateur
* L'authentification LDAP est-elle prise en charge ?
* L'application peut-elle être utilisée par plusieurs utilisateurs ?
#### Architectures supportées
* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/luckysheet.svg)](https://ci-apps.yunohost.org/ci/apps/luckysheet/)
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/luckysheet.svg)](https://ci-apps-arm.yunohost.org/ci/apps/luckysheet/)
## Liens
* Signaler un bug : https://github.com/YunoHost-Apps/luckysheet_ynh/issues
* Dépôt de l'application principale : https://github.com/mengshukeji/Luckysheet
* Site web YunoHost : https://yunohost.org/
---
* Site officiel de l'app : <https://github.com/mengshukeji/Luckysheet>
* Documentation officielle de l'admin : <https://mengshukeji.github.io/LuckysheetDocs/guide/>
* Dépôt de code officiel de l'app : <https://github.com/mengshukeji/Luckysheet>
* Documentation YunoHost pour cette app : <https://yunohost.org/app_luckysheet>
* Signaler un bug : <https://github.com/YunoHost-Apps/luckysheet_ynh/issues>
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/luckysheet_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/luckysheet_ynh/tree/testing --debug
ou
sudo yunohost app upgrade luckysheet -u https://github.com/YunoHost-Apps/luckysheet_ynh/tree/testing --debug
```
**Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>

View file

@ -2,7 +2,6 @@
; Manifest
domain="domain.tld"
path="/path"
admin="john"
is_public=1
; Checks
pkg_linter=1
@ -12,6 +11,8 @@
setup_private=1
setup_public=1
upgrade=1
# 2.0.0~ynh4
upgrade=1 from_commit=e381055bd0e6b6b862bdbec72945ec589d8128d7
backup_restore=1
multi_instance=0
port_already_use=1
@ -19,5 +20,3 @@
;;; Options
Email=
Notification=none
;;; Upgrade options
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&

View file

@ -1,6 +1,7 @@
SOURCE_URL=https://github.com/mengshukeji/Luckysheet/archive/v2.0.0.tar.gz
SOURCE_SUM=697e79a4d033506074f8e0261ff94cee6e4360b7f0634cb9de53ae59edcec1fe
SOURCE_URL=https://github.com/mengshukeji/Luckysheet/archive/v2.1.13.tar.gz
SOURCE_SUM=9c996e1e2a47ca0bb37b17840f7ded82ed999899daf3bd620b07c154b71647f9
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -1,25 +1,16 @@
location ^~ __PATH__/ {
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
proxy_pass http://127.0.0.1:__PORT__/;
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;
# Path to source
alias __FINALPATH__/live/;
proxy_http_version 1.1;
proxy_set_header Connection "upgrade";
proxy_set_header Upgrade $http_upgrade;
index index.html;
# setup for image upload
#client_max_body_size 256M;
#proxy_max_temp_file_size 1024M;
# Common parameter to increase upload size limit in conjunction with dedicated php-fpm file
#client_max_body_size 50M;
#proxy_read_timeout 300;
#proxy_connect_timeout 300;
try_files $uri $uri/ index.html;
# Include SSOWAT user panel.
#include conf.d/yunohost_panel.conf.inc;
#more_clear_input_headers 'Accept-Encoding';
include conf.d/yunohost_panel.conf.inc;
}

View file

@ -1,19 +0,0 @@
[Unit]
Description=Luckysheet: online spreadsheet
Documentation=https://github.com/mengshukeji/Luckysheet
After=network.target
[Service]
Type=simple
User=__APP__
Group=__APP__
WorkingDirectory=__FINALPATH__
Environment="PATH=__ENV_PATH__"
Environment="NODE_ENV=production"
ExecStart=__YNH_NPM__ run build
Restart=always
PrivateTmp=true
PrivateDevices=true
[Install]
WantedBy=multi-user.target

0
doc/.gitkeep Normal file
View file

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
Luckysheet is an online spreadsheet that is powerful, simple to configure, and completely open source.

1
doc/DESCRIPTION_fr.md Normal file
View file

@ -0,0 +1 @@
Luckysheet est une feuille de calcul en ligne, puissante, simple à configurer et complètement open source.

0
doc/DISCLAIMER.md Normal file
View file

0
doc/DISCLAIMER_fr.md Normal file
View file

0
doc/screenshots/.gitkeep Normal file
View file

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 KiB

View file

@ -6,8 +6,15 @@
"en": "Online spreadsheet that is powerful, simple to configure",
"fr": "Feuille de calcul en ligne, puissante, simple à configurer"
},
"version": "2.0.0~ynh4",
"version": "2.1.13~ynh1",
"url": "https://github.com/mengshukeji/Luckysheet",
"upstream": {
"license": "MIT",
"website": "https://github.com/mengshukeji/Luckysheet",
"demo": "https://mengshukeji.github.io/LuckysheetDemo/",
"admindoc": "https://mengshukeji.github.io/LuckysheetDocs/guide/",
"code": "https://github.com/mengshukeji/Luckysheet"
},
"license": "MIT",
"maintainer": {
"name": "eric_G"

View file

@ -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
@ -14,7 +15,7 @@ source /usr/share/yunohost/helpers
#=================================================
ynh_clean_setup () {
ynh_clean_check_starting
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
@ -48,14 +49,8 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service"
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for Luckysheet. (YunoHost will then actually copy those files to the archive)."
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -28,20 +28,23 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
# Add settings here as needed by your application
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up Luckysheet before changing its URL (may take a while)..." --weight=1
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
# restore it if the upgrade fails
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
@ -65,13 +68,6 @@ fi
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log"
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
@ -103,14 +99,6 @@ fi
#=================================================
# GENERIC FINALISATION
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
# Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Serving files from: dist"
#=================================================
# RELOAD NGINX
#=================================================
@ -122,4 +110,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for Luckysheet" --last
ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -50,15 +50,6 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=2
# Find an available port
port=$(ynh_find_port --port=3000)
ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
@ -73,7 +64,7 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_script_progression --message="Configuring system user..." --weight=3
# Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -82,7 +73,11 @@ ynh_script_progression --message="Setting up source files..." --weight=2
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir=$final_path
ynh_setup_source --dest_dir="$final_path/build"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
@ -94,66 +89,48 @@ ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#==============================================
# INSTALL HEDGEDOC
#==============================================
ynh_script_progression --message="Building Luckysheet... (this will take some time and resources!)" --weight=20
#=================================================
# BUILD APP
#=================================================
ynh_script_progression --message="Building app... (this will take some time and resources!)" --weight=20
pushd "$final_path"
pushd "$final_path/build"
ynh_use_nodejs
ynh_exec_warn_less $ynh_npm install
ynh_exec_warn_less $ynh_npm install gulp -g
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install
ynh_npm install gulp -g
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm run build
popd
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_exec_as $app mv "$final_path/build/dist" "$final_path/live"
cp ../conf/config.example.js $final_path/src/config.js
ynh_secure_remove --file="$final_path/build"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# SETUP SYSTEMD
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=1
ynh_script_progression --message="Adding a configuration file..."
ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service"
ynh_replace_string --match_string="__YNH_NPM__" --replace_string="$ynh_npm" --target_file="../conf/systemd.service"
ynh_add_config --template="../conf/config.example.js" --destination="$final_path/live/config.js"
ynh_add_systemd_config
chmod 400 "$final_path/live/config.js"
chown $app:$app "$final_path/live/config.js"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..." --weight=1
# Set permissions to app files
chown -R $app: $final_path
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Online spreadsheet like excel" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=2
# Start a systemd service
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Serving files from: dist"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary or protect it
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi
@ -168,4 +145,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of Luckysheet completed" --last
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -17,41 +17,14 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing Luckysheet service..." --weight=1
yunohost service remove $app
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1
# Remove the dedicated systemd config
ynh_remove_systemd_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
ynh_remove_nodejs
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing Luckysheet main directory..." --weight=6
ynh_script_progression --message="Removing app main directory..." --weight=6
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
@ -61,9 +34,16 @@ ynh_secure_remove --file="$final_path"
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=5
# Remove the dedicated nginx config
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=1
ynh_remove_nodejs
#=================================================
# GENERIC FINALIZATION
#=================================================
@ -78,4 +58,4 @@ ynh_system_user_delete --username=$app
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of Luckysheet completed" --last
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -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
@ -22,7 +23,7 @@ ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading settings..." --weight=1
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
@ -35,71 +36,38 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=2
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring Luckysheet main directory..." --weight=50
ynh_restore_file --origin_path="$final_path"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE USER RIGHTS
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring user rights..." --weight=1
ynh_script_progression --message="Restoring the app main directory..." --weight=50
# Restore permissions on app files
chown -R $app: $final_path
ynh_restore_file --origin_path="$final_path"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# SPECIFIC RESTORATION
#=================================================
# REINSTALL DEPENDENCIES
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=7
ynh_script_progression --message="Restoring the NGINX configuration..." --weight=1
# Install Nodejs
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# RESTORE SYSTEMD
#=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=5
ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Online spreadsheet like excel" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Serving files from: dist"
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# GENERIC FINALIZATION
@ -114,4 +82,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for Luckysheet" --last
ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -19,7 +19,6 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# CHECK VERSION
@ -28,6 +27,23 @@ ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=20
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
ynh_clean_check_starting
# Restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
@ -40,28 +56,21 @@ if ynh_legacy_permissions_exists; then
ynh_app_setting_delete --app=$app --key=is_public
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up Luckysheet before upgrading (may take a while)..." --weight=20
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app
fi
# 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
ynh_app_setting_delete --app=$app --key=port
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# STOP SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_remove_systemd_config
ynh_systemd_action --service_name=$app --action=stop --log_path=systemd
if [[ -d "$final_path/src/" ]]
then
mv $final_path/src/ $final_path/live/
fi
#=================================================
# CREATE DEDICATED USER
@ -69,7 +78,7 @@ ynh_systemd_action --service_name=$app --action=stop --log_path=systemd
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -79,20 +88,13 @@ if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=20
# Remove the app directory securely
ynh_secure_remove --file=$final_path
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir=$final_path
ynh_setup_source --dest_dir="$final_path/build"
fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# UPGRADE DEPENDENCIES
@ -102,56 +104,53 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=18
# Install Nodejs
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC UPGRADE
#==============================================
# INSTALL HEDGEDOC
#==============================================
#=================================================
# BUILD APP
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Building Luckysheet... (this will take some time and resources!)" --weight=20
ynh_script_progression --message="Building app... (this will take some time and resources!)" --weight=20
pushd "$final_path"
pushd "$final_path/build"
ynh_use_nodejs
ynh_exec_warn_less $ynh_npm install
ynh_exec_warn_less $ynh_npm install gulp -g
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install
ynh_npm install gulp -g
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm run build
popd
tmpdir="$(mktemp -d)"
cp -af "$final_path/live/config.js" "$tmpdir/config.js"
ynh_secure_remove --file="$final_path/live"
mv "$final_path/build/dist" "$final_path/live"
cp -af "$tmpdir/config.js" "$final_path/live/config.js"
ynh_secure_remove --file="$tmpdir"
fi
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=2
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
ynh_replace_string --match_string="__ENV_PATH__" --replace_string="$PATH" --target_file="../conf/systemd.service"
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
# Create a dedicated systemd config
ynh_add_systemd_config
ynh_add_config --template="../conf/config.example.js" --destination="$final_path/live/config.js"
chmod 400 "$final_path/live/config.js"
chown $app:$app "$final_path/live/config.js"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
ynh_script_progression --message="Securing files and directories..." --weight=1
# Set permissions on app files
chown -R $app: $final_path
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..."
yunohost service add $app --description="Online spreadsheet like excel" --log="/var/log/$app/$app.log"
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="Serving files from: dist"
#=================================================
# RELOAD NGINX
#=================================================
@ -163,4 +162,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of Luckysheet completed" --last
ynh_script_progression --message="Upgrade of $app completed" --last