mirror of
https://github.com/YunoHost-Apps/trilium_ynh.git
synced 2024-10-01 13:34:49 +02:00
Switch to packaging v2 and upgrade to v0.58.8
Signed-off-by: John Schmidt <john@schmidthaus.rocks>
This commit is contained in:
parent
ad97756d62
commit
d35be6111d
16 changed files with 434 additions and 496 deletions
|
@ -1,22 +0,0 @@
|
||||||
;; Test complet
|
|
||||||
; Manifest
|
|
||||||
domain="domain.tld"
|
|
||||||
is_public=1
|
|
||||||
instance_name="MyTrillium"
|
|
||||||
; Checks
|
|
||||||
pkg_linter=1
|
|
||||||
setup_sub_dir=0
|
|
||||||
setup_root=1
|
|
||||||
setup_nourl=0
|
|
||||||
setup_private=1
|
|
||||||
setup_public=1
|
|
||||||
upgrade=1
|
|
||||||
# 0.50.2~ynh1
|
|
||||||
upgrade=0 from_commit=1a944e70223108bc16a28d236eca6e7efd25018e
|
|
||||||
backup_restore=1
|
|
||||||
multi_instance=1
|
|
||||||
port_already_use=0
|
|
||||||
change_url=1
|
|
||||||
;;; Options
|
|
||||||
Email=
|
|
||||||
Notification=none
|
|
|
@ -1,7 +1,7 @@
|
||||||
SOURCE_URL=https://github.com/zadam/trilium/archive/refs/tags/v0.57.5.tar.gz
|
SOURCE_URL=https://github.com/zadam/trilium/archive/refs/tags/v0.58.8.tar.gz
|
||||||
SOURCE_SUM=a6025d5946dbefc1ee8e8fb2517cb969680277caf041cea9ac1ec90c98a943cb
|
SOURCE_SUM=a4b8d062bfacaa47bcde6356c8a5be0fe114f3f8db78c697e7f6cc4a72c03593
|
||||||
SOURCE_SUM_PRG=sha256sum
|
SOURCE_SUM_PRG=sha256sum
|
||||||
SOURCE_FORMAT=tar.gz
|
SOURCE_FORMAT=tar.gz
|
||||||
SOURCE_IN_SUBDIR=true
|
SOURCE_IN_SUBDIR=true
|
||||||
SOURCE_FILENAME=v0.57.5.tar.gz
|
SOURCE_FILENAME=v0.58.8.tar.gz
|
||||||
SOURCE_EXTRACT=true
|
SOURCE_EXTRACT=true
|
||||||
|
|
|
@ -6,12 +6,13 @@ After=network.target
|
||||||
Type=simple
|
Type=simple
|
||||||
User=__APP__
|
User=__APP__
|
||||||
Group=__APP__
|
Group=__APP__
|
||||||
Environment=TRILIUM_DATA_DIR=__DATADIR__
|
Environment=TRILIUM_DATA_DIR=__DATA_DIR__
|
||||||
Environment=TRILIUM_PORT=__PORT__
|
Environment=TRILIUM_PORT=__PORT__
|
||||||
Environment="__YNH_NODE_LOAD_PATH__"
|
Environment="__YNH_NODE_LOAD_PATH__"
|
||||||
Environment=NODE_ENV=production
|
Environment=NODE_ENV=production
|
||||||
WorkingDirectory=__FINALPATH__/
|
Environment=TRILIUM_ENV=dev
|
||||||
ExecStart=__YNH_NODE__ __FINALPATH__/src/www
|
WorkingDirectory=__INSTALL_DIR__/
|
||||||
|
ExecStart=__YNH_NODE__ __INSTALL_DIR__/src/www
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
## Configuration
|
|
||||||
|
|
||||||
You will be asked to choose a username and password when you first access the app. You can configure Trillium from the settings menu of the app interface.
|
|
|
@ -1,3 +0,0 @@
|
||||||
## Configuration
|
|
||||||
|
|
||||||
On vous demandera de choisir un nom d'utilisateur et mot de passe quand vous installez l'application. Vous pouvez configurer Trillium depuis le menu de configuration de l'interface web.
|
|
3
doc/post_install.md
Normal file
3
doc/post_install.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
You will be asked to choose a password when you first access the app. You can configure Trillium from the settings menu of the app interface.
|
3
doc/post_install_fr.md
Normal file
3
doc/post_install_fr.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
On vous demandera de choisir un mot de passe quand vous installez l'application. Vous pouvez configurer Trillium depuis le menu de configuration de l'interface web.
|
|
@ -1,56 +0,0 @@
|
||||||
{
|
|
||||||
"name": "Trilium Notes",
|
|
||||||
"id": "trilium",
|
|
||||||
"packaging_format": 1,
|
|
||||||
"description": {
|
|
||||||
"en": "A hierarchical note taking application with focus on building large personal knowledge base",
|
|
||||||
"fr": "Une application de prise de note hiérarchique centrée sur la construction d'une large base de connaissances personnelle"
|
|
||||||
},
|
|
||||||
"version": "0.57.5~ynh1",
|
|
||||||
"url": "https://github.com/zadam/trilium",
|
|
||||||
"upstream": {
|
|
||||||
"license": "AGPL-3.0-only",
|
|
||||||
"admindoc": "https://github.com/zadam/trilium/wiki",
|
|
||||||
"code": "https://github.com/zadam/trilium"
|
|
||||||
},
|
|
||||||
"license": "AGPL-3.0-only",
|
|
||||||
"maintainer": {
|
|
||||||
"name": "Jules Bertholet",
|
|
||||||
"email": "jules.bertholet@gmail.com"
|
|
||||||
},
|
|
||||||
"requirements": {
|
|
||||||
"yunohost": ">= 4.3.0"
|
|
||||||
},
|
|
||||||
"multi_instance": true,
|
|
||||||
"services": [
|
|
||||||
"nginx"
|
|
||||||
],
|
|
||||||
"arguments": {
|
|
||||||
"install": [
|
|
||||||
{
|
|
||||||
"name": "domain",
|
|
||||||
"type": "domain"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "is_public",
|
|
||||||
"type": "boolean",
|
|
||||||
"default": true,
|
|
||||||
"help": {
|
|
||||||
"en": "Required for sync with desktop app",
|
|
||||||
"fr": "Nécessaire pour la synchronisation avec l'application desktop"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "instance_name",
|
|
||||||
"type": "string",
|
|
||||||
"ask": {
|
|
||||||
"en": "Choose a unique name for this instance (optional)",
|
|
||||||
"fr": "Choisissez un nom unique pour cette instance (facultatif)"
|
|
||||||
},
|
|
||||||
"example": "MyTrillium",
|
|
||||||
"optional": true,
|
|
||||||
"default": ""
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
68
manifest.toml
Normal file
68
manifest.toml
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
packaging_format = 2
|
||||||
|
|
||||||
|
id = "trilium"
|
||||||
|
name = "Trilium Notes"
|
||||||
|
description.en = "A hierarchical note taking application with focus on building large personal knowledge base"
|
||||||
|
description.fr = "Une application de prise de note hiérarchique centrée sur la construction d'une large base de connaissances personnelle"
|
||||||
|
|
||||||
|
version = "0.58.8~ynh1"
|
||||||
|
|
||||||
|
maintainers = ["Jules Bertholet"]
|
||||||
|
|
||||||
|
[upstream]
|
||||||
|
license = "AGPL-3.0-only"
|
||||||
|
admindoc = "https://github.com/zadam/trilium/wiki"
|
||||||
|
code = "https://github.com/zadam/trilium"
|
||||||
|
cpe = "cpe:2.3:a:trilium_project:trilium"
|
||||||
|
fund = "https://github.com/sponsors/zadam"
|
||||||
|
|
||||||
|
[integration]
|
||||||
|
yunohost = ">= 11.1.11.1"
|
||||||
|
architectures = [ "amd64" ]
|
||||||
|
multi_instance = true
|
||||||
|
ldap = false
|
||||||
|
sso = false
|
||||||
|
disk = "200M"
|
||||||
|
ram.build = "350M"
|
||||||
|
ram.runtime = "110M"
|
||||||
|
|
||||||
|
[install]
|
||||||
|
[install.domain]
|
||||||
|
# this is a generic question - ask strings are automatically handled by Yunohost's core
|
||||||
|
type = "domain"
|
||||||
|
full_domain = true
|
||||||
|
|
||||||
|
[install.init_main_permission]
|
||||||
|
help.en = "Required for sync with desktop app"
|
||||||
|
help.fr = "Nécessaire pour la synchronisation avec l'application desktop"
|
||||||
|
type = "group"
|
||||||
|
default = "visitors"
|
||||||
|
|
||||||
|
[install.instance_name]
|
||||||
|
ask.en = "Choose a unique name for this instance (optional)"
|
||||||
|
ask.fr = "Choisissez un nom unique pour cette instance (facultatif)"
|
||||||
|
type = "string"
|
||||||
|
example = "MyTrillium"
|
||||||
|
optional = true
|
||||||
|
default = ""
|
||||||
|
|
||||||
|
[resources]
|
||||||
|
|
||||||
|
[resources.system_user]
|
||||||
|
|
||||||
|
[resources.install_dir]
|
||||||
|
|
||||||
|
[resources.data_dir]
|
||||||
|
|
||||||
|
[resources.permissions]
|
||||||
|
main.url = "/"
|
||||||
|
|
||||||
|
[resources.ports]
|
||||||
|
main.default = 8095
|
||||||
|
|
||||||
|
[resources.apt]
|
||||||
|
packages = "libpng16-16, libpng-dev, pkg-config, autoconf, libtool, build-essential, nasm, libx11-dev, libxkbfile-dev"
|
||||||
|
|
||||||
|
extras.yarn.repo = "deb https://dl.yarnpkg.com/debian/ stable main"
|
||||||
|
extras.yarn.key = "https://dl.yarnpkg.com/debian/pubkey.gpg"
|
||||||
|
extras.yarn.packages = "yarn"
|
|
@ -6,9 +6,6 @@
|
||||||
|
|
||||||
nodejs_version=16
|
nodejs_version=16
|
||||||
|
|
||||||
# dependencies used by the app
|
|
||||||
pkg_dependencies="libpng16-16 libpng-dev pkg-config autoconf libtool build-essential nasm libx11-dev libxkbfile-dev"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
33
scripts/backup
Executable file → Normal file
33
scripts/backup
Executable file → Normal file
|
@ -10,43 +10,28 @@
|
||||||
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)
|
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_print_info --message="Declaring files to be backed up..."
|
ynh_print_info --message="Declaring files to be backed up..."
|
||||||
|
|
||||||
|
### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs
|
||||||
|
### to be backuped and not an actual copy of any file. The actual backup that
|
||||||
|
### creates and fill the archive with the files happens in the core after this
|
||||||
|
### script is called. Hence ynh_backups calls takes basically 0 seconds to run.
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE APP MAIN DIR
|
# BACKUP THE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$final_path"
|
ynh_backup --src_path="$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE DATA DIR
|
# BACKUP THE DATA DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup --src_path="$datadir" --is_big
|
# Only relevant if there is a "data_dir" resource for this app
|
||||||
|
ynh_backup --src_path="$data_dir" --is_big
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP THE NGINX CONFIGURATION
|
# BACKUP THE NGINX CONFIGURATION
|
||||||
|
@ -66,4 +51,4 @@ ynh_backup --src_path="/etc/systemd/system/$app.service"
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_print_info --message="Backup script completed for $app. (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)."
|
292
scripts/install
Executable file → Normal file
292
scripts/install
Executable file → Normal file
|
@ -9,98 +9,58 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
# Install parameters are automatically saved as settings
|
||||||
# MANAGE SCRIPT FAILURE
|
#
|
||||||
#=================================================
|
# Settings are automatically loaded as bash variables
|
||||||
|
# in every app script context, therefore typically these will exist:
|
||||||
|
# - $domain
|
||||||
|
# - $path
|
||||||
|
# - $language
|
||||||
|
# ... etc
|
||||||
|
#
|
||||||
|
# Resources defined in the manifest are provisioned prior to this script
|
||||||
|
# and corresponding settings are also available, such as:
|
||||||
|
# - $install_dir
|
||||||
|
# - $port
|
||||||
|
# - $db_name
|
||||||
|
# ...
|
||||||
|
|
||||||
ynh_clean_setup () {
|
#
|
||||||
ynh_clean_check_starting
|
# $app is the app id (i.e. 'example' for first install,
|
||||||
}
|
# or 'example__2', '__3', ... for multi-instance installs)
|
||||||
# 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=10
|
||||||
|
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
|
||||||
path_url="/"
|
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
|
||||||
instance_name=$YNH_APP_ARG_INSTANCE_NAME
|
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Validating installation parameters..." --weight=1
|
|
||||||
|
|
||||||
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=instance_name --value=$instance_name
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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=8095)
|
|
||||||
ynh_app_setting_set --app=$app --key=port --value=$port
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INSTALL DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Installing dependencies..." --weight=60
|
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
|
||||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||||
ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
|
||||||
#=================================================
|
|
||||||
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=5
|
ynh_script_progression --message="Setting up source files..." --weight=10
|
||||||
|
|
||||||
|
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
|
||||||
|
### downloaded from an upstream source, like a git repository.
|
||||||
|
### `ynh_setup_source` use the file conf/app.src
|
||||||
|
|
||||||
ynh_app_setting_set --app=$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"
|
||||||
|
|
||||||
grep -v electron "$final_path/package.json" > "$final_path/server-package.json"
|
grep -v electron "$install_dir/package.json" > "$install_dir/server-package.json"
|
||||||
mv "$final_path/server-package.json" "$final_path/package.json"
|
mv "$install_dir/server-package.json" "$install_dir/package.json"
|
||||||
|
# $install_dir will automatically be initialized with some decent
|
||||||
|
# permission by default ... however, you may need to recursively reapply
|
||||||
|
# ownership to all files such as after the ynh_setup_source step
|
||||||
|
chmod 750 "$install_dir"
|
||||||
|
chmod -R o-rwx "$install_dir"
|
||||||
|
chown -R $app:www-data "$install_dir"
|
||||||
|
|
||||||
chmod 750 "$final_path"
|
ynh_exec_as root echo ~$app
|
||||||
chmod -R o-rwx "$final_path"
|
|
||||||
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
|
# SPECIFIC SETUP
|
||||||
|
@ -109,84 +69,150 @@ ynh_add_nginx_config
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing Node.js packages ..." --weight=45
|
ynh_script_progression --message="Installing Node.js packages ..." --weight=45
|
||||||
|
|
||||||
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
|
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install ./
|
||||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm rebuild
|
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm rebuild ./
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DATA DIRECTORY
|
# SYSTEM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Creating a data directory..."
|
ynh_script_progression --message="Adding system configurations related to $app ..." --weight=1
|
||||||
|
|
||||||
datadir=/home/yunohost.app/$app
|
### `ynh_add_fpm_config` is used to set up a PHP config.
|
||||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
### You can remove it if your app doesn't use PHP.
|
||||||
|
### `ynh_add_fpm_config` will use the files conf/php-fpm.conf
|
||||||
|
### If you're not using these lines:
|
||||||
|
### - You can remove these files in conf/.
|
||||||
|
### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script
|
||||||
|
### - Remove also the section "REMOVE PHP-FPM CONFIGURATION" in the remove script
|
||||||
|
### - As well as the section "RESTORE THE PHP-FPM CONFIGURATION" in the restore script
|
||||||
|
### with the reload at the end of the script.
|
||||||
|
### - And the section "PHP-FPM CONFIGURATION" in the upgrade script
|
||||||
|
|
||||||
mkdir -p $datadir
|
# Create a dedicated NGINX config using the conf/nginx.conf template
|
||||||
|
ynh_add_nginx_config
|
||||||
|
|
||||||
chmod 750 "$datadir"
|
### `ynh_systemd_config` is used to configure a systemd script for an app.
|
||||||
chmod -R o-rwx "$datadir"
|
### It can be used for apps that use sysvinit (with adaptation) or systemd.
|
||||||
chown -R $app:www-data "$datadir"
|
### Have a look at the app to be sure this app needs a systemd script.
|
||||||
|
### `ynh_systemd_config` will use the file conf/systemd.service
|
||||||
#=================================================
|
### If you're not using these lines:
|
||||||
# ADD A CONFIGURATION
|
### - You can remove those files in conf/.
|
||||||
#=================================================
|
### - Remove the section "BACKUP SYSTEMD" in the backup script
|
||||||
ynh_script_progression --message="Adding a configuration file..."
|
### - Remove also the section "STOP AND REMOVE SERVICE" in the remove script
|
||||||
|
### - As well as the section "RESTORE SYSTEMD" in the restore script
|
||||||
ynh_add_config --template="../conf/config.ini" --destination="$final_path/config.ini"
|
### - And the section "SETUP SYSTEMD" in the upgrade script
|
||||||
ln -sf $final_path/config.ini $datadir/config.ini
|
|
||||||
|
|
||||||
chmod 400 "$final_path/config.ini"
|
|
||||||
chown $app:$app "$final_path/config.ini"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP SYSTEMD
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring a systemd service..." --weight=1
|
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
# Create a dedicated systemd config
|
||||||
ynh_add_systemd_config
|
ynh_add_systemd_config
|
||||||
|
|
||||||
#=================================================
|
### `yunohost service add` integrates a service in YunoHost. It then gets
|
||||||
# GENERIC FINALIZATION
|
### displayed in the admin interface and through the others `yunohost service` commands.
|
||||||
#=================================================
|
### (N.B.: this line only makes sense if the app adds a service to the system!)
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
### If you're not using these lines:
|
||||||
#=================================================
|
### - You can remove these files in conf/.
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
### - Remove the section "REMOVE SERVICE INTEGRATION IN YUNOHOST" in the remove script
|
||||||
|
### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script
|
||||||
|
### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade script
|
||||||
|
|
||||||
yunohost service add $app --description="Trilium Notes app" --log="systemd"
|
yunohost service add $app --description="Trilium Notes app" --log="systemd"
|
||||||
|
|
||||||
|
### Additional options starting with 3.8:
|
||||||
|
###
|
||||||
|
### --needs_exposed_ports "$port" a list of ports that needs to be publicly exposed
|
||||||
|
### which will then be checked by YunoHost's diagnosis system
|
||||||
|
### (N.B. DO NOT USE THIS is the port is only internal!!!)
|
||||||
|
###
|
||||||
|
### --test_status "some command" a custom command to check the status of the service
|
||||||
|
### (only relevant if 'systemctl status' doesn't do a good job)
|
||||||
|
###
|
||||||
|
### --test_conf "some command" some command similar to "nginx -t" that validates the conf of the service
|
||||||
|
###
|
||||||
|
### Re-calling 'yunohost service add' during the upgrade script is the right way
|
||||||
|
### to proceed if you later realize that you need to enable some flags that
|
||||||
|
### weren't enabled on old installs (be careful it'll override the existing
|
||||||
|
### service though so you should re-provide all relevant flags when doing so)
|
||||||
|
|
||||||
|
### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app.
|
||||||
|
### Use this helper only if there is effectively a log file for this app.
|
||||||
|
### If you're not using this helper:
|
||||||
|
### - Remove the section "BACKUP LOGROTATE" in the backup script
|
||||||
|
### - Remove also the section "REMOVE LOGROTATE CONFIGURATION" in the remove script
|
||||||
|
### - As well as the section "RESTORE THE LOGROTATE CONFIGURATION" in the restore script
|
||||||
|
### - And the section "SETUP LOGROTATE" in the upgrade script
|
||||||
|
|
||||||
|
# Create a dedicated Fail2Ban config
|
||||||
|
#ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# APP INITIAL CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
# ADD A CONFIGURATION
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
||||||
|
|
||||||
|
### You can add specific configuration files.
|
||||||
|
###
|
||||||
|
### Typically, put your template conf file in ../conf/your_config_file
|
||||||
|
### The template may contain strings such as __FOO__ or __FOO_BAR__,
|
||||||
|
### which will automatically be replaced by the values of $foo and $foo_bar
|
||||||
|
###
|
||||||
|
### ynh_add_config will also keep track of the config file's checksum,
|
||||||
|
### which later during upgrade may allow to automatically backup the config file
|
||||||
|
### if it's found that the file was manually modified
|
||||||
|
###
|
||||||
|
### Check the documentation of `ynh_add_config` for more info.
|
||||||
|
|
||||||
|
ynh_add_config --template="../conf/config.ini" --destination="$install_dir/config.ini"
|
||||||
|
ln -sf $install_dir/config.ini $data_dir/config.ini
|
||||||
|
|
||||||
|
# FIXME: this should be handled by the core in the future
|
||||||
|
# You may need to use chmod 600 instead of 400,
|
||||||
|
# for example if the app is expected to be able to modify its own config
|
||||||
|
chmod 400 "$install_dir/config.ini"
|
||||||
|
chown $app:$app "$install_dir/config.ini"
|
||||||
|
|
||||||
|
### For more complex cases where you want to replace stuff using regexes,
|
||||||
|
### you shoud rely on ynh_replace_string (which is basically a wrapper for sed)
|
||||||
|
### When doing so, you also need to manually call ynh_store_file_checksum
|
||||||
|
###
|
||||||
|
### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$install_dir/some_config_file"
|
||||||
|
### ynh_store_file_checksum --file="$install_dir/some_config_file"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SETUP APPLICATION WITH CURL
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
### Use these lines only if the app installation needs to be finalized through
|
||||||
|
### web forms. We generally don't want to ask the final user,
|
||||||
|
### so we're going to use curl to automatically fill the fields and submit the
|
||||||
|
### forms.
|
||||||
|
|
||||||
|
# Installation with curl
|
||||||
|
#ynh_script_progression --message="Finalizing installation..." --weight=1
|
||||||
|
#ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||||
|
|
||||||
|
### `ynh_systemd_action` is used to start a systemd service for an app.
|
||||||
|
### Only needed if you have configure a systemd service
|
||||||
|
### If you're not using these lines:
|
||||||
|
### - Remove the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the backup script
|
||||||
|
### - As well as the section "START SYSTEMD SERVICE" in the restore script
|
||||||
|
### - As well as the section"STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the upgrade script
|
||||||
|
### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script
|
||||||
|
|
||||||
# Start a systemd service
|
# Start a systemd service
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Listening on port"
|
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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=1
|
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Installation of $app completed" --last
|
||||||
ynh_script_progression --message="Installation of $app completed" --last
|
|
81
scripts/remove
Executable file → Normal file
81
scripts/remove
Executable file → Normal file
|
@ -9,87 +9,44 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
# Settings are automatically loaded as bash variables
|
||||||
# LOAD SETTINGS
|
# in every app script context, therefore typically these will exist:
|
||||||
#=================================================
|
# - $domain
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
# - $path
|
||||||
|
# - $language
|
||||||
|
# - $install_dir
|
||||||
|
# - $port
|
||||||
|
# ...
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
# For remove operations :
|
||||||
|
# - the core will deprovision every resource defined in the manifest **after** this script is ran
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
# this includes removing the install directory, and data directory (if --purge was used)
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STANDARD REMOVE
|
# REMOVE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
# REMOVE SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Removing system configurations related to $app..." --weight=60
|
||||||
|
|
||||||
|
# This should be a symetric version of what happens in the install script
|
||||||
|
|
||||||
# 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
|
||||||
ynh_script_progression --message="Removing $app service integration..." --weight=1
|
ynh_script_progression --message="Removing $app service integration..." --weight=30
|
||||||
yunohost service remove $app
|
yunohost service remove $app
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STOP AND REMOVE SERVICE
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Stopping and removing the systemd service..." --weight=30
|
|
||||||
|
|
||||||
# Remove the dedicated systemd config
|
|
||||||
ynh_remove_systemd_config
|
ynh_remove_systemd_config
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE APP MAIN DIR
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing app main directory..." --weight=1
|
|
||||||
|
|
||||||
# Remove the app directory securely
|
|
||||||
ynh_secure_remove --file="$final_path"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE DATA DIR
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
# Remove the data directory if --purge option is used
|
|
||||||
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
|
|
||||||
then
|
|
||||||
ynh_script_progression --message="Removing app data directory..."
|
|
||||||
ynh_secure_remove --file="$datadir"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
|
|
||||||
|
|
||||||
# Remove the dedicated NGINX config
|
|
||||||
ynh_remove_nginx_config
|
ynh_remove_nginx_config
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# REMOVE DEPENDENCIES
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing dependencies..." --weight=30
|
|
||||||
|
|
||||||
# Remove metapackage and its dependencies
|
|
||||||
ynh_remove_app_dependencies
|
|
||||||
ynh_remove_nodejs
|
ynh_remove_nodejs
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Removal of $app completed" --last
|
ynh_script_progression --message="Removal of $app completed" --last
|
103
scripts/restore
Executable file → Normal file
103
scripts/restore
Executable file → Normal file
|
@ -10,117 +10,58 @@
|
||||||
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 () {
|
|
||||||
ynh_clean_check_starting
|
|
||||||
}
|
|
||||||
# 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)
|
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK IF THE APP CAN BE RESTORED
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Validating restoration parameters..." --weight=1
|
|
||||||
|
|
||||||
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=1
|
|
||||||
|
|
||||||
# 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=20
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$final_path"
|
ynh_restore_file --origin_path="$install_dir"
|
||||||
|
|
||||||
chmod 750 "$final_path"
|
# $install_dir will automatically be initialized with some decent
|
||||||
chmod -R o-rwx "$final_path"
|
# permission by default ... however, you may need to recursively reapply
|
||||||
chown -R $app:www-data "$final_path"
|
# ownership to all files such as after the ynh_setup_source step
|
||||||
|
chown -R $app:www-data "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE DATA DIRECTORY
|
# RESTORE THE DATA DIRECTORY
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the data directory..."
|
ynh_script_progression --message="Restoring the data directory..." --weight=50
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$datadir" --not_mandatory
|
ynh_restore_file --origin_path="$data_dir" --not_mandatory
|
||||||
|
|
||||||
mkdir -p $datadir
|
# (Same as for install dir)
|
||||||
|
chown -R $app:www-data "$data_dir"
|
||||||
chmod 750 "$datadir"
|
|
||||||
chmod -R o-rwx "$datadir"
|
|
||||||
chown -R $app:www-data "$datadir"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# INSTALL NODEJS
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
ynh_script_progression --message="Installing nodejs..." --weight=20
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Reinstalling dependencies..." --weight=40
|
|
||||||
|
|
||||||
# Define and install dependencies
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
|
||||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||||
ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE NGINX CONFIGURATION
|
# RESTORE SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the NGINX web server configuration..."
|
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=10
|
||||||
|
|
||||||
|
# This should be a symetric version of what happens in the install script
|
||||||
|
|
||||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RESTORE SYSTEMD
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
|
||||||
|
|
||||||
yunohost service add $app --description="Trilium Notes app" --log="systemd"
|
yunohost service add $app --description="Trilium Notes app" --log="systemd"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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="Listening on port"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# RELOAD NGINX
|
# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1
|
||||||
|
|
||||||
|
# Typically you only have either $app or php-fpm but not both at the same time...
|
||||||
|
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Listening on port"
|
||||||
|
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
|
|
||||||
|
@ -128,4 +69,4 @@ ynh_systemd_action --service_name=nginx --action=reload
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Restoration completed for $app" --last
|
ynh_script_progression --message="Restoration completed for $app" --last
|
193
scripts/upgrade
193
scripts/upgrade
|
@ -9,45 +9,52 @@
|
||||||
source _common.sh
|
source _common.sh
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
# Settings are automatically loaded as bash variables
|
||||||
# LOAD SETTINGS
|
# in every app script context, therefore typically these will exist:
|
||||||
#=================================================
|
# - $domain
|
||||||
ynh_script_progression --message="Loading installation settings..." --weight=1
|
# - $path
|
||||||
|
# - $language
|
||||||
|
# - $install_dir
|
||||||
|
# - $port
|
||||||
|
# ...
|
||||||
|
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
# In the context of upgrade,
|
||||||
|
# - resources are automatically provisioned / updated / deleted (depending on existing resources)
|
||||||
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
# - a safety backup is automatically created by the core and will be restored if the upgrade fails
|
||||||
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
|
||||||
admin=$(ynh_app_setting_get --app=$app --key=admin)
|
|
||||||
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=datadir)
|
|
||||||
port=$(ynh_app_setting_get --app=$app --key=port)
|
|
||||||
instance_name=$(ynh_app_setting_get --app=$app --key=instance_name)
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CHECK VERSION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Checking version..."
|
|
||||||
|
|
||||||
|
### This helper will compare the version of the currently installed app and the version of the upstream package.
|
||||||
|
### $upgrade_type can have 2 different values
|
||||||
|
### - UPGRADE_APP if the upstream app version has changed
|
||||||
|
### - UPGRADE_PACKAGE if only the YunoHost package has changed
|
||||||
|
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
|
||||||
|
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
|
||||||
upgrade_type=$(ynh_check_app_version_changed)
|
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=15
|
|
||||||
|
|
||||||
# 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
|
# STANDARD UPGRADE STEPS
|
||||||
|
#=================================================
|
||||||
|
# ENSURE DOWNWARD COMPATIBILITY
|
||||||
|
#=================================================
|
||||||
|
#ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1
|
||||||
|
|
||||||
|
#
|
||||||
|
# N.B. : the followings setting migrations snippets are provided as *EXAMPLES*
|
||||||
|
# of what you may want to do in some cases (e.g. a setting was not defined on
|
||||||
|
# some legacy installs and you therefore want to initiaze stuff during upgrade)
|
||||||
|
#
|
||||||
|
|
||||||
|
# If db_name doesn't exist, create it
|
||||||
|
#if [ -z "$db_name" ]; then
|
||||||
|
# db_name=$(ynh_sanitize_dbid --db_name=$app)
|
||||||
|
# ynh_app_setting_set --app=$app --key=db_name --value=$db_name
|
||||||
|
#fi
|
||||||
|
|
||||||
|
# If install_dir doesn't exist, create it
|
||||||
|
#if [ -z "$install_dir" ]; then
|
||||||
|
# install_dir=/var/www/$app
|
||||||
|
# ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir
|
||||||
|
#fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STOP SYSTEMD SERVICE
|
# STOP SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -56,102 +63,89 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=60
|
||||||
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
|
# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD, ETC...)
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Ensuring downward compatibility..."
|
|
||||||
|
|
||||||
# If datadir doesn't exist, create it
|
|
||||||
if [ -z "$datadir" ]; then
|
|
||||||
datadir=$(ynh_app_setting_get --app=$app --key=data_path)
|
|
||||||
ynh_app_setting_set --app=$app --key=datadir --value=$datadir
|
|
||||||
ynh_app_setting_delete --app=$app --key=data_path
|
|
||||||
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
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Upgrading source files..."
|
ynh_script_progression --message="Upgrading source files..." --weight=10
|
||||||
|
|
||||||
# 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" --keep="config.ini"
|
ynh_setup_source --dest_dir="$install_dir" --keep="config.ini"
|
||||||
|
|
||||||
grep -v electron "$final_path/package.json" > "$final_path/server-package.json"
|
grep -v electron "$install_dir/package.json" > "$install_dir/server-package.json"
|
||||||
mv "$final_path/server-package.json" "$final_path/package.json"
|
mv "$install_dir/server-package.json" "$install_dir/package.json"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chmod 750 "$final_path"
|
# $install_dir will automatically be initialized with some decent
|
||||||
chmod -R o-rwx "$final_path"
|
# permission by default ... however, you may need to recursively reapply
|
||||||
chown -R $app:www-data "$final_path"
|
# ownership to all files such as after the ynh_setup_source step
|
||||||
|
chmod 750 "$install_dir"
|
||||||
|
chmod -R o-rwx "$install_dir"
|
||||||
|
chown -R $app:www-data "$install_dir"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE DEPENDENCIES
|
# UPGRADE NODEJS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading dependencies..." --weight=5
|
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies
|
ynh_script_progression --message="Upgrading nodejs..." --weight=5
|
||||||
|
|
||||||
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
|
||||||
ynh_exec_warn_less ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# NGINX CONFIGURATION
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
|
|
||||||
|
|
||||||
# Create a dedicated NGINX config
|
|
||||||
ynh_add_nginx_config
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC UPGRADE
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL NODE PACKAGES
|
# INSTALL NODE PACKAGES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing Node.js packages ..." --weight=45
|
ynh_script_progression --message="Installing Node.js packages ..." --weight=45
|
||||||
|
|
||||||
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
|
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm install ./
|
||||||
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm rebuild
|
ynh_exec_warn_less ynh_exec_as $app $ynh_node_load_PATH $ynh_npm rebuild ./
|
||||||
popd
|
popd
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPDATE A CONFIG FILE
|
# REAPPLY SYSTEM CONFIGURATIONS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Updating a configuration file..."
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||||||
|
|
||||||
ynh_add_config --template="../conf/config.ini" --destination="$final_path/config.ini"
|
# This should be a literal copypasta of what happened in the install's "System configuration" section
|
||||||
ln -sf $final_path/config.ini $datadir/config.ini
|
|
||||||
|
|
||||||
chmod 400 "$final_path/config.ini"
|
ynh_add_nginx_config
|
||||||
chown $app:$app "$final_path/config.ini"
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SETUP SYSTEMD
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
|
||||||
|
|
||||||
# Create a dedicated systemd config
|
|
||||||
ynh_add_systemd_config
|
ynh_add_systemd_config
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# GENERIC FINALIZATION
|
|
||||||
#=================================================
|
|
||||||
# INTEGRATE SERVICE IN YUNOHOST
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
|
||||||
|
|
||||||
yunohost service add $app --description="Trilium Notes app" --log="systemd"
|
yunohost service add $app --description="Trilium Notes app" --log="systemd"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS, ...)
|
||||||
|
#=================================================
|
||||||
|
# UPDATE A CONFIG FILE
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
||||||
|
|
||||||
|
### Same as during install
|
||||||
|
###
|
||||||
|
### The file will automatically be backed-up if it's found to be manually modified (because
|
||||||
|
### ynh_add_config keeps track of the file's checksum)
|
||||||
|
|
||||||
|
ynh_add_config --template="../conf/config.ini" --destination="$install_dir/config.ini"
|
||||||
|
ln -sf $install_dir/config.ini $data_dir/config.ini
|
||||||
|
|
||||||
|
# FIXME: this should be handled by the core in the future
|
||||||
|
# You may need to use chmod 600 instead of 400,
|
||||||
|
# for example if the app is expected to be able to modify its own config
|
||||||
|
chmod 400 "$install_dir/config.ini"
|
||||||
|
chown $app:$app "$install_dir/config.ini"
|
||||||
|
|
||||||
|
### For more complex cases where you want to replace stuff using regexes,
|
||||||
|
### you shoud rely on ynh_replace_string (which is basically a wrapper for sed)
|
||||||
|
### When doing so, you also need to manually call ynh_store_file_checksum
|
||||||
|
###
|
||||||
|
### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$install_dir/some_config_file"
|
||||||
|
### ynh_store_file_checksum --file="$install_dir/some_config_file"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# START SYSTEMD SERVICE
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -159,15 +153,8 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1
|
||||||
|
|
||||||
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Listening on port"
|
ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Listening on port"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# 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
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
ynh_script_progression --message="Upgrade of $app completed" --last
|
54
tests.toml
Normal file
54
tests.toml
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
test_format = 1.0
|
||||||
|
|
||||||
|
[default]
|
||||||
|
|
||||||
|
# ------------
|
||||||
|
# Tests to run
|
||||||
|
# ------------
|
||||||
|
|
||||||
|
# NB: the tests to run are automatically deduced by the CI script according to the
|
||||||
|
# content of the app's manifest. The declarations below allow to customize which
|
||||||
|
# tests are ran, possibly add special test suite to test special args, or
|
||||||
|
# declare which commits to test upgrade from.
|
||||||
|
#
|
||||||
|
# You can also decide (though this is discouraged!) to ban/ignore some tests,
|
||||||
|
|
||||||
|
#exclude = ["install.private", "install.multi"] # NB : you should NOT need this except if you really have a good reason ...
|
||||||
|
|
||||||
|
# For special usecases, sometimes you need to setup other things on the machine
|
||||||
|
# prior to installing the app (such as installing another app)
|
||||||
|
# (Remove this key entirely if not needed)
|
||||||
|
#preinstall = """
|
||||||
|
#sudo yunohost app install foobar
|
||||||
|
#sudo yunohost user list
|
||||||
|
#"""
|
||||||
|
|
||||||
|
# -------------------------------
|
||||||
|
# Default args to use for install
|
||||||
|
# -------------------------------
|
||||||
|
|
||||||
|
# By default, the CI will automagically fill the 'standard' args
|
||||||
|
# such as domain, path, admin, is_public and password with relevant values
|
||||||
|
# and also install args with a "default" provided in the manifest..
|
||||||
|
# It should only make sense to declare custom args here for args with no default values
|
||||||
|
|
||||||
|
#args.language = "fr_FR" # NB : you should NOT need those lines unless for custom questions with no obvious/default value
|
||||||
|
#args.multisite = 0
|
||||||
|
|
||||||
|
# -------------------------------
|
||||||
|
# Commits to test upgrade from
|
||||||
|
# -------------------------------
|
||||||
|
|
||||||
|
test_upgrade_from.85a53b5.name = "Merge pull request #36 from YunoHost-Apps/testing"
|
||||||
|
#test_upgrade_from.00a1a6e7.args.foo = "bar"
|
||||||
|
|
||||||
|
|
||||||
|
# This is an additional test suite
|
||||||
|
#[some_additional_testsuite]
|
||||||
|
|
||||||
|
# On additional tests suites, you can decide to run only specific tests
|
||||||
|
|
||||||
|
#only = ["install.subdir"]
|
||||||
|
|
||||||
|
#args.language = "en_GB"
|
||||||
|
#args.multisite = 1
|
Loading…
Add table
Reference in a new issue