1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/shaarli_ynh.git synced 2024-09-03 20:26:10 +02:00

Apply last example_ynh (#78)

* Apply last example_ynh

* Auto-update README

* removing rafi59

Co-authored-by: Alexandre Aubin <alex.aubin@mailoo.org>
Co-authored-by: yunohost-bot <yunohost@yunohost.org>
This commit is contained in:
yalh76 2022-07-22 00:47:28 +02:00 committed by GitHub
parent 3ea747b2f3
commit 9c5fe175b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 190 additions and 170 deletions

View file

@ -5,7 +5,7 @@ It shall NOT be edited by hand.
# Shaarli for YunoHost # Shaarli for YunoHost
[![Integration level](https://dash.yunohost.org/integration/shaarli.svg)](https://dash.yunohost.org/appci/app/shaarli) ![](https://ci-apps.yunohost.org/ci/badges/shaarli.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/shaarli.maintain.svg) [![Integration level](https://dash.yunohost.org/integration/shaarli.svg)](https://dash.yunohost.org/appci/app/shaarli) ![Working status](https://ci-apps.yunohost.org/ci/badges/shaarli.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/shaarli.maintain.svg)
[![Install Shaarli with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=shaarli) [![Install Shaarli with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=shaarli)
*[Lire ce readme en français.](./README_fr.md)* *[Lire ce readme en français.](./README_fr.md)*
@ -30,13 +30,13 @@ Shaarli is a minimalist bookmark manager and link sharing service that you can i
- feed other blogs, aggregators, social networks... - feed other blogs, aggregators, social networks...
**Shipped version:** 0.12.1~ynh3 **Shipped version:** 0.12.1~ynh4
**Demo:** https://demo.shaarli.org/ **Demo:** https://demo.shaarli.org/
## Screenshots ## Screenshots
![](./doc/screenshots/27wYsbC.png) ![Screenshot of Shaarli](./doc/screenshots/27wYsbC.png)
## Disclaimers / important information ## Disclaimers / important information
@ -47,20 +47,21 @@ During the installation app will prompt you to install itself as public or priva
After the installation is complete, go to the domain where the Shaarli is installed and create your account. After the creation of the account the registration will be locked. After the installation is complete, go to the domain where the Shaarli is installed and create your account. After the creation of the account the registration will be locked.
## Documentation and resources ## Documentation and resources
* Official admin documentation: https://shaarli.readthedocs.io/en/master/ * Official admin documentation: <https://shaarli.readthedocs.io/en/master/>
* Upstream app code repository: https://github.com/shaarli/Shaarli * Upstream app code repository: <https://github.com/shaarli/Shaarli>
* YunoHost documentation for this app: https://yunohost.org/app_shaarli * YunoHost documentation for this app: <https://yunohost.org/app_shaarli>
* Report a bug: https://github.com/YunoHost-Apps/shaarli_ynh/issues * Report a bug: <https://github.com/YunoHost-Apps/shaarli_ynh/issues>
## Developer info ## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/shaarli_ynh/tree/testing). Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/shaarli_ynh/tree/testing).
To try the testing branch, please proceed like that. To try the testing branch, please proceed like that.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/shaarli_ynh/tree/testing --debug sudo yunohost app install https://github.com/YunoHost-Apps/shaarli_ynh/tree/testing --debug
or or
sudo yunohost app upgrade shaarli -u https://github.com/YunoHost-Apps/shaarli_ynh/tree/testing --debug sudo yunohost app upgrade shaarli -u https://github.com/YunoHost-Apps/shaarli_ynh/tree/testing --debug
``` ```
**More info regarding app packaging:** https://yunohost.org/packaging_apps **More info regarding app packaging:** <https://yunohost.org/packaging_apps>

View file

@ -1,10 +1,14 @@
<!--
N.B.: This README was automatically generated by https://github.com/YunoHost/apps/tree/master/tools/README-generator
It shall NOT be edited by hand.
-->
# Shaarli pour YunoHost # Shaarli pour YunoHost
[![Niveau d'intégration](https://dash.yunohost.org/integration/shaarli.svg)](https://dash.yunohost.org/appci/app/shaarli) ![](https://ci-apps.yunohost.org/ci/badges/shaarli.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/shaarli.maintain.svg) [![Niveau d'intégration](https://dash.yunohost.org/integration/shaarli.svg)](https://dash.yunohost.org/appci/app/shaarli) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/shaarli.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/shaarli.maintain.svg)
[![Installer Shaarli avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=shaarli) [![Installer Shaarli avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=shaarli)
*[Read this readme in english.](./README.md)* *[Read this readme in english.](./README.md)*
*[Lire ce readme en français.](./README_fr.md)*
> *Ce package vous permet d'installer Shaarli rapidement et simplement sur un serveur YunoHost. > *Ce package vous permet d'installer Shaarli 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.* Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.*
@ -26,13 +30,13 @@ Shaarli is a minimalist bookmark manager and link sharing service that you can i
- feed other blogs, aggregators, social networks... - feed other blogs, aggregators, social networks...
**Version incluse :** 0.12.1~ynh3 **Version incluse :** 0.12.1~ynh4
**Démo :** https://demo.shaarli.org/ **Démo :** https://demo.shaarli.org/
## Captures d'écran ## Captures d'écran
![](./doc/screenshots/27wYsbC.png) ![Capture d'écran de Shaarli](./doc/screenshots/27wYsbC.png)
## Avertissements / informations importantes ## Avertissements / informations importantes
@ -43,20 +47,21 @@ During the installation app will prompt you to install itself as public or priva
After the installation is complete, go to the domain where the Shaarli is installed and create your account. After the creation of the account the registration will be locked. After the installation is complete, go to the domain where the Shaarli is installed and create your account. After the creation of the account the registration will be locked.
## Documentations et ressources ## Documentations et ressources
* Documentation officielle de l'admin : https://shaarli.readthedocs.io/en/master/ * Documentation officielle de l'admin : <https://shaarli.readthedocs.io/en/master/>
* Dépôt de code officiel de l'app : https://github.com/shaarli/Shaarli * Dépôt de code officiel de l'app : <https://github.com/shaarli/Shaarli>
* Documentation YunoHost pour cette app : https://yunohost.org/app_shaarli * Documentation YunoHost pour cette app : <https://yunohost.org/app_shaarli>
* Signaler un bug : https://github.com/YunoHost-Apps/shaarli_ynh/issues * Signaler un bug : <https://github.com/YunoHost-Apps/shaarli_ynh/issues>
## Informations pour les développeurs ## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/shaarli_ynh/tree/testing). Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/shaarli_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit. Pour essayer la branche testing, procédez comme suit.
```
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/shaarli_ynh/tree/testing --debug sudo yunohost app install https://github.com/YunoHost-Apps/shaarli_ynh/tree/testing --debug
ou ou
sudo yunohost app upgrade shaarli -u https://github.com/YunoHost-Apps/shaarli_ynh/tree/testing --debug sudo yunohost app upgrade shaarli -u https://github.com/YunoHost-Apps/shaarli_ynh/tree/testing --debug
``` ```
**Plus d'infos sur le packaging d'applications :** https://yunohost.org/packaging_apps **Plus d'infos sur le packaging d'applications :** <https://yunohost.org/packaging_apps>

View file

@ -1,10 +1,10 @@
;; Test complet sans multisite ;; Test complet
; Manifest ; Manifest
domain="domain.tld" domain="domain.tld"
path="/path" path="/path"
is_public=1 is_public=1
admin="john" admin="john"
password="pass" password="1Strong-Password"
title="Shaarli" title="Shaarli"
; Checks ; Checks
pkg_linter=1 pkg_linter=1
@ -14,8 +14,11 @@
setup_private=1 setup_private=1
setup_public=1 setup_public=1
upgrade=1 upgrade=1
# 0.12.1~ynh3
upgrade=1 from_commit=f61a2392a4df80d92a5f2042d1b503958f1f4fdf
backup_restore=1 backup_restore=1
multi_instance=1 multi_instance=1
port_already_use=0
change_url=1 change_url=1
;;; Options ;;; Options
Email= Email=

View file

@ -2,24 +2,25 @@
location __PATH__/ { location __PATH__/ {
# Path to source # Path to source
alias __FINALPATH__/ ; alias __FINALPATH__/;
index index.php; index index.php;
if (!-f $request_filename) { if (!-f $request_filename) {
rewrite ^ __PATH__/index.php last; rewrite ^ __PATH__/index.php last;
} }
client_max_body_size 50M; client_max_body_size 50M;
try_files $uri $uri/ index.php$is_args$args; try_files $uri $uri/ index.php$is_args$args;
location ~ [^/]\.php(/|$) { location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params; fastcgi_index index.php;
fastcgi_param REMOTE_USER $remote_user; include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param REMOTE_USER $remote_user;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_param SCRIPT_FILENAME $request_filename;
} }

View file

@ -1,72 +1,70 @@
{ {
"name": "Shaarli", "name": "Shaarli",
"id": "shaarli", "id": "shaarli",
"packaging_format": 1, "packaging_format": 1,
"description": { "description": {
"en": "The personal, minimalist, super-fast, no-database delicious clone", "en": "The personal, minimalist, super-fast, no-database delicious clone",
"fr": "Clone de delicious, rapide, simple et sans base de données" "fr": "Clone de delicious, rapide, simple et sans base de données"
}, },
"version": "0.12.1~ynh3", "version": "0.12.1~ynh4",
"url": "https://github.com/shaarli/Shaarli", "url": "https://github.com/shaarli/Shaarli",
"upstream": { "upstream": {
"license": "MIT", "license": "MIT",
"demo": "https://demo.shaarli.org/", "demo": "https://demo.shaarli.org/",
"admindoc": "https://shaarli.readthedocs.io/en/master/", "admindoc": "https://shaarli.readthedocs.io/en/master/",
"code": "https://github.com/shaarli/Shaarli" "code": "https://github.com/shaarli/Shaarli"
}, },
"license": "MIT", "license": "MIT",
"maintainer": { "maintainer": {
"name": "lapineige et rafi59", "name": "lapineige"
"email": "rafi59_dev@srvmaison.fr.nf", },
"url": "" "requirements": {
}, "yunohost": ">= 4.3.0"
"requirements": { },
"yunohost": ">= 4.3.0" "multi_instance": true,
}, "services": [
"multi_instance": true,
"services": [
"nginx", "nginx",
"php7.3-fpm" "php7.3-fpm"
], ],
"arguments": { "arguments": {
"install" : [ "install": [
{ {
"name": "domain", "name": "domain",
"type": "domain" "type": "domain"
}, },
{ {
"name": "path", "name": "path",
"type": "path", "type": "path",
"example": "/shaarli", "example": "/shaarli",
"default": "/shaarli" "default": "/shaarli"
}, },
{ {
"name": "admin", "name": "is_public",
"type": "user" "type": "boolean",
}, "help": {
{ "en": "If set as public, Shaarli will be visible to anyone, including non-Yunohost users. However only Shaarli users can add bookmarks. Your links will be public by default, but you can change that in Shaarli's configuration page.",
"name": "password", "fr": "Si configuré en public, Shaarli sera visible par tout le monde, y compris des personnes sans compte sur votre Yunohost. Cependant seules les personnes avec un compte Shaarli pourrons ajouter des marques-pages. Vos nouveaux liens seront publics par défaut, mais vous pourrez changer ça dans la page de configuration de Shaarli."
"type": "password" },
}, "default": false
{ },
"name": "title", {
"type": "string", "name": "admin",
"ask": { "type": "user"
"en": "Choose a title for your Shaarli instance", },
"fr": "Choisissez un titre pour votre instance Shaarli" {
}, "name": "password",
"example": "Shaarli", "type": "password"
"default": "Shaarli" },
}, {
{ "name": "title",
"name": "is_public", "type": "string",
"type": "boolean", "ask": {
"help": { "en": "Choose a title for your Shaarli instance",
"en": "If set as public, Shaarli will be visible to anyone, including non-Yunohost users. However only Shaarli users can add bookmarks. Your links will be public by default, but you can change that in Shaarli's configuration page.", "fr": "Choisissez un titre pour votre instance Shaarli"
"fr": "Si configuré en public, Shaarli sera visible par tout le monde, y compris des personnes sans compte sur votre Yunohost. Cependant seules les personnes avec un compte Shaarli pourrons ajouter des marques-pages. Vos nouveaux liens seront publics par défaut, mais vous pourrez changer ça dans la page de configuration de Shaarli." },
}, "example": "Shaarli",
"default": false "default": "Shaarli"
} }
] ]
} }
} }

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -25,7 +25,7 @@ ynh_print_info --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
@ -51,6 +51,13 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# BACKUP FAIL2BAN CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
#================================================= #=================================================
# SPECIFIC BACKUP # SPECIFIC BACKUP
#================================================= #=================================================
@ -59,13 +66,6 @@ ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP FAIL2BAN CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -22,11 +22,10 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
admin=$YNH_APP_ARG_ADMIN admin=$YNH_APP_ARG_ADMIN
password=$YNH_APP_ARG_PASSWORD password=$YNH_APP_ARG_PASSWORD
title=$YNH_APP_ARG_TITLE title=$YNH_APP_ARG_TITLE
is_public=$YNH_APP_ARG_IS_PUBLIC
phpversion=$YNH_PHP_VERSION
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
@ -48,8 +47,9 @@ ynh_script_progression --message="Storing installation settings..."
ynh_app_setting_set --app=$app --key=domain --value=$domain 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=path --value=$path_url
ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion
#=================================================
# STANDARD MODIFICATIONS
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
@ -63,7 +63,7 @@ ynh_install_app_dependencies $pkg_dependencies
ynh_script_progression --message="Configuring system user..." ynh_script_progression --message="Configuring system user..."
# Create a system user # Create a system user
ynh_system_user_create --username=$app ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -79,6 +79,15 @@ chmod -R o-rwx "$final_path"
chmod -R u+rwX $final_path/{cache/,data/,pagecache/,tmp/} chmod -R u+rwX $final_path/{cache/,data/,pagecache/,tmp/}
chown -R $app:www-data "$final_path" chown -R $app:www-data "$final_path"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..."
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#================================================= #=================================================
# NGINX CONFIGURATION # NGINX CONFIGURATION
#================================================= #=================================================
@ -88,36 +97,20 @@ ynh_script_progression --message="Configuring NGINX web server..."
ynh_add_nginx_config ynh_add_nginx_config
#================================================= #=================================================
# PHP-FPM CONFIGURATION # SPECIFIC SETUP
#================================================= #=================================================
ynh_script_progression --message="Configuring PHP-FPM..." # ADD A CONFIGURATION
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low
#================================================= #=================================================
# SETUP LOGROTATE ynh_script_progression --message="Adding a configuration file..."
#=================================================
ynh_script_progression --message="Configuring log rotation..."
# Use logrotate to manage application logfile(s)
touch "$final_path/data/log.txt"
ynh_use_logrotate "$final_path/data/log.txt"
chown $app:www-data "$final_path/data/log.txt"
#=================================================
# MODIFY A CONFIG FILE
#=================================================
ynh_script_progression --message="Configuring Shaarli..."
# Get the timezone # Get the timezone
timezone=$(cat /etc/timezone) timezone=$(cat /etc/timezone)
# Generate the salt # Generate the salt
salt=$(php${YNH_PHP_VERSION} -r 'echo sha1(uniqid("", true) ."_". mt_rand());') salt=$(php$phpversion -r 'echo sha1(uniqid("", true) ."_". mt_rand());')
# Generate the hash with the password # Generate the hash with the password
hash=$(php${YNH_PHP_VERSION} -r "echo sha1('${password}'.'${admin}'.'${salt}');") hash=$(php$phpversion -r "echo sha1('${password}'.'${admin}'.'${salt}');")
# Generate the API secret # Generate the API secret
secret=$(php${YNH_PHP_VERSION} -r "echo str_shuffle(substr(hash_hmac('sha512', uniqid('${salt}'), '${admin}'), 10, 12));") secret=$(php${YNH_PHP_VERSION} -r "echo str_shuffle(substr(hash_hmac('sha512', uniqid('${salt}'), '${admin}'), 10, 12));")
@ -134,6 +127,18 @@ fi
ynh_add_config --template="../conf/config.json.php" --destination="$final_path/data/config.json.php" ynh_add_config --template="../conf/config.json.php" --destination="$final_path/data/config.json.php"
chmod 700 "$final_path/data/config.json.php" chmod 700 "$final_path/data/config.json.php"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..."
# Use logrotate to manage application logfile(s)
touch "$final_path/data/log.txt"
ynh_use_logrotate "$final_path/data/log.txt"
chown $app:www-data "$final_path/data/log.txt"
#================================================= #=================================================
# SETUP FAIL2BAN # SETUP FAIL2BAN
#================================================= #=================================================
@ -150,7 +155,9 @@ ynh_script_progression --message="Configuring permissions..."
# Make app public if necessary # Make app public if necessary
if [ $is_public -eq 1 ] if [ $is_public -eq 1 ]
then then
ynh_permission_update --permission "main" --add "visitors" # Everyone can access the app.
# The "main" permission is automatically created before the install script.
ynh_permission_update --permission="main" --add="visitors"
fi fi
#================================================= #=================================================

View file

@ -19,6 +19,16 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config
ynh_remove_logrotate
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
@ -43,20 +53,12 @@ ynh_script_progression --message="Removing PHP-FPM configuration..."
# Remove the dedicated PHP-FPM config # Remove the dedicated PHP-FPM config
ynh_remove_fpm_config ynh_remove_fpm_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..."
# Remove the app-specific logrotate config
ynh_remove_logrotate
#================================================= #=================================================
# REMOVE FAIL2BAN CONFIGURATION # REMOVE FAIL2BAN CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Removing Fail2Ban configuration..." ynh_script_progression --message="Removing Fail2Ban configuration..."
# Remove the dedicated fail2ban config # Remove the dedicated Fail2Ban config
ynh_remove_fail2ban_config ynh_remove_fail2ban_config
#================================================= #=================================================

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts # Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
@ -39,20 +39,13 @@ test ! -d $final_path \
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create --username=$app ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
@ -68,12 +61,16 @@ chown -R $app:www-data "$final_path"
chmod 700 "$final_path/data/config.json.php" chmod 700 "$final_path/data/config.json.php"
#================================================= #=================================================
# RESTORE THE PHP-FPM CONFIGURATION # RESTORE FAIL2BAN CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring the PHP-FPM configuration..." ynh_script_progression --message="Restoring the Fail2Ban configuration..."
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
ynh_systemd_action --action=restart --service_name=fail2ban
#=================================================
# SPECIFIC RESTORATION
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
@ -83,7 +80,19 @@ ynh_script_progression --message="Reinstalling dependencies..."
ynh_install_app_dependencies $pkg_dependencies ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
# SPECIFIC RESTORATION # RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the PHP-FPM configuration..."
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# RESTORE THE LOGROTATE CONFIGURATION # RESTORE THE LOGROTATE CONFIGURATION
#================================================= #=================================================
@ -91,15 +100,6 @@ ynh_script_progression --message="Restoring the logrotate configuration..."
ynh_restore_file --origin_path="/etc/logrotate.d/$app" ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#=================================================
# RESTORE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the Fail2Ban configuration..."
ynh_restore_file "/etc/fail2ban/jail.d/$app.conf"
ynh_restore_file "/etc/fail2ban/filter.d/$app.conf"
ynh_systemd_action --action=restart --service_name=fail2ban
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================

View file

@ -23,6 +23,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
@ -34,7 +35,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { ynh_clean_setup () {
# restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup ynh_restore_upgradebackup
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
@ -64,7 +65,7 @@ fi
ynh_script_progression --message="Making sure dedicated system user exists..." ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create --username=$app ynh_system_user_create --username=$app --home_dir="$final_path"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -100,14 +101,6 @@ chmod -R u+rwX $final_path/{cache/,data/,pagecache/,tmp/}
chown -R $app:www-data "$final_path" chown -R $app:www-data "$final_path"
chmod 700 "$final_path/data/config.json.php" chmod 700 "$final_path/data/config.json.php"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
@ -120,9 +113,19 @@ ynh_install_app_dependencies $pkg_dependencies
#================================================= #=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..." ynh_script_progression --message="Upgrading PHP-FPM configuration..."
# Create a dedicated php-fpm config # Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low ynh_add_fpm_config --usage=low --footprint=low
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================