mise en place package
This commit is contained in:
4
LICENSE
Normal file
4
LICENSE
Normal file
@@ -0,0 +1,4 @@
|
||||
File containing the license of your package.
|
||||
|
||||
More information here:
|
||||
https://choosealicense.com/
|
||||
85
README.md
Normal file
85
README.md
Normal file
@@ -0,0 +1,85 @@
|
||||
# Packaging an app, starting from this example
|
||||
|
||||
* Copy this app before working on it, using the ['Use this template'](https://github.com/new?template_name=example_ynh&template_owner=YunoHost) button on the GitHub repo.
|
||||
* Edit the `manifest.toml` with app specific info.
|
||||
* Edit the `install`, `upgrade`, `remove`, `backup` and `restore` scripts, and any relevant conf files in `conf/`.
|
||||
* Using the [script helpers documentation.](https://doc.yunohost.org/dev/packaging/scripts/helpers_v2.1/)
|
||||
* Edit the `change_url` and `config` scripts too, or remove them if you have no use of them
|
||||
* Add a `LICENSE` file for the package. NB: this LICENSE file is not meant to necessarily be the LICENSE of the upstream app - it is only the LICENSE you want this package's code to published with ;). We recommend to use [the AGPL-3](https://www.gnu.org/licenses/agpl-3.0.txt).
|
||||
* Edit files under the `doc/` directory
|
||||
* The `README.md` files are to be automatically generated by <https://github.com/YunoHost/apps/tree/main/tools/readme_generator>
|
||||
|
||||
---
|
||||
<!--
|
||||
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/main/tools/readme_generator
|
||||
It shall NOT be edited by hand.
|
||||
-->
|
||||
|
||||
# Example app for YunoHost
|
||||
|
||||
[](https://dash.yunohost.org/appci/app/example)  <br>
|
||||
[](https://install-app.yunohost.org/?app=example)
|
||||
|
||||
*[Lire ce readme en français.](./README_fr.md)*
|
||||
|
||||
> *This package allows you to install Example app quickly and simply on a YunoHost server.
|
||||
If you don't have YunoHost, please consult [the guide](https://doc.yunohost.org/admin/get_started/install_on/) to learn how to install it.*
|
||||
|
||||
## Overview
|
||||
|
||||
Some long and extensive description of what the app is and does, lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||
|
||||
### Features
|
||||
|
||||
- Ut enim ad minim veniam, quis nostrud exercitation ullamco ;
|
||||
- Laboris nisi ut aliquip ex ea commodo consequat ;
|
||||
- Duis aute irure dolor in reprehenderit in voluptate ;
|
||||
- Velit esse cillum dolore eu fugiat nulla pariatur ;
|
||||
- Excepteur sint occaecat cupidatat non proident, sunt in culpa."
|
||||
|
||||
|
||||
**Shipped version:** 1.0~ynh1
|
||||
|
||||
**Demo:** https://demo.example.com
|
||||
|
||||
## Screenshots
|
||||
|
||||

|
||||
|
||||
## Disclaimers / important information
|
||||
|
||||
* Any known limitations, constrains or stuff not working, such as (but not limited to):
|
||||
* requiring a full dedicated domain ?
|
||||
* architectures not supported ?
|
||||
* not-working single-sign on or LDAP integration ?
|
||||
* the app requires an important amount of RAM / disk / .. to install or to work properly
|
||||
* etc...
|
||||
|
||||
* Other infos that people should be aware of, such as:
|
||||
* any specific step to perform after installing (such as manually finishing the install, specific admin credentials, ...)
|
||||
* how to configure / administrate the application if it ain't obvious
|
||||
* upgrade process / specificities / things to be aware of ?
|
||||
* security considerations ?
|
||||
|
||||
## Documentation and resources
|
||||
|
||||
* Official app website: <https://example.com>
|
||||
* Official user documentation: <https://yunohost.org/apps>
|
||||
* Official admin documentation: <https://doc.yunohost.org/dev/packaging/>
|
||||
* Upstream app code repository: <https://some.forge.com/example/example>
|
||||
* YunoHost documentation for this app: <https://yunohost.org/app_example>
|
||||
* Report a bug: <https://github.com/YunoHost-Apps/example_ynh/issues>
|
||||
|
||||
## Developer info
|
||||
|
||||
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/example_ynh/tree/testing).
|
||||
|
||||
To try the testing branch, please proceed like that.
|
||||
|
||||
``` bash
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/example_ynh/tree/testing --debug
|
||||
or
|
||||
sudo yunohost app upgrade example -u https://github.com/YunoHost-Apps/example_ynh/tree/testing --debug
|
||||
```
|
||||
|
||||
**More info regarding app packaging:** <https://doc.yunohost.org/dev/packaging/>
|
||||
85
README_fr.md
Normal file
85
README_fr.md
Normal file
@@ -0,0 +1,85 @@
|
||||
# Emballage d'une application, à partir de cet exemple
|
||||
|
||||
* Copier cette application avant de travailler dessus, en utilisant le bouton ['Use this template'](https://github.com/new?template_name=example_ynh&template_owner=YunoHost) sur le repo GitHub.
|
||||
* Editer le fichier `manifest.toml` avec les informations spécifiques à l'application.
|
||||
* Editer les scripts `install`, `upgrade`, `remove`, `backup` et `restore`, et tous les fichiers de conf pertinents dans `conf/`.
|
||||
* Utiliser la [documentation sur les aides aux scripts] (https://yunohost.org/packaging_apps_helpers).
|
||||
* Éditez aussi les scripts `change_url` et `config`, ou supprimez-les si vous n'en avez pas l'utilité.
|
||||
* Ajouter un fichier `LICENSE` pour le paquet. NB : ce fichier LICENSE n'est pas nécessairement la LICENSE de l'application en amont - c'est seulement la LICENSE avec laquelle vous voulez que le code de ce paquet soit publié ;). Nous recommandons d'utiliser [l'AGPL-3] (https://www.gnu.org/licenses/agpl-3.0.txt).
|
||||
* Editer les fichiers dans le répertoire `doc/`.
|
||||
* Les fichiers `README.md` doivent être générés automatiquement par <https://github.com/YunoHost/apps/tree/main/tools/readme_generator>
|
||||
|
||||
---
|
||||
<!--
|
||||
N.B. : Ce README a été généré automatiquement par https://github.com/YunoHost/apps/tree/main/tools/readme_generator
|
||||
Il ne doit PAS être édité à la main.
|
||||
-->
|
||||
|
||||
# Exemple d'app pour YunoHost
|
||||
|
||||
[](https://dash.yunohost.org/appci/app/example)  
|
||||
[](https://install-app.yunohost.org/?app=example)
|
||||
|
||||
*[Read this readme in english.](./README.md)*
|
||||
|
||||
> *Ce package vous permet d'installer Example app rapidement et simplement sur un serveur YunoHost.
|
||||
Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
|
||||
|
||||
## Vue d'ensemble
|
||||
|
||||
Some long and extensive description of what the app is and does, lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||
|
||||
### Features
|
||||
|
||||
- Ut enim ad minim veniam, quis nostrud exercitation ullamco ;
|
||||
- Laboris nisi ut aliquip ex ea commodo consequat ;
|
||||
- Duis aute irure dolor in reprehenderit in voluptate ;
|
||||
- Velit esse cillum dolore eu fugiat nulla pariatur ;
|
||||
- Excepteur sint occaecat cupidatat non proident, sunt in culpa."
|
||||
|
||||
|
||||
**Version incluse :** 1.0~ynh1
|
||||
|
||||
**Démo :** https://demo.example.com
|
||||
|
||||
## Captures d'écran
|
||||
|
||||

|
||||
|
||||
## Avertissements / informations importantes
|
||||
|
||||
* Any known limitations, constrains or stuff not working, such as (but not limited to):
|
||||
* requiring a full dedicated domain ?
|
||||
* architectures not supported ?
|
||||
* not-working single-sign on or LDAP integration ?
|
||||
* the app requires an important amount of RAM / disk / .. to install or to work properly
|
||||
* etc...
|
||||
|
||||
* Other infos that people should be aware of, such as:
|
||||
* any specific step to perform after installing (such as manually finishing the install, specific admin credentials, ...)
|
||||
* how to configure / administrate the application if it ain't obvious
|
||||
* upgrade process / specificities / things to be aware of ?
|
||||
* security considerations ?
|
||||
|
||||
## Documentations et ressources
|
||||
|
||||
* Site officiel de l'app : <https://example.com>
|
||||
* Documentation officielle utilisateur : <https://yunohost.org/apps>
|
||||
* Documentation officielle de l'admin : <https://yunohost.org/packaging_apps>
|
||||
* Dépôt de code officiel de l'app : <https://some.forge.com/example/example>
|
||||
* Documentation YunoHost pour cette app : <https://yunohost.org/app_example>
|
||||
* Signaler un bug : <https://github.com/YunoHost-Apps/example_ynh/issues>
|
||||
|
||||
## Informations pour les développeurs
|
||||
|
||||
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/example_ynh/tree/testing).
|
||||
|
||||
Pour essayer la branche testing, procédez comme suit.
|
||||
|
||||
``` bash
|
||||
sudo yunohost app install https://github.com/YunoHost-Apps/example_ynh/tree/testing --debug
|
||||
ou
|
||||
sudo yunohost app upgrade example -u https://github.com/YunoHost-Apps/example_ynh/tree/testing --debug
|
||||
```
|
||||
|
||||
**Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>
|
||||
34
conf/nginx.conf
Normal file
34
conf/nginx.conf
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
location __PATH__/static/ {
|
||||
# Service static files by nginx
|
||||
# e.g.: /var/www/$app/static/
|
||||
alias __INSTALL_DIR__/static/;
|
||||
expires 30d;
|
||||
}
|
||||
|
||||
location __PATH__/ {
|
||||
# https://github.com/benoitc/gunicorn/blob/master/examples/nginx.conf
|
||||
|
||||
# this is needed if you have file import via upload enabled
|
||||
client_max_body_size 100M;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Protocol $scheme;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Scheme $scheme;
|
||||
|
||||
# Sets `HTTP_YNH_USER` used in django_yunohost_integration
|
||||
proxy_set_header Ynh-User $http_ynh_user;
|
||||
|
||||
proxy_read_timeout 30;
|
||||
proxy_send_timeout 30;
|
||||
proxy_connect_timeout 30;
|
||||
proxy_redirect off;
|
||||
|
||||
proxy_pass http://127.0.0.1:__PORT__;
|
||||
|
||||
# Include SSOWAT user panel.
|
||||
include conf.d/yunohost_panel.conf.inc;
|
||||
}
|
||||
55
conf/systemd.service
Normal file
55
conf/systemd.service
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
|
||||
[Unit]
|
||||
Description=__APP__ gunicorn server
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=__APP__
|
||||
Group=www-data
|
||||
WorkingDirectory=__INSTALL_DIR__/
|
||||
ExecStart=__INSTALL_DIR__/venv/bin/gunicorn \
|
||||
-c gunicorn.conf.py \
|
||||
djsiteweb.wsgi:application
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
StandardOutput=append:/var/log/__APP__/__APP__.log
|
||||
StandardError=inherit
|
||||
|
||||
### Depending on specificities of your service/app, you may need to tweak these
|
||||
### .. but this should be a good baseline
|
||||
# Sandboxing options to harden security
|
||||
# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
|
||||
NoNewPrivileges=yes
|
||||
PrivateTmp=yes
|
||||
PrivateDevices=yes
|
||||
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
|
||||
RestrictNamespaces=yes
|
||||
RestrictRealtime=yes
|
||||
DevicePolicy=closed
|
||||
ProtectClock=yes
|
||||
ProtectHostname=yes
|
||||
ProtectProc=invisible
|
||||
ProtectSystem=full
|
||||
ProtectControlGroups=yes
|
||||
ProtectKernelModules=yes
|
||||
ProtectKernelTunables=yes
|
||||
LockPersonality=yes
|
||||
SystemCallArchitectures=native
|
||||
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap @cpu-emulation @privileged
|
||||
|
||||
# Denying access to capabilities that should not be relevant for webapps
|
||||
# Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
|
||||
CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD
|
||||
CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE
|
||||
CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT
|
||||
CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK
|
||||
CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM
|
||||
CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
|
||||
CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE
|
||||
CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW
|
||||
CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
137
manifest.toml
Normal file
137
manifest.toml
Normal file
@@ -0,0 +1,137 @@
|
||||
#:schema https://raw.githubusercontent.com/YunoHost/apps/main/schemas/manifest.v2.schema.json
|
||||
|
||||
packaging_format = 2
|
||||
|
||||
id = "vignes"
|
||||
name = "Exploitation Viticole"
|
||||
description.en = "A web app to manage the vinyard."
|
||||
description.fr = "Une application pour gérer l'exploitation viticole."
|
||||
|
||||
version = "0.0~ynh1"
|
||||
|
||||
maintainers = ["Laurent Beltran"]
|
||||
|
||||
[upstream]
|
||||
# NB: Only the "license" key is mandatory. Remove entries for which there's no relevant data
|
||||
license = "free" # you can see the available licenses identifiers list here: https://spdx.org/licenses/
|
||||
#lbn-comment# website = "https://example.com"
|
||||
#lbn-comment# demo = "https://demo.example.com"
|
||||
#lbn-comment# admindoc = "https://doc.yunohost.org/dev/packaging/"
|
||||
#lbn-comment# userdoc = "https://yunohost.org/apps"
|
||||
#lbn-comment# code = "https://some.forge.com/example/example"
|
||||
# FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is
|
||||
# sort of a standard id for applications defined by the NIST. In particular, YunoHost may use this is in the future
|
||||
# to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here:
|
||||
# https://nvd.nist.gov/products/cpe/search.
|
||||
# For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number)
|
||||
#lbn-comment# cpe = "???"
|
||||
|
||||
# FIXME: optional but recommended (or remove if irrelevant / not applicable).
|
||||
# This is meant to be an URL where people can financially support this app, especially when its development is based
|
||||
# on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin.
|
||||
#lbn-comment# fund = "???"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 12.1.17"
|
||||
helpers_version = "2.1"
|
||||
# FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"]
|
||||
architectures = "all"
|
||||
multi_instance = false #lbn-comment# true
|
||||
|
||||
# FIXME: replace with true, false, or "not_relevant".
|
||||
# Not to confuse with the "sso" key: the "ldap" key corresponds to wether or not a user *can* login on the app using
|
||||
# its YunoHost credentials.
|
||||
ldap = true
|
||||
|
||||
# FIXME: replace with true, false, or "not_relevant".
|
||||
# Not to confuse with the "ldap" key: the "sso" key corresponds to wether or not a user is *automatically logged-in*
|
||||
# on the app when logged-in on the YunoHost portal.
|
||||
sso = true
|
||||
|
||||
# FIXME: replace with an **estimate** minimum disk and RAM requirements. e.g. 20M, 400M, 1G...
|
||||
disk = "50M"
|
||||
ram.build = "50M"
|
||||
ram.runtime = "50M"
|
||||
|
||||
[install]
|
||||
[install.domain]
|
||||
# this is a generic question - ask strings are automatically handled by YunoHost's core
|
||||
type = "domain"
|
||||
|
||||
[install.path]
|
||||
# this is a generic question - ask strings are automatically handled by YunoHost's core
|
||||
type = "path"
|
||||
default = "/example"
|
||||
|
||||
[install.init_main_permission]
|
||||
# this is a generic question - ask strings are automatically handled by YunoHost's core
|
||||
# This won't be saved as setting and will instead be used to initialize the SSOwat permission
|
||||
type = "group"
|
||||
default = "visitors"
|
||||
|
||||
[install.language]
|
||||
ask.en = "Choose the application language"
|
||||
ask.fr = "Choisissez la langue de l'application"
|
||||
type = "select"
|
||||
choices = ["fr", "en"]
|
||||
default = "fr"
|
||||
|
||||
[install.admin]
|
||||
# this is a generic question - ask strings are automatically handled by YunoHost's core
|
||||
type = "user"
|
||||
|
||||
[install.password]
|
||||
# this is a generic question - ask strings are automatically handled by YunoHost's core
|
||||
# Note that user-provided passwords questions are not automatically saved as setting
|
||||
help.en = "Use the help field to add an information for the admin about this question."
|
||||
help.fr = "Utilisez le champ aide pour ajouter une information à l'intention de l'administrateur à propos de cette question."
|
||||
type = "password"
|
||||
|
||||
[resources]
|
||||
# See the packaging documentation for the full set
|
||||
# of explanation regarding the behavior and properties for each of those
|
||||
|
||||
[resources.sources]
|
||||
|
||||
[resources.sources.main]
|
||||
# This will pre-fetch the asset which can then be deployed during the install/upgrade scripts with :
|
||||
# ynh_setup_source --dest_dir="$install_dir"
|
||||
# You can also define other assets than "main" and add --source_id="foobar" in the previous command
|
||||
url = "/home/laurent/playing/djangoapp_exploitation.tar.gz"
|
||||
sha256 = "68de7cd0a2343028980dc904532c3d388769466efaae1ac2c24f9fcf7ac21c7b"
|
||||
|
||||
# These infos are used by https://github.com/YunoHost/apps_tools/blob/main/autoupdate_app_sources/autoupdate_app_sources.py
|
||||
# to auto-update the previous asset urls and sha256sum + manifest version
|
||||
# assuming the upstream's code repo is on github and relies on tags or releases
|
||||
# See the 'sources' resource documentation for more details
|
||||
|
||||
# autoupdate.strategy = "latest_github_tag"
|
||||
|
||||
[resources.system_user]
|
||||
# This will provision/deprovision a unix system user
|
||||
|
||||
[resources.install_dir]
|
||||
# This will create/remove the install dir as /var/www/$app
|
||||
# and store the corresponding setting $install_dir
|
||||
|
||||
[resources.data_dir]
|
||||
# This will create/remove the data dir as /home/yunohost.app/$app
|
||||
# and store the corresponding setting $data_dir
|
||||
|
||||
[resources.permissions]
|
||||
# This will configure SSOwat permission for $domain/$path/
|
||||
# The initial allowed group of user is configured via the init_main_permission question (public=visitors, private=all_users)
|
||||
main.url = "/"
|
||||
|
||||
[resources.ports]
|
||||
# This will pick a random port for reverse-proxying and store it as the $port setting
|
||||
default = 8000
|
||||
|
||||
[resources.apt]
|
||||
# This will automatically install/uninstall the following apt packages
|
||||
# and implicitly define the $phpversion setting as 8.0 (if phpX.Y-foobar dependencies are listed)
|
||||
#lbn-comment# packages = "" #lbn-comment# "mariadb-server, deb1, deb2, php8.3-foo, php8.3-bar"
|
||||
|
||||
#lbn-comment# [resources.database]
|
||||
# This will automatically provision/deprovison a MySQL DB and store the corresponding credentials in settings $db_user, $db_name, $db_pwd
|
||||
#lbn-comment# type = "mysql"
|
||||
5
scripts/_common.sh
Normal file
5
scripts/_common.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||
#=================================================
|
||||
46
scripts/change_url
Normal file
46
scripts/change_url
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
## this script is only run if actual change to domain/path is detected, if you're here either $domain or $path changed
|
||||
## new location is available via $domain and $path (or $new_domain and $new_path variables if you want to be explicit)
|
||||
## old values are available via, you guessed it, $old_domain and $old_path
|
||||
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# STOP SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression "Stopping $app's systemd service..."
|
||||
|
||||
ynh_systemctl --service="$app" --action="stop"
|
||||
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression "Updating NGINX web server configuration..."
|
||||
|
||||
# this will most likely adjust NGINX config correctly
|
||||
ynh_config_change_url_nginx
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
|
||||
## do any changes to files that reference specific installation domain/path, i.e. regenerate configs etc
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
ynh_systemctl --service="$app" --action="start"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression "Change of URL completed for $app"
|
||||
199
scripts/install
Normal file
199
scripts/install
Normal file
@@ -0,0 +1,199 @@
|
||||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
### Install parameters are automatically saved as settings
|
||||
###
|
||||
### 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
|
||||
### ...
|
||||
###
|
||||
### $app is the app id (i.e. 'example' for first install,
|
||||
### or 'example__2', '__3'... for multi-instance installs)
|
||||
|
||||
#=================================================
|
||||
# INITIALIZE AND STORE SETTINGS
|
||||
#=================================================
|
||||
|
||||
# If you need to, you can define custom settings
|
||||
# (or remove this section entirely if not relevant for you)
|
||||
#lbn-comment# foo="bar"
|
||||
#lbn-comment# ynh_app_setting_set --key=foo --value=$foo
|
||||
|
||||
#lbn-comment# ynh_app_setting_set --key=php_upload_max_filesize --value=50M
|
||||
#lbn-comment# ynh_app_setting_set --key=php_post_max_size --value=50M
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression "Setting up source files..."
|
||||
|
||||
### `ynh_setup_source` is used to install an app from a zip or tar.gz file,
|
||||
### downloaded from an upstream source, like a git repository.
|
||||
### `ynh_setup_source` use the file manifest.toml
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from manifest.toml
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
|
||||
### $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
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# APP INITIAL CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression "Adding $app's configuration files..."
|
||||
|
||||
### 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_config_add 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_config_add` for more info.
|
||||
|
||||
#lbn-comment# ynh_config_add --template="some_config_file" --destination="$install_dir/some_config_file"
|
||||
|
||||
# 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
|
||||
#lbn-comment# chmod 400 "$install_dir/some_config_file"
|
||||
#lbn-comment# chown "$app:$app" "$install_dir/some_config_file"
|
||||
|
||||
### For more complex cases where you want to replace stuff using regexes,
|
||||
### you shoud rely on ynh_replace (which is basically a wrapper for sed)
|
||||
### When doing so, you also need to manually call ynh_store_file_checksum
|
||||
###
|
||||
### ynh_replace --match="match_string" --replace="replace_string" --file="$install_dir/some_config_file"
|
||||
### ynh_store_file_checksum "$install_dir/some_config_file"
|
||||
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression "Adding system configurations related to $app..."
|
||||
|
||||
### `ynh_config_add_phpfpm` is used to set up a PHP config.
|
||||
### You can remove it if your app doesn't use PHP.
|
||||
### `ynh_config_add_phpfpm` will use the files conf/extra_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
|
||||
|
||||
# Create a PHP-FPM config (with conf/extra_php-fpm.conf being appended to it)
|
||||
#lbn-comment# ynh_config_add_phpfpm
|
||||
|
||||
# Create a dedicated NGINX config using the conf/nginx.conf template
|
||||
ynh_config_add_nginx
|
||||
|
||||
### `ynh_config_add_systemd` is used to configure a systemd script for an app.
|
||||
### It can be used for apps that use sysvinit (with adaptation) or systemd.
|
||||
### Have a look at the app to be sure this app needs a systemd script.
|
||||
### `ynh_config_add_systemd` will use the file conf/systemd.service
|
||||
### If you're not using these lines:
|
||||
### - You can remove those files in conf/.
|
||||
### - Remove the section "BACKUP SYSTEMD" in the backup script
|
||||
### - Remove also the section "STOP AND REMOVE SERVICE" in the remove script
|
||||
### - As well as the section "RESTORE SYSTEMD" in the restore script
|
||||
### - And the section "SETUP SYSTEMD" in the upgrade script
|
||||
|
||||
# Create a dedicated systemd config
|
||||
ynh_config_add_systemd
|
||||
|
||||
### `yunohost service add` integrates a service in YunoHost. It then gets
|
||||
### 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!)
|
||||
### If you're not using these lines:
|
||||
### - You can remove these files in conf/.
|
||||
### - 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
|
||||
|
||||
### 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 if 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)
|
||||
yunohost service add "$app" --description="A short description of the app" --log="/var/log/$app/$app.log"
|
||||
|
||||
### `ynh_config_add_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
|
||||
|
||||
# Use logrotate to manage application logfile(s)
|
||||
ynh_config_add_logrotate
|
||||
|
||||
# Create a dedicated Fail2Ban config
|
||||
ynh_config_add_fail2ban --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login"
|
||||
|
||||
#=================================================
|
||||
# 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
|
||||
#lbn-comment# ynh_script_progression "Finalizing installation..."
|
||||
#lbn-comment# ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
|
||||
|
||||
#=================================================
|
||||
# START SYSTEMD SERVICE
|
||||
#=================================================
|
||||
ynh_script_progression "Starting $app's systemd service..."
|
||||
|
||||
### `ynh_systemctl` 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
|
||||
ynh_systemctl --service="$app" --action="start"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression "Installation of $app completed"
|
||||
Reference in New Issue
Block a user