1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/dato_ynh.git synced 2024-09-03 18:16:33 +02:00

manifestv2 pt1

This commit is contained in:
Salamandar 2024-02-28 22:22:42 +01:00
parent edc672f1db
commit cd3fe851d9
17 changed files with 240 additions and 772 deletions

View file

@ -1,33 +0,0 @@
;; Test without autosync
; Manifest
domain="domain.tld"
is_public=1
autosynchronize=0
couch_url="none"
couch_admin_name="none"
couch_admin_password="none"
couch_datoadmin_name="none"
couch_datoadmin_password="none"
admin_email="none"
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=1
setup_nourl=0
setup_private=1
setup_public=1
upgrade=1
# 1.5.11~ynh2
upgrade=1 from_commit=b127adc6bf773afd1bc2ee7cead36c91c4fded60
# 1.6.3~ynh2
upgrade=1 from_commit=6cbecb3f2af6adfce5bdf8077c906569703a1508
backup_restore=1
multi_instance=1
port_already_use=0
change_url=1
;;; Options
Email=squeak@eauchat.org
Notification=none
;;; Upgrade options
; commit=b127adc6bf773afd1bc2ee7cead36c91c4fded60
name=1.5.11~ynh2.

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://framagit.org/squeak/dato/-/archive/v1.6.3/dato-v1.6.3.tar.gz
SOURCE_SUM=200aa392cbe2e43d85b5a78d9289cc5957dbd6b7aa3d4491838d12aa5dbc9c30
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=
SOURCE_EXTRACT=true

View file

@ -6,9 +6,9 @@ After=network.target
Type=simple Type=simple
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__INSTALL_DIR__/
Environment=NODE_ENV=production Environment=NODE_ENV=production
Environment=NODE_CONFIG_DIR=__FINALPATH__/config Environment=NODE_CONFIG_DIR=__INSTALL_DIR__/config
Environment="__YNH_NODE_LOAD_PATH__" Environment="__YNH_NODE_LOAD_PATH__"
ExecStart=__YNH_NPM__ start ExecStart=__YNH_NPM__ start
StandardOutput=syslog StandardOutput=syslog

View file

@ -1,13 +1,9 @@
* Any known limitations, constrains or stuff not working, such as (but not limited to):
* For now, dato needs a full domain, it doesn't support being set to a subpath.
* LDAP is not supported, but dato has it's own user's control system, so it can be used publicly, or restricted to some users when autosynchronization is enabled.
## Configuration ## Configuration
To configure dato, you can edit the `config/public.js` file in the app directory that should be in `/opt/yunohost/APPID/` where `APPID` is `dato` if it's the first installed instance, `dato__2`, `dato__3`... for additional instances. To configure dato, you can edit the `config/public.js` file in the app directory that should be in `/opt/yunohost/APPID/` where `APPID` is `dato` if it's the first installed instance, `dato__2`, `dato__3`... for additional instances.
You can also make modifications in `config/private.js`, but be sure to know what you're doing when doing so. You can also make modifications in `config/private.js`, but be sure to know what you're doing when doing so.
## Autosynchronization ## Autosynchronization
By default all data you create with dato is stored only in your browser. Users can manually enable per-database synchronization with any remote couch server, but this process is not obvious to users. Therefore dato provide an autosynchronization mechanism. By default all data you create with dato is stored only in your browser. Users can manually enable per-database synchronization with any remote couch server, but this process is not obvious to users. Therefore dato provide an autosynchronization mechanism.
@ -16,7 +12,6 @@ Then when installing dato, set the url to your couchdb server when prompted (you
If you want to allow both a free usage of the app by anyone, and autosynchronization for some users, you can install the dato package multiple times with different setups. If you want to allow both a free usage of the app by anyone, and autosynchronization for some users, you can install the dato package multiple times with different setups.
## Adding users ## Adding users
If you setup autosynchronization, users will need an account to use the app. Dato doesn't support LDAP for the moment, so you will need to add users in it's own database. If you setup autosynchronization, users will need an account to use the app. Dato doesn't support LDAP for the moment, so you will need to add users in it's own database.
@ -25,7 +20,6 @@ If you want a user to have administration rights (= to have the power to add/rem
Also, if you need, you can make use of the password reset feature to allow users to modify their passwords, you will just need to send them the generated password reset link. Also, if you need, you can make use of the password reset feature to allow users to modify their passwords, you will just need to send them the generated password reset link.
## A note about dato ## A note about dato
Please be aware that dato is a Progressive Web App. In a nutshell, this means that browsers cache the whole app, so it doesn't have to be requested to the server every time a user is visiting it. Please be aware that dato is a Progressive Web App. In a nutshell, this means that browsers cache the whole app, so it doesn't have to be requested to the server every time a user is visiting it.

View file

@ -1,13 +1,9 @@
* Limitations
* Pour le moment, dato a besoin d'un domaine/sous-domaine complet et ne peut être installé dans un sous-chemin.
* LDAP n'est pas supporté, mais dato contient son propre mécanisme de gestion des utilisateurs, et permet de rendre l'application soit disponible à tous, soit restreinte aux utilisateurs choisis quand l'autosynchronisation est activée.
## Configuration ## Configuration
Cette application peut être personnalisée en modifiant le fichier `config/public.js` situé dans `/opt/yunohost/APPID/` (`APPID` devrait-être `dato` pour une première instance et puis, `dato__2`, `dato__3`... pour les suivantes). Cette application peut être personnalisée en modifiant le fichier `config/public.js` situé dans `/opt/yunohost/APPID/` (`APPID` devrait-être `dato` pour une première instance et puis, `dato__2`, `dato__3`... pour les suivantes).
Il est aussi possible de modifier `config/private.js`, mais à vos risques et périls. Il est aussi possible de modifier `config/private.js`, mais à vos risques et périls.
## Ajouter des utilisateurs ## Ajouter des utilisateurs
Si vous activez l'autosynchronisation, les utilisateurs auront besoin d'un compte pour utiliser l'application. Dato ne supporte pas LDAP pour le moment, vous devrez donc ajouter des utilisateurs séparément dans sa base de données. Si vous activez l'autosynchronisation, les utilisateurs auront besoin d'un compte pour utiliser l'application. Dato ne supporte pas LDAP pour le moment, vous devrez donc ajouter des utilisateurs séparément dans sa base de données.
@ -16,7 +12,6 @@ Si vous voulez donner le droit à un utilisateur d'administrer (= d'ajouter/supp
Si besoin, vous pouvez créer des liens pour permettre à un utilisateur de modifier son mot de passe. Il suffira alors d'envoyer ce lien manuellement à l'utilisateur. Si besoin, vous pouvez créer des liens pour permettre à un utilisateur de modifier son mot de passe. Il suffira alors d'envoyer ce lien manuellement à l'utilisateur.
## Note sur dato ## Note sur dato
Dato est une application web progressive (PWA). En deux mots, cela veut dire que les navigateurs gardent en cache l'application entière, afin de ne pas avoir à la demander au serveur à chaque visite. Dato est une application web progressive (PWA). En deux mots, cela veut dire que les navigateurs gardent en cache l'application entière, afin de ne pas avoir à la demander au serveur à chaque visite.

1
doc/PRE_INSTALL.md Normal file
View file

@ -0,0 +1 @@
Dato needs a full domain, it doesn't support being set to a subpath.

0
doc/PRE_INSTALL_fr.md Normal file
View file

View file

@ -1,130 +0,0 @@
{
"name": "Dato",
"id": "dato",
"packaging_format": 1,
"description": {
"en": "Store all kinds of data with an extremely customizable interface.",
"fr": "Stockez tous types de données avec une interface complètement customizable."
},
"version": "1.6.3~ynh3",
"url": "https://squeak.eauchat.org/dato",
"upstream": {
"license": "AGPL-3.0-or-later",
"demo": "https://publicdato.eauchat.org/",
"admindoc": "https://squeak.eauchat.org/dato/",
"code": "https://framagit.org/squeak/dato"
},
"license": "AGPL-3.0-or-later",
"maintainer": {
"name": "Squeak",
"email": "squeak@eauchat.org",
"url": "https://squeak.eauchat.org"
},
"requirements": {
"yunohost": ">= 4.3.0"
},
"multi_instance": true,
"services": [
"nginx"
],
"arguments": {
"install": [
{
"name": "domain",
"type": "domain"
},
{
"name": "is_public",
"type": "boolean",
"help": {
"en": "Will users need to have a yunohost account to use dato? If you choose to set autosynchronization to true, then dato contains it's own login system, so you probably don't need to make it private.",
"fr": "Les utilisateurs devront-ils avoir un compte pour utiliser dato ? Si vous activez l'autosynchronisation, dato contient son propre système de login, ce n'est donc probablement pas nécessaire de la rendre privée."
},
"default": true
},
{
"name": "autosynchronize",
"type": "boolean",
"ask": {
"en": "Do you want to autosynchronize users databases?",
"fr": "Voulez vous activer l'autosynchronisation des bases de données des utilisateurs ?"
},
"help": {
"en": "If you activate autosynchronization, to use dato, people will need to have a dato-specific account on your server. To enable this, you need a couchdb server, you can install one with the couchdb yunohost package (you should do this before proceeding to dato installation).",
"fr": "Si vous activez l'autosynchronisation, pour utiliser dato, les utilisateurs devront avoir un compte specifique à dato sur votre serveur. Pour activer cette option, vous devez avoir un server couchdb, vous pouvez en installer un en utilisant le packet yunohost couchdb (vous devez avoir couchdb installé avant d'installer dato)."
},
"default" : false
},
{
"name": "autosync_info",
"type": "display_text",
"ask": {
"en": "All the following options are useful only if you chose to enable autosynchronization. You can skip them all if you didn't.",
"fr": "Les options qui suivent ne sont utiles que si vous avez choisi d'activer l'autosynchronisation. Vous pouvez toutes les ignorer si ce n'est pas le cas."
}
},
{
"name": "couch_url",
"type": "string",
"ask": {
"en": "What is the url of your couchdb server (only if autosynchronization is enabled).",
"fr": "Quelle est l'addresse de votre serveur couchdb (nécessaire uniquement si l'autosynchronisation a été activée)."
},
"example": "https://couch.domain.tld",
"optional": true,
"default" : "none"
},
{
"name": "couch_admin_name",
"type": "string",
"ask": {
"en": "Specify the username of the administrator of your couchdb instance (only if autosynchronization is enabled), if you didn't customize it, it should be called 'admin'",
"fr": "Entrez le nom de l'administrateur de votre serveur couchdb (nécessaire uniquement si l'autosynchronisation a été activée), si vous ne l'avez pas modifié, ce devrait être 'admin'"
},
"example": "admin",
"optional": true,
"default" : "admin"
},
{
"name": "couch_admin_password",
"type": "password",
"ask": {
"en": "Enter the password of your couchdb administrator (only if autosynchronization is enabled)",
"fr": "Entrez le mot de passe de l'administrateur de votre serveur couchdb (nécessaire uniquement si l'autosynchronisation a été activée)"
},
"optional": true
},
{
"name": "couch_datoadmin_name",
"type": "string",
"ask": {
"en": "Choose the username of the dato admin user to create (only if autosynchronization is enabled)",
"fr": "Choisissez le nom de l'administrateur de dato qui va être créé (nécessaire uniquement si l'autosynchronisation a été activée)"
},
"example": "dato-admin",
"optional": true,
"default": "none"
},
{
"name": "couch_datoadmin_password",
"type": "password",
"ask": {
"en": "Choose the password to use for the dato admin user to create (only if autosynchronization is enabled)",
"fr": "Choisissez le mot de passe de l'administrateur de dato qui va être créé (nécessaire uniquement si l'autosynchronisation a été activée)"
},
"optional": true
},
{
"name": "admin_email",
"type": "string",
"ask": {
"en": "If you want the dato administrator email to be displayed in login page, so that users can contact you to create accounts... you can set your email here, otherwise leave this empty (only useful if autosynchronization is enabled)",
"fr": "Si tu souhaites que l'email de l'administrateur de dato soit visible sur la page de login, afin que les utilisateurs puissent le contacter pour des demandes de compte... tu peux le spécifier ici, sinon laisser ce champ vide (utile uniquement si l'autosynchronisation a été activée)"
},
"example": "datoadmin((at))domain.tld",
"optional": true,
"default" : ""
}
]
}
}

116
manifest.toml Normal file
View file

@ -0,0 +1,116 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "dato"
name = "Dato"
description.en = "Store all kinds of data with an extremely customizable interface."
description.fr = "Stockez tous types de données avec une interface complètement customizable."
version = "1.6.3~ynh3"
maintainers = ["Squeak"]
[upstream]
license = "AGPL-3.0-or-later"
demo = "https://publicdato.eauchat.org/"
admindoc = "https://squeak.eauchat.org/dato/"
code = "https://framagit.org/squeak/dato"
website = "https://squeak.eauchat.org/dato"
[integration]
yunohost = ">= 11.2"
architectures = "all"
multi_instance = true
ldap = false
sso = false
disk = "50M"
ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ...
[install]
[install.domain]
type = "domain"
[install.init_main_permission]
help.en = "Will users need to have a yunohost account to use dato? If you choose to set autosynchronization to true, then dato contains it's own login system, so you probably don't need to make it private."
help.fr = "Les utilisateurs devront-ils avoir un compte pour utiliser dato ? Si vous activez l'autosynchronisation, dato contient son propre système de login, ce n'est donc probablement pas nécessaire de la rendre privée."
type = "group"
default = "visitors"
[install.autosynchronize]
ask.en = "Do you want to autosynchronize users databases?"
ask.fr = "Voulez vous activer l'autosynchronisation des bases de données des utilisateurs ?"
help.en = "If you activate autosynchronization, to use dato, people will need to have a dato-specific account on your server. To enable this, you need a couchdb server, you can install one with the couchdb yunohost package (you should do this before proceeding to dato installation)."
help.fr = "Si vous activez l'autosynchronisation, pour utiliser dato, les utilisateurs devront avoir un compte specifique à dato sur votre serveur. Pour activer cette option, vous devez avoir un server couchdb, vous pouvez en installer un en utilisant le packet yunohost couchdb (vous devez avoir couchdb installé avant d'installer dato)."
type = "boolean"
default = false
[install.autosync_info]
ask.en = "All the following options are useful only if you chose to enable autosynchronization. You can skip them all if you didn't."
ask.fr = "Les options qui suivent ne sont utiles que si vous avez choisi d'activer l'autosynchronisation. Vous pouvez toutes les ignorer si ce n'est pas le cas."
type = "text"
[install.couch_url]
ask.en = "What is the url of your couchdb server (only if autosynchronization is enabled)."
ask.fr = "Quelle est l'addresse de votre serveur couchdb (nécessaire uniquement si l'autosynchronisation a été activée)."
type = "string"
example = "https://couch.domain.tld"
optional = true
default = "none"
[install.couch_admin_name]
ask.en = "Specify the username of the administrator of your couchdb instance (only if autosynchronization is enabled), if you didn't customize it, it should be called 'admin'"
ask.fr = "Entrez le nom de l'administrateur de votre serveur couchdb (nécessaire uniquement si l'autosynchronisation a été activée), si vous ne l'avez pas modifié, ce devrait être 'admin'"
type = "string"
example = "admin"
optional = true
default = "admin"
[install.couch_admin_password]
ask.en = "Enter the password of your couchdb administrator (only if autosynchronization is enabled)"
ask.fr = "Entrez le mot de passe de l'administrateur de votre serveur couchdb (nécessaire uniquement si l'autosynchronisation a été activée)"
type = "password"
optional = true
[install.couch_datoadmin_name]
ask.en = "Choose the username of the dato admin user to create (only if autosynchronization is enabled)"
ask.fr = "Choisissez le nom de l'administrateur de dato qui va être créé (nécessaire uniquement si l'autosynchronisation a été activée)"
type = "string"
example = "dato-admin"
optional = true
default = "none"
[install.couch_datoadmin_password]
ask.en = "Choose the password to use for the dato admin user to create (only if autosynchronization is enabled)"
ask.fr = "Choisissez le mot de passe de l'administrateur de dato qui va être créé (nécessaire uniquement si l'autosynchronisation a été activée)"
type = "password"
optional = true
[install.admin_email]
ask.en = "If you want the dato administrator email to be displayed in login page, so that users can contact you to create accounts... you can set your email here, otherwise leave this empty (only useful if autosynchronization is enabled)"
ask.fr = "Si tu souhaites que l'email de l'administrateur de dato soit visible sur la page de login, afin que les utilisateurs puissent le contacter pour des demandes de compte... tu peux le spécifier ici, sinon laisser ce champ vide (utile uniquement si l'autosynchronisation a été activée)"
type = "string"
example = "datoadmin((at))domain.tld"
optional = true
default = ""
[resources]
[resources.sources.main]
url = "https://framagit.org/squeak/dato/-/archive/v1.6.3/dato-v1.6.3.tar.gz"
sha256 = "200aa392cbe2e43d85b5a78d9289cc5957dbd6b7aa3d4491838d12aa5dbc9c30"
autoupdate.strategy = "latest_gitlab_release"
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"
[resources.ports]
main.default = 9559
[resources.apt]
packages = ["curl", "jq"]

View file

@ -4,9 +4,6 @@
# COMMON VARIABLES # COMMON VARIABLES
#================================================= #=================================================
# dependencies used by the app
pkg_dependencies="curl jq"
# nodejs version # nodejs version
nodejs_version=12 nodejs_version=12
@ -14,23 +11,28 @@ nodejs_version=12
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================
bool_to_str() {
bool_str=(false true)
return "${bool_str[$1]}"
}
dato_setup_config_files() { dato_setup_config_files() {
# create config directory (if it doesn't exist yet) # create config directory (if it doesn't exist yet)
[ -d "$final_path/config/" ] || mkdir "$final_path/config/" [ -d "$install_dir/config/" ] || mkdir "$install_dir/config/"
# setup public dato config # setup public dato config
ynh_add_config --template="../conf/public.js" --destination="$final_path/config/public.js" ynh_add_config --template="public.js" --destination="$install_dir/config/public.js"
chmod 400 "$final_path/config/public.js" chmod 400 "$install_dir/config/public.js"
chown $app:$app "$final_path/config/public.js" chown "$app:$app" "$install_dir/config/public.js"
# setup private dato config # setup private dato config
if [[ $autosynchronize == true ]]; then if [[ $autosynchronize == true ]]; then
ynh_add_config --template="../conf/private-autosync.js" --destination="$final_path/config/private.js" ynh_add_config --template="private-autosync.js" --destination="$install_dir/config/private.js"
else else
ynh_add_config --template="../conf/private.js" --destination="$final_path/config/private.js" ynh_add_config --template="private.js" --destination="$install_dir/config/private.js"
fi fi
chmod 400 "$final_path/config/private.js" chmod 400 "$install_dir/config/private.js"
chown $app:$app "$final_path/config/private.js" chown "$app:$app" "$install_dir/config/private.js"
} }
#================================================= #=================================================

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -10,27 +8,6 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
ynh_clean_setup () {
true
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain)
autosynchronize=$(ynh_app_setting_get --app=$app --key=autosynchronize)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
#================================================= #=================================================
@ -40,49 +17,30 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE SYSTEM CONFIGURATION
#================================================= #=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP SYSTEMD
#=================================================
ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/systemd/system/$app.service"
#================================================= #=================================================
# BACKUP VARIOUS FILES # BACKUP VARIOUS FILES
#================================================= #=================================================
if [[ $autosynchronize == true ]]; then ynh_backup --src_path="/var/log/$app/"
if [[ "$autosynchronize" == true ]]; then
# backup dato.ini config in couch # backup dato.ini config in couch
ynh_backup --src_path="/opt/couchdb/etc/local.d/$app.ini" ynh_backup --src_path="/opt/couchdb/etc/local.d/$app.ini"
fi
#=================================================
# AUTOSYNCHRONIZED SPECIFICS
#=================================================
# warn that dbs haven't been backed up, only dato
if [[ $autosynchronize == true ]]; then
# notify that couchdb users and dbs are left # notify that couchdb users and dbs are left
ynh_print_warn --message="Please note that backing up dato doesn't backup the databases you created through it. To backup your data, you should backup the couchdb app." ynh_print_warn --message="Please note that backing up dato doesn't backup the databases you created through it. To backup your data, you should backup the couchdb app."
fi fi
#================================================= #=================================================

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC STARTING
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -9,114 +7,27 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers 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="/"
app=$YNH_APP_INSTANCE_NAME
#=================================================
# LOAD SETTINGS
#=================================================
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)
#=================================================
# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=10
# 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
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# 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
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_script_progression --message="Stopping $app's systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd"
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # MODIFY URL IN NGINX CONF
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf ynh_change_url_nginx_config
# 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 --file="$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 --file="$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 --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
fi
#=================================================
# GENERIC FINALISATION
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=60 ynh_script_progression --message="Starting $app's systemd service..." --weight=60
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600 ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -10,129 +8,39 @@ source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # INITIALIZE AND STORE SETTINGS
#================================================= #=================================================
ynh_clean_setup () { # Convert to true/false
ynh_clean_check_starting autosynchronize=$(bool_to_str "$autosynchronize")
} ynh_app_setting_set --app="$app" --key=autosynchronize --value="$autosynchronize"
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # INSTALL NODEJS
#================================================= #=================================================
ynh_script_progression --message="Installing NodeJS..." --weight=6
domain=$YNH_APP_ARG_DOMAIN ynh_install_nodejs --nodejs_version="$nodejs_version"
path_url="/"
is_public=$YNH_APP_ARG_IS_PUBLIC
autosynchronize=$YNH_APP_ARG_AUTOSYNCHRONIZE
couch_url=$YNH_APP_ARG_COUCH_URL
couch_admin_name=$YNH_APP_ARG_COUCH_ADMIN_NAME
couch_admin_password=$YNH_APP_ARG_COUCH_ADMIN_PASSWORD
couch_datoadmin_name=$YNH_APP_ARG_COUCH_DATOADMIN_NAME
couch_datoadmin_password=$YNH_APP_ARG_COUCH_DATOADMIN_PASSWORD
admin_email=$YNH_APP_ARG_ADMIN_EMAIL
app=$YNH_APP_INSTANCE_NAME
# make sure autosynchronize variable is a boolean
if [[
"$autosynchronize" == "true" ||
"$autosynchronize" == "yes" ||
"$autosynchronize" == "1"
]] && [[ "$couch_url" != "none" ]]
then
autosynchronize=true
else
autosynchronize=false
fi
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=1
# dato provides an internal webserver, setup it's installation path
final_path=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin_email --value=$admin_email
ynh_app_setting_set --app=$app --key=autosynchronize --value=$autosynchronize
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
ynh_app_setting_set --app=$app --key=couch_url --value=$couch_url
ynh_app_setting_set --app=$app --key=couch_admin_name --value=$couch_admin_name
ynh_app_setting_set --app=$app --key=couch_admin_password --value=$couch_admin_password
ynh_app_setting_set --app=$app --key=admin_email --value=$admin_email
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
ynh_script_progression --message="Finding an available port..." --weight=1
# Find an available port
port=$(ynh_find_port --port=9559)
ynh_app_setting_set --app=$app --key=port --value=$port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Installing dependencies..." --weight=6
ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Setting up source files..." --weight=2 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 # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$install_dir"
chmod 750 "$final_path" chmod -R o-rwx "$install_dir"
chmod -R o-rwx "$final_path" chown -R "$app:www-data" "$install_dir"
chown -R $app:www-data "$final_path"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#================================================= #=================================================
# BUILD NODE DEPENDENCIES # BUILD NODE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Building node dependencies..." --weight=90 ynh_script_progression --message="Building node dependencies..." --weight=90
pushd "$final_path" pushd "$install_dir"
ynh_use_nodejs ynh_use_nodejs
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install --loglevel warn ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install --loglevel warn
popd popd
#================================================= #=================================================
@ -142,14 +50,6 @@ ynh_script_progression --message="Adding a configuration file..." --weight=3
dato_setup_config_files dato_setup_config_files
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Configuring a systemd service..." --weight=2
# Create a dedicated systemd config
ynh_add_systemd_config
#================================================= #=================================================
# CUSTOMIZE SETUP FOR AUTOSYNCHRONIZATION # CUSTOMIZE SETUP FOR AUTOSYNCHRONIZATION
#================================================= #=================================================
@ -210,53 +110,31 @@ fi
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
[ -d "$final_path/dist" ] || mkdir "$final_path/dist" [ -d "$install_dir/dist" ] || mkdir "$install_dir/dist"
chown -R $app:$app $final_path/dist $final_path/global $final_path/config chown -R $app:$app $install_dir/dist $install_dir/global $install_dir/config
#================================================= #=================================================
# GENERIC FINALIZATION # SYSTEM CONFIGURATION
#================================================= #=================================================
# SETUP LOGROTATE ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
#=================================================
ynh_script_progression --message="Configuring log rotation..." --weight=1 # Create a dedicated NGINX config
ynh_add_nginx_config
# Create a dedicated systemd config
ynh_add_systemd_config
yunohost service add "$app" --description="Data storage with a convenient and flexible interface" --log="/var/log/$app/$app.log"
# Use logrotate to manage application logfile(s) # Use logrotate to manage application logfile(s)
ynh_use_logrotate ynh_use_logrotate
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Data storage with a convenient and flexible interface" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=60 ynh_script_progression --message="Starting $app's systemd service..." --weight=60
# Start a systemd service # Start a systemd service
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600 ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1
# 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
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=2
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -10,97 +8,44 @@ source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=2
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)
autosynchronize=$(ynh_app_setting_get --app=$app --key=autosynchronize)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) # 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 if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then
then yunohost service remove "$app"
ynh_script_progression --message="Removing $app service integration..." --weight=1
yunohost service remove $app
fi fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=2
# Remove the dedicated systemd config # Remove the dedicated systemd config
ynh_remove_systemd_config ynh_remove_systemd_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config # Remove the app-specific logrotate config
ynh_remove_logrotate ynh_remove_logrotate
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..." --weight=3
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=2
# Remove the dedicated NGINX config # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE DEPENDENCIES # REMOVE NODEJS
#================================================= #=================================================
ynh_script_progression --message="Removing dependencies..." --weight=13 ynh_script_progression --message="Removing NodeJS..." --weight=13
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_nodejs ynh_remove_nodejs
ynh_remove_app_dependencies
#=================================================
# SPECIFIC REMOVE
#================================================= #=================================================
# AUTOSYNCHRONIZED SPECIFICS # AUTOSYNCHRONIZED SPECIFICS
#================================================= #=================================================
if [[ $autosynchronize == true ]]; then if [[ $autosynchronize == true ]]; then
# Remove dato specific config added to couch # Remove dato specific config added to couch
ynh_secure_remove --file="/opt/couchdb/etc/local.d/$app.ini" ynh_secure_remove --file="/opt/couchdb/etc/local.d/$app.ini"
# notify that couchdb users and dbs are left # notify that couchdb users and dbs are left
ynh_print_warn --message="Please note that dbs and users in the attached couchdb instance haven't been modified. If you want them removed, you should do that manually, for example from the couchdb web interface." ynh_print_warn --message="Please note that dbs and users in the attached couchdb instance haven't been modified. If you want them removed, you should do that manually, for example from the couchdb web interface."
fi fi
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..." --weight=1
# Delete a system user
ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -11,80 +9,28 @@ source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling NodeJS..." --weight=5
ynh_clean_setup () { # Define and install dependencies
ynh_clean_check_starting ynh_install_nodejs --nodejs_version="$nodejs_version"
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
autosynchronize=$(ynh_app_setting_get --app=$app --key=autosynchronize)
port=$(ynh_app_setting_get --app=$app --key=port)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --weight=2
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path" chmod -R o-rwx "$install_dir"
chmod -R o-rwx "$final_path" chown -R "$app:www-data" "$install_dir"
chown -R $app:www-data "$final_path"
[ -d "$final_path/dist" ] || mkdir "$final_path/dist" mkdir -p "$install_dir/dist"
chown -R $app:$app $final_path/dist $final_path/global $final_path/config chown -R "$app:$app" "$install_dir/dist" "$install_dir/global" "$install_dir/config"
#================================================= #=================================================
# SPECIFIC RESTORATION # RESTORE VARIOUS FILES
#=================================================
# REINSTALL DEPENDENCIES
#=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=5
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies
ynh_install_nodejs --nodejs_version=$nodejs_version
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP VARIOUS FILES
#================================================= #=================================================
# restore dato.ini config in couch # restore dato.ini config in couch
@ -93,40 +39,24 @@ if [[ $autosynchronize == true ]]; then
fi fi
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --weight=2 ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service --quiet systemctl enable "$app.service" --quiet
yunohost service add "$app" --description="Data storage with a convenient and flexible interface" --log="/var/log/$app/$app.log"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
#================================================= #=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
yunohost service add $app --description="Data storage with a convenient and flexible interface" --log="/var/log/$app/$app.log" ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600
#=================================================
# START SYSTEMD SERVICE
#=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=60
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload

View file

@ -1,7 +1,5 @@
#!/bin/bash #!/bin/bash
#=================================================
# GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
@ -9,170 +7,72 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
port=$(ynh_app_setting_get --app=$app --key=port)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
autosynchronize=$(ynh_app_setting_get --app=$app --key=autosynchronize)
couch_url=$(ynh_app_setting_get --app=$app --key=couch_url)
couch_admin_name=$(ynh_app_setting_get --app=$app --key=couch_admin_name)
couch_admin_password=$(ynh_app_setting_get --app=$app --key=couch_admin_password)
admin_email=$(ynh_app_setting_get --app=$app --key=admin_email)
#=================================================
# CHECK VERSION
#=================================================
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=10
# 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
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" ynh_systemd_action --service_name="$app" --action="stop" --log_path="systemd"
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # ENSURE DOWNWARD COMPATIBILITY
#================================================= #=================================================
ynh_script_progression --message="Ensuring downward compatibility..." # ynh_script_progression --message="Ensuring downward compatibility..."
# Cleaning legacy permissions
if ynh_legacy_permissions_exists; then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
fi
# If path_url doesn't exist, create it
if [ -z "$path_url" ]; then
path_url="/"
ynh_app_setting_set --app=$app --key=path_url --value=$path_url
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
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
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=3
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" --keep="config/public.js config/private.js"
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Upgrading dependencies..." --weight=5 ynh_script_progression --message="Upgrading NodeJS..." --weight=5
ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version="$nodejs_version"
ynh_install_nodejs --nodejs_version=$nodejs_version
#================================================= #=================================================
# NGINX CONFIGURATION # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 ynh_script_progression --message="Upgrading source files..." --weight=3
# Create a dedicated NGINX config # Download, check integrity, uncompress and patch the source from app.src
ynh_add_nginx_config ynh_setup_source --dest_dir="$install_dir" --full_replace=1 --keep="config/public.js config/private.js"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
mkdir "$install_dir/dist"
chown -R "$app:$app" "$install_dir/dist" "$install_dir/global" "$install_dir/config"
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
#================================================= #=================================================
# BUILD NODE DEPENDENCIES # BUILD NODE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Building node dependencies..." --weight=90 #REMOVEME? ynh_script_progression --message="Building node dependencies..." --weight=90
pushd "$final_path" pushd "$install_dir"
ynh_use_nodejs ynh_use_nodejs
ynh_secure_remove --file="./node_modules" ynh_exec_warn_less ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" install --loglevel warn
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install --loglevel warn
popd popd
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # REAPPLY SYSTEM CONFIGURATIONS
#================================================= #=================================================
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
[ -d "$final_path/dist" ] || mkdir "$final_path/dist" # Create a dedicated NGINX config
chown -R $app:$app $final_path/dist $final_path/global $final_path/config ynh_add_nginx_config
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_add_systemd_config ynh_add_systemd_config
yunohost service add "$app" --description="Data storage with a convenient and flexible interface" --log="/var/log/$app/$app.log"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
# Use logrotate to manage app-specific logfile(s) # Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append ynh_use_logrotate --non-append
#=================================================
# INTEGRATE SERVICE IN YUNOHOST
#=================================================
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
yunohost service add $app --description="Data storage with a convenient and flexible interface" --log="/var/log/$app/$app.log"
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=60 ynh_script_progression --message="Starting $app's systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600 ynh_systemd_action --service_name="$app" --action="start" --log_path="systemd" --line_match="electrode server listening on port" --timeout=600
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

8
tests.toml Normal file
View file

@ -0,0 +1,8 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json
test_format = 1.0
[default]
test_upgrade_from.b127adc6bf773afd1bc2ee7cead36c91c4fded60.name = "1.5.11~ynh2"
test_upgrade_from.6cbecb3f2af6adfce5bdf8077c906569703a1508.name = "1.6.3~ynh2"