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

Thanks to Hubzilla packagers, switch to format 2 is made

This commit is contained in:
dragondaddy 2023-07-29 22:25:24 +02:00
parent 2640bee5c3
commit 53b92f2f80
23 changed files with 591 additions and 830 deletions

View file

@ -1,79 +0,0 @@
<!--
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.
-->
# Zap for YunoHost
[![Integration level](https://dash.yunohost.org/integration/zap.svg)](https://dash.yunohost.org/appci/app/zap) ![Working status](https://ci-apps.yunohost.org/ci/badges/zap.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/zap.maintain.svg)
[![Install Zap with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=zap)
*[Lire ce readme en français.](./README_fr.md)*
> *This package allows you to install Zap quickly and simply on a YunoHost server.
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
## Overview
[Zap](https://zotlabs.com/zap/) is an an ethical alternative to Fediverse that provides powerful features for creating interconnected websites featuring a decentralized identity, communications, and permissions framework built using common webserver technology.
Compatible with **Mastodon**, **Pleroma**, **Pixelfed**, **Friendica**, **Hubzilla**, **Funkwhale**, **Peertube**, **Plume**, **WriteFreely** and many, many more.
## Unique Features of ZAP
- **Groups** : public, private, and moderated.
- **Events** : Calendar and attendance; automatic birthday notifications for friends using this feature.
- **Cloud**storage : Built-in network file storage integrated with social networking access.
- **Editor** : Supports both markdown and bbcode. Use either or both - if you want.
- **Share**: Drag-and-drop a number of different things such as files, photos, webpages, maps, phone numbers to share- them.
- **Lists**: Sometimes referred to as circles or aspects, this lets you define your own groups of related friends and- communicate with them as a private group.
- **Extend** : Change or upgrade your software functionality as desired by installing additional features from addons and- the free app collection.
**Shipped version:** 21.11.28~ynh1
## Disclaimers / important information
## Installation
Before installing, read the [Zap installation instructions](https://codeberg.org/zot/zap/src/branch/release/install/INSTALL.txt) for important information about:
### Register a new domain and add it to YunoHost
- Zap requires a dedicated domain, so obtain one and add it using the YunoHost admin panel. **Domains -> Add domain**. As Zap uses the full domain and is installed on the root, you can create a subdomain such as Zap.domain.tld. Don't forget to update your DNS if you manage them manually.
## LDAP Admin user rights, logs and failed database updates
- **For admin rights**: When installation is complete, you will need to visit your new hub's page and login with the **admin account username** which was entered at the time of installation process. You should then be able to create your first channel and have the **admin rights** for the hub.
- **For normal YunoHost users :** Normal LDAP users can login through Ldap authentication and create there channels.
- **Failing to get admin rights :** If the admin cannot access the admin settings at `https://zap.example.com/admin` or you want to grant admin rights to any other user(s) on the hub, then you have to **manually add 4096** to the **account_roles** under **accounts** for that user in the **database through phpMYAdmin**.
- **For logs:** Go to **admin->logs** and enter the file name **php.log**.
- **Failed Database after Upgrade:** Some times databse upgrade fails after version upgrade. You can go to hub eg. `https://zap.example.com/admin/dbsync/` and check the numbers of failled update. These updates will have to be ran manually by **phpMYAdmin**.
## :red_circle: Antifeatures
- **Upstream not maintained**: This software is not maintained anymore. Expect it to break down over time, be exposed to unfixed security breaches, etc.
## Documentation and resources
* Upstream app code repository: <https://codeberg.org/zot-archive/zap>
* YunoHost documentation for this app: <https://yunohost.org/app_zap>
* Report a bug: <https://github.com/YunoHost-Apps/zap_ynh/issues>
## Developer info
Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/zap_ynh/tree/testing).
To try the testing branch, please proceed like that.
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/zap_ynh/tree/testing --debug
or
sudo yunohost app upgrade zap -u https://github.com/YunoHost-Apps/zap_ynh/tree/testing --debug
```
**More info regarding app packaging:** <https://yunohost.org/packaging_apps>

View file

@ -1,79 +0,0 @@
<!--
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.
-->
# Zap pour YunoHost
[![Niveau dintégration](https://dash.yunohost.org/integration/zap.svg)](https://dash.yunohost.org/appci/app/zap) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/zap.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/zap.maintain.svg)
[![Installer Zap avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=zap)
*[Read this readme in english.](./README.md)*
> *Ce package vous permet dinstaller Zap rapidement et simplement sur un serveur YunoHost.
Si vous navez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment linstaller et en profiter.*
## Vue densemble
[Zap](https://zotlabs.com/zap/) is an an ethical alternative to Fediverse that provides powerful features for creating interconnected websites featuring a decentralized identity, communications, and permissions framework built using common webserver technology.
Compatible with **Mastodon**, **Pleroma**, **Pixelfed**, **Friendica**, **Hubzilla**, **Funkwhale**, **Peertube**, **Plume**, **WriteFreely** and many, many more.
## Unique Features of ZAP
- **Groups** : public, private, and moderated.
- **Events** : Calendar and attendance; automatic birthday notifications for friends using this feature.
- **Cloud**storage : Built-in network file storage integrated with social networking access.
- **Editor** : Supports both markdown and bbcode. Use either or both - if you want.
- **Share**: Drag-and-drop a number of different things such as files, photos, webpages, maps, phone numbers to share- them.
- **Lists**: Sometimes referred to as circles or aspects, this lets you define your own groups of related friends and- communicate with them as a private group.
- **Extend** : Change or upgrade your software functionality as desired by installing additional features from addons and- the free app collection.
**Version incluse :** 21.11.28~ynh1
## Avertissements / informations importantes
## Installation
Before installing, read the [Zap installation instructions](https://codeberg.org/zot/zap/src/branch/release/install/INSTALL.txt) for important information about:
### Register a new domain and add it to YunoHost
- Zap requires a dedicated domain, so obtain one and add it using the YunoHost admin panel. **Domains -> Add domain**. As Zap uses the full domain and is installed on the root, you can create a subdomain such as Zap.domain.tld. Don't forget to update your DNS if you manage them manually.
## LDAP Admin user rights, logs and failed database updates
- **For admin rights**: When installation is complete, you will need to visit your new hub's page and login with the **admin account username** which was entered at the time of installation process. You should then be able to create your first channel and have the **admin rights** for the hub.
- **For normal YunoHost users :** Normal LDAP users can login through Ldap authentication and create there channels.
- **Failing to get admin rights :** If the admin cannot access the admin settings at `https://zap.example.com/admin` or you want to grant admin rights to any other user(s) on the hub, then you have to **manually add 4096** to the **account_roles** under **accounts** for that user in the **database through phpMYAdmin**.
- **For logs:** Go to **admin->logs** and enter the file name **php.log**.
- **Failed Database after Upgrade:** Some times databse upgrade fails after version upgrade. You can go to hub eg. `https://zap.example.com/admin/dbsync/` and check the numbers of failled update. These updates will have to be ran manually by **phpMYAdmin**.
## :red_circle: Fonctions indésirables
- **Upstream not maintained**: This software is not maintained anymore. Expect it to break down over time, be exposed to unfixed security breaches, etc.
## Documentations et ressources
* Dépôt de code officiel de lapp : <https://codeberg.org/zot-archive/zap>
* Documentation YunoHost pour cette app : <https://yunohost.org/app_zap>
* Signaler un bug : <https://github.com/YunoHost-Apps/zap_ynh/issues>
## Informations pour les développeurs
Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/zap_ynh/tree/testing).
Pour essayer la branche testing, procédez comme suit.
``` bash
sudo yunohost app install https://github.com/YunoHost-Apps/zap_ynh/tree/testing --debug
ou
sudo yunohost app upgrade zap -u https://github.com/YunoHost-Apps/zap_ynh/tree/testing --debug
```
**Plus dinfos sur le packaging dapplications :** <https://yunohost.org/packaging_apps>

View file

@ -1,20 +0,0 @@
;; Test complet
; Manifest
domain="domain.tld"
admin="john"
upload="256M"
database="1"
; Checks
pkg_linter=1
setup_sub_dir=0
setup_root=1
setup_nourl=0
setup_private=0
setup_public=1
upgrade=1
backup_restore=1
multi_instance=1
change_url=0
;;; Options
Email=
Notification=

View file

@ -1,3 +0,0 @@
SOURCE_URL=https://codeberg.org/streams/streams/archive/c6cfd33c0e1b88e30399a4f9efd557512bb9ec86.tar.gz
SOURCE_SUM=a336c9f70109459bc167736aaa9211fba05a009110d8d0e9586af126337c8ec8
SOURCE_FORMAT=tar.gz

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://codeberg.org/streams/streams-addons/archive/0ff7cafbb205611c9f5fbbb8d8294c0b9dba0d70.tar.gz
SOURCE_SUM=2118bb796e1113a50b72c525708484563656edfe4b03c50b01ef973d839f3bce
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=
SOURCE_FILENAME=

View file

@ -358,7 +358,7 @@ request_terminate_timeout = 1d
; Chdir to this directory at the start.
; Note: relative path can be used.
; Default Value: current directory or / when chroot
chdir = __FINALPATH__
chdir = __INSTALL_DIR__
; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.

94
conf/htconfig.sample.php Normal file
View file

@ -0,0 +1,94 @@
<?php
// If automatic system installation fails:
// Copy or rename this file to .htconfig.php in the top level
// Hubzilla directory
// Why .htconfig.php? Because it contains sensitive information which could
// give somebody complete control of your database. Apache's default
// configuration denies access to and refuses to serve any file beginning
// with .ht
// Then set the following for your MySQL installation
$db_host = 'localhost'; // Use 'localhost' or ':/path/to/socket.file' if you aren't using a remote server
$db_port = 0; // leave 0 for default or set your port
$db_user = '__DB_USER__';
$db_pass = '__DB_PWD__';
$db_data = '__DB_NAME__';
$db_type = __DB_TYPE__; // use 1 for postgres, 0 for mysql
/*
* Notice: Many of the following settings will be available in the admin panel
* after a successful site install. Once they are set in the admin panel, they
* are stored in the DB - and the DB setting will over-ride any corresponding
* setting in this file
*
* The command-line tool util/config is able to query and set the DB items
* directly if for some reason the admin panel is not available and a system
* setting requires modification.
*
*/
// Choose a legal default timezone. If you are unsure, use "America/Los_Angeles".
// It can be changed later and only applies to timestamps for anonymous viewers.
App::$config['system']['timezone'] = 'America/Los_Angeles';
// What is your site name? DO NOT ADD A TRAILING SLASH!
App::$config['system']['baseurl'] = 'https://__DOMAIN__';
App::$config['system']['sitename'] = "YunoHost Hubzilla";
App::$config['system']['location_hash'] = '__RANDOM_STRING__';
// These lines set additional security headers to be sent with all responses
// You may wish to set transport_security_header to 0 if your server already sends
// this header. content_security_policy may need to be disabled if you wish to
// run the piwik analytics plugin or include other offsite resources on a page
App::$config['system']['transport_security_header'] = 1;
App::$config['system']['content_security_policy'] = 1;
App::$config['system']['ssl_cookie_protection'] = 1;
// Your choices are REGISTER_OPEN, REGISTER_APPROVE, or REGISTER_CLOSED.
// Be certain to create your own personal account before setting
// REGISTER_CLOSED. 'register_text' (if set) will be displayed prominently on
// the registration page. REGISTER_APPROVE requires you set 'admin_email'
// to the email address of an already registered person who can authorise
// and/or approve/deny the request.
// In order to perform system administration via the admin panel, admin_email
// must precisely match the email address of the person logged in.
App::$config['system']['register_policy'] = REGISTER_OPEN;
App::$config['system']['register_text'] = '';
App::$config['system']['admin_email'] = '__EMAIL__';
// Location of PHP command line processor
App::$config['system']['php_path'] = '/usr/bin/php__PHPVERSION__';
// Configure how we communicate with directory servers.
// DIRECTORY_MODE_NORMAL = directory client, we will find a directory (all of your member's queries will be directed elsewhere)
// DIRECTORY_MODE_SECONDARY = caching directory or mirror (keeps in sync with realm primary [adds significant cron execution time])
// DIRECTORY_MODE_PRIMARY = main directory server (you do not want this unless you are operating your own realm. one per realm.)
// DIRECTORY_MODE_STANDALONE = "off the grid" or private directory services (only local site members in directory)
App::$config['system']['directory_mode'] = DIRECTORY_MODE_NORMAL;
// PHP error logging setup
// Before doing this ensure that the webserver has permission
// to create and write to php.out in the top level Red directory,
// or change the name (below) to a file/path where this is allowed.
// Uncomment the following 4 lines to turn on PHP error logging.
error_reporting(E_ERROR | E_WARNING | E_PARSE );
ini_set('error_log','php.log');
ini_set('log_errors','1');
ini_set('display_errors', '0');

View file

@ -1,63 +1,69 @@
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
alias __FINALPATH__/;
# Path to source
alias __INSTALL_DIR__/;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?req=$1;
}
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?q=$1;
}
client_max_body_size 20m;
client_body_buffer_size 128k;
# Default indexes and catch-all
index index.php;
charset utf-8;
# Default indexes and catch-all
index index.php;
charset utf-8;
# Common parameter to increase upload size limit in conjunction with dedicated php-fpm file
client_max_body_size 50M;
client_body_buffer_size 128k;
location ~* \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 300;
}
location ~* \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
# make sure webfinger and other well known services aren't blocked
# by denying dot files and rewrite request to the front controller
location ^~ /.well-known/ {
allow all;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?req=$1;
}
}
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 300;
}
# statically serve these file types when possible
# otherwise fall back to front controller
# allow browser to cache them
# added .htm for advanced source code editor library
# location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|map|ttf|woff|woff2|svg)$ {
# expires 30d;
# try_files $uri /index.php?q=$uri&$args;
# }
# make sure webfinger and other well known services aren't blocked
# by denying dot files and rewrite request to the front controller
location ^~ /.well-known/ {
allow all;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?q=$1;
}
}
# block these file types
location ~* \.(tpl|md|tgz|log|out)$ {
deny all;
}
# statically serve these file types when possible
# otherwise fall back to front controller
# allow browser to cache them
# added .htm for advanced source code editor library
# location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|map|ttf|woff|woff2|svg)$ {
# expires 30d;
# try_files $uri /index.php?q=$uri&$args;
# }
# deny access to all dot files
location ~ /\. {
deny all;
}
# block these file types
location ~* \.(tpl|md|tgz|log|out)$ {
deny all;
}
#deny access to store
location ~ /store {
deny all;
}
# deny access to all dot files
location ~ /\. {
deny all;
}
#deny access to util
location ~ /util {
deny all;
}
}
#deny access to store
location ~ /store {
deny all;
}
#deny access to util
location ~ /util {
deny all;
}
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}

View file

@ -1,2 +1,2 @@
# Run poller periodically to update your website
*/10 * * * * __APP__ cd __FINALPATH__; /usr/bin/php__PHPVERSION__ Code/Daemon/Run.php Cron > /dev/null 2>&1
*/10 * * * * __APP__ /usr/bin/php__PHPVERSION__ -f __INSTALL_DIR__/Code/Daemon/Run.php Cron > /dev/null 2>&1

View file

@ -1 +0,0 @@
define('NOMADIC',1);

30
config_panel.toml Normal file
View file

@ -0,0 +1,30 @@
version = "1.0"
[main]
name = "Hubzilla configuration"
[main.php_fpm_config]
name = "PHP-FPM configuration"
[main.php_fpm_config.fpm_footprint]
ask = "Memory footprint"
type = "select"
choices.low = "Low, <= 20Mb per pool"
choices.medium = "Medium, between 20Mb and 40Mb per pool"
choices.high = "High, > 40Mb per pool"
choices.specific = "Use specific value"
default = "low"
[main.php_fpm_config.fpm_free_footprint]
visible = "fpm_footprint == 'specific'"
ask = "Memory footprint of the service?"
type = "number"
default = "0"
help = "Free field to specify exactly the footprint in Mb if you don't want to use one of the three previous values."
[main.php_fpm_config.fpm_usage]
ask = "Expected usage"
type = "select"
choices = ["low", "medium", "high"]
default = "low"
help = "low: Personal usage, behind the SSO. No RAM footprint when not used, but the impact on the processor can be high if many users are using the service.<br>medium: Low usage, few people or/and publicly accessible. Low RAM footprint, medium processor footprint when used.<br>high: High usage, frequently visited website. High RAM footprint, but lower on processor usage and quickly responding."

15
doc/ADMIN_fr.md Normal file
View file

@ -0,0 +1,15 @@
### Enregistrez un nouveau domaine et ajoutez-le à YunoHost
- Votre site basé sur Streams nécessite un domaine dédié, alors obtenez-en un et ajoutez-le à l'aide du panneau d'administration YunoHost. **Domaines -> Ajouter un domaine**. Votre site utilise un domaine complet et est installé à la racine, vous pouvez donc créer un sous-domaine tel que monsite.domaine.tld. N'oubliez pas de mettre à jour vos DNS si vous les gérez manuellement.
## Droits d'utilisateur de l'administrateur LDAP, journaux et échec des mises à jour de la base de données
- **Pour les droits d'administrateur** : lorsque l'installation est terminée, vous devrez visiter la page d'accueil de votre nouveau site et vous connecter avec le **nom d'utilisateur du compte administrateur** qui a été saisi au moment du processus d'installation. Vous devriez alors pouvoir créer votre premier canal et disposer des **droits d'administrateur** pour le site.
- **Pour les utilisateurs YunoHost normaux** : les utilisateurs LDAP normaux peuvent se connecter via l'authentification LDAP et y créer des canaux.
- **Échec de l'obtention des droits d'administrateur** : si l'administrateur ne peut pas accéder aux paramètres d'administration sur `https://monsite.domaine.tld/admin`, vous devez **ajouter manuellement 4096** aux **account_roles* * sous **comptes** pour cet utilisateur dans la **base de données via phpMyAdmin**.
- **Pour les logs** : Allez dans **admin->logs** et saisissez le nom du fichier **php.log**.
- **Échec de la base de données après la mise à niveau :** Parfois, la mise à niveau de la base de données échoue après la mise à niveau de la version. Vous pouvez aller au hub, par exemple. `https://monsite.domaine.tld/admin/dbsync/` et vérifiez le nombre de mises à jour défaillantes. Ces mises à jour devront être exécutées manuellement par **phpMyAdmin**.

24
doc/DESCRIPTION_fr.md Normal file
View file

@ -0,0 +1,24 @@
[Streams](https://codeberg.org/streams/streams/) est un serveur fediverse open source qui a une longue histoire d'innovation. Voir [FEATURES](https://codeberg.org/streams/streams/src/branch/dev/FEATURES.md).
Ce logiciel appartient au domaine public dans les limites autorisées par la loi et n'est pas associé à une marque ou à un produit.
Compatible avec **Mastodon**, **Pleroma**, **Pixelfed**, **Friendica**, **Hubzilla**, **Funkwhale**, **Peertube**, **Plume**, **WriteFreely** et bien d'autres encore.
## Caractéristiques uniques de Streams
- **Signature unique fédérée** : Rend les ressources privées/protégées sur des sites externes aussi accessibles que sur des sites locaux.
- **Contrôle d'accès fédéré** : Permet l'authentification unique fédérée pour fournir des ressources multimédias et web privées/protégées à n'importe qui, y compris à ceux qui visitent le site depuis d'autres sites.
- **Groupes** : Publics, privés et modérés. Ils fonctionnent sur presque toutes les plateformes fediverse.
- **Événements** : Calendrier et présence ; notifications automatiques d'anniversaire ajustées au fuseau horaire pour les amis utilisant cette fonctionnalité.
- **Permissions** : Parce que tout le monde ne souhaite pas converser et partager des aspects intimes de sa vie avec des inconnus.
- **Stockage en ligne** : Stockage en ligne de fichiers intégré au logiciel, avec contrôle d'accès fédéré et accès/permissions aux réseaux sociaux. Accessible via le protocole WebDAV.
- **Éditeur** : Supporte le markdown, le html et le bbcode. Utilisez l'un ou l'autre de ces éléments dans un message y intégrer des médias. L'édition et la prévisualisation des messages sont disponibles. Il est peu probable que, dans le cadre d'une utilisation normale, vous dépassiez les limites de longueur des messages fédérés (environ 100 pages imprimées de texte). Il n'y a pas de limites arbitraires imposées au nombre de photos, de fichiers ou de réponses à des sondages joints à vos publications.
- **Partager** : Glissez-déposez un certain nombre de choses différentes telles que des fichiers, des photos, des vidéos, des pages web, des cartes, des articles de fediverse et des numéros de téléphone pour les partager.
- **Listes** : Parfois appelées cercles ou aspects, elles vous permettent de définir vos propres groupes d'amis et de communiquer avec eux en tant que groupe privé.
- **Extension** : Modifiez ou mettez à niveau les fonctionnalités de votre logiciel en installant des fonctions supplémentaires à partir de modules complémentaires et de la collection d'applications gratuites.
- **Guest Pass** : Fournissez à des invités un accès unique à des ressources et à des médias privés - vous fixez les conditions.
- **Zoom sur les amis** : Définissez votre degré de proximité avec n'importe quelle connexion, puis effectuez un zoom avant interactif pour filtrer votre flux vers vos amis proches, ou un zoom arrière pour voir les messages de vos simples connaissances.
- **Services de localisation** : Activation et désactivation, départ et recherche en fonction de la distance.
- **Rapports de distribution** : Dans un monde de plateforme multiples et décentralisées, il y a des imprévus. Les sites et les réseaux tombent parfois en panne. Les développeurs de projets introduisent parfois des bogues et des incompatibilités. Cette fonction vous permet de savoir ce qu'il est advenu de votre message ou de votre commentaire et où il est réellement passé une fois que vous l'avez publié.
- **Sécurité des données** : Parce que le meilleur moment pour faire une sauvegarde à jour de vos données, c'était il y a 10 secondes. Clonez votre identité et votre contenu en ligne sur plusieurs sites à l'aide du protocole Nomad et reproduisez tout changement en temps quasi réel. Ainsi, si le site qui héberge votre compte tombe en panne (temporairement ou définitivement) ou si vous en êtes expulsé pour une raison quelconque, votre vie en ligne n'est pas perdue et vous n'êtes pas obligé de la reprendre à zéro. Tous vos amis et tout votre contenu sont disponibles sur n'importe laquelle de vos instances clonées - à tout moment.
- **ActivityPub** : Fournit l'API ActivityPub "Client to Server" pour une utilisation avec des applications externes.

View file

@ -57,12 +57,12 @@ ram.runtime = "50M"
main.url = "/"
[resources.apt]
packages = "php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-gd"
packages = "php8.2-mbstring php8.2-cli php8.2-imagick php8.2-xml php8.2-zip php8.2-curl php8.2-ldap php8.2-json php8.2-gd"
packages_from_raw_bash = """
if [[ "$database" == "mysql" ]]; then
echo "mariadb-server"
echo "mariadb-server php8.2-mysql"
elif [[ "$database" == "postgresql" ]]; then
echo "postgresql postgresql-contrib"
echo "postgresql postgresql-contrib php8.2-pgsql"
fi
"""

View file

@ -3,43 +3,19 @@
#=================================================
# COMMON VARIABLES
#=================================================
# PHP APP SPECIFIC
#=================================================
# dependencies used by the app
YNH_PHP_VERSION="8.2"
YNH_COMPOSER_VERSION="2.5.8"
pkg_dependencies_main="php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-cli php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-gd"
pkg_dependencies_psql="postgresql postgresql-contrib php${YNH_PHP_VERSION}-pgsql"
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
ynh_smart_mktemp () {
local min_size="${1:-300}"
# Transform the minimum size from megabytes to kilobytes
min_size=$(( $min_size * 1024 ))
# Check if there's enough free space in a directory
is_there_enough_space () {
local free_space=$(df --output=avail "$1" | sed 1d)
test $free_space -ge $min_size
}
if is_there_enough_space /tmp; then
local tmpdir=/tmp
elif is_there_enough_space /var; then
local tmpdir=/var
elif is_there_enough_space /; then
local tmpdir=/
elif is_there_enough_space /home; then
local tmpdir=/home
else
ynh_die "Insufficient free space to continue..."
fi
echo "$(mktemp --directory --tmpdir="$tmpdir")"
}
#=================================================
# FUTURE OFFICIAL HELPERS
#=================================================

79
scripts/backup Executable file → Normal file
View file

@ -6,32 +6,10 @@
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# 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)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
database=$(ynh_app_setting_get --app=$app --key=database)
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
@ -41,7 +19,7 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$final_path"
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
@ -55,31 +33,6 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# BACKUP OF THE DATABASE
#=================================================
if [ $database -eq 1 ]; then
ynh_print_info --message="Backup of the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
elif [ $database -eq 2 ]; then
# Removing postgresSQL database
ynh_print_info --message="Backup of the postgreSQL database..."
ynh_psql_dump_db --database="$db_name" > db.sql
fi
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP A CRON FILE
#=================================================
ynh_backup --src_path="/etc/cron.d/$app"
#=================================================
# BACKUP FAIL2BAN CONFIGURATION
#=================================================
@ -87,6 +40,34 @@ ynh_backup --src_path="/etc/cron.d/$app"
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP LOGROTATE
#=================================================
ynh_backup --src_path="/etc/logrotate.d/$app"
#=================================================
# BACKUP VARIOUS FILES
#=================================================
ynh_backup --src_path="/etc/cron.d/$app"
#=================================================
# BACKUP THE DATABASE
#=================================================
if [ $database = "mysql" ]; then
# Backup MySQL database
ynh_print_info --message="Backup of the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
elif [ $database = "postgresql" ]; then
# Backup PostgreSQL database
ynh_print_info --message="Backup of the PostgreSQL database..."
ynh_psql_dump_db --database="$db_name" > db.sql
fi
#=================================================
# END OF SCRIPT
#=================================================

95
scripts/config Normal file
View file

@ -0,0 +1,95 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
current_fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
#=================================================
# SPECIFIC GETTERS FOR TOML SHORT KEY
#=================================================
get__fpm_footprint() {
# Free footprint value for php-fpm
# Check if current_fpm_footprint is an integer
if [ "$current_fpm_footprint" -eq "$current_fpm_footprint" ] 2> /dev/null
then
echo "specific"
else
echo "$current_fpm_footprint"
fi
}
get__free_footprint() {
# Free footprint value for php-fpm
# Check if current_fpm_footprint is an integer
if [ "$current_fpm_footprint" -eq "$current_fpm_footprint" ] 2> /dev/null
then
# If current_fpm_footprint is an integer, that's a numeric value for the footprint
echo "$current_fpm_footprint"
else
echo "0"
fi
}
#=================================================
# SPECIFIC SETTERS FOR TOML SHORT KEYS
#=================================================
set__fpm_footprint() {
if [ "$fpm_footprint" != "specific" ]
then
ynh_app_setting_set --app=$app --key=fpm_footprint --value="$fpm_footprint"
fi
}
set__fpm_free_footprint() {
if [ "$fpm_footprint" = "specific" ]
then
ynh_app_setting_set --app=$app --key=fpm_footprint --value="$fpm_free_footprint"
fi
}
#=================================================
# GENERIC FINALIZATION
#=================================================
ynh_app_config_validate() {
_ynh_app_config_validate
if [ "${changed[fpm_usage]}" == "true" ] || [ "${changed[fpm_footprint]}" == "true" ] || [ "${changed[fpm_free_footprint]}" == "true" ]; then
# If fpm_footprint is set to 'specific', use $fpm_free_footprint value.
if [ "$fpm_footprint" = "specific" ]
then
fpm_footprint=$fpm_free_footprint
fi
if [ "$fpm_footprint" == "0" ]
then
ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below."
exit 0
fi
fi
}
ynh_app_config_apply() {
_ynh_app_config_apply
ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
}
ynh_app_config_run $1

View file

@ -9,259 +9,153 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
domain=$YNH_APP_ARG_DOMAIN
path_url="/"
admin=$YNH_APP_ARG_ADMIN
email=$(ynh_user_get_info --username=$admin --key=mail)
upload="256M"
database="1"
random_string=$(ynh_string_random --length=48)
database=`expr $YNH_APP_ARG_DATABASE`
app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..."
final_path=/var/www/$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
random_string="$(ynh_string_random --length=48)"
fpm_footprint="low"
fpm_free_footprint=0
fpm_usage="low"
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_print_info "Storing installation settings..."
ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=database --value=$database
ynh_app_setting_set --app=$app --key=email --value=$email
ynh_app_setting_set --app=$app --key=upload --value=$upload
ynh_app_setting_set --app=$app --key=database --value=$database
ynh_app_setting_set --app=$app --key=random_string --value=$random_string
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
#=================================================
# STANDARD MODIFICATIONS
# CREATE A DATABASE
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_print_info "Installing dependencies..."
ynh_install_app_dependencies $pkg_dependencies_main
if [ $database == "postgresql" ]; then
ynh_install_app_dependencies $pkg_dependencies_psql
ynh_script_progression --message="Creating a database..." --weight=2
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
db_pwd=$(ynh_string_random --length=30)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_app_setting_set --app=$app --key=db_user --value=$db_user
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
if [ $database == "mysql" ]; then
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \
<<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
db_type=0
elif [ $database == "postgresql" ]; then
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
db_type=1
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
# Create a system user
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..." --weight=1
# 1 - Streams
ynh_script_progression --message="Setting up Streams source files..."
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# Download
# Uncomment the line below to use latest available release version
# git clone https://codeberg.org/streams/streams.git "$final_path" --quiet
# git checkout release
# Secure install - Comment the two lines below to use the git repository as the source
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
ynh_setup_source --dest_dir="$install_dir/addon" --source_id="addons"
# 2 - Composer
ynh_script_progression --message="Pulling in external libraries with Composer..."
touch "$install_dir/php.log"
mkdir -p "$install_dir/store"
mkdir -p "$install_dir/cache/smarty3"
ynh_install_composer
# 3 - Streams Addons
# Make addon Directory and unpack the addons to this directory
ynh_script_progression --message="Setting up Streams addons source files..."
pushd "$final_path"
mkdir -p extend/addon/zaddons
mkdir addon
git clone https://codeberg.org/streams/streams-addons.git $final_path/extend/addon/zaddons --quiet
filelist=(`ls extend/addon/zaddons`)
cd addon
for a in "${filelist[@]}" ; do
base=`basename $a`
if [ $base = '.git' ]; then
#echo 'ignoring git'
continue;
fi
if [ ! -d ../extend/addon/zaddons/$base ]; then
#echo $a 'not a directory'
continue;
fi
if [ -x $base ]; then
#echo $base 'file exists'
continue;
fi
echo linking $base
ln -s ../extend/addon/zaddons/$base $base
done
popd
# 3 - Some extra folders
ynh_script_progression --message="Creating smarty3 folder for personal data..."
mkdir -p "${final_path}/store"
mkdir -p "${final_path}/cache/smarty3"
chmod -R 775 $final_path/store $final_path/cache
# Copy the template install/htconfig.sample.php to .htconfig.php
config="$final_path/.htconfig.php"
ynh_script_progression --message="Moving .htconfig.php to root of Zap ..."
cp $final_path/install/htconfig.sample.php $config
config="$final_path/.htconfig.php"
# Create php.log inside for logs
ynh_print_info "Create php.log for the debuging..."
touch "$final_path/php.log"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
#=================================================
# CREATE A DATABASE
#=================================================
if [ $database == "mysql" ]; then
ynh_script_progression --message="Creating a MySQL database..."
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
ynh_script_progression --message="Importing database..."
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $final_path/install/schema_mysql.sql
elif [ $database == "postgresql" ]; then
# Create postgresql database
ynh_script_progression --message="Creating a postgresql database..."
ynh_replace_string --match_string="db_type = 0;" --replace_string="db_type = 1;" --target_file="$config"
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$app
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_script_progression --message="Importing database..."
ynh_psql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $final_path/install/schema_postgres.sql
else
ynh_die --message="Some problem occured in creating the database, contact maintainer"
fi
#=================================================
# MODIFY A CONFIG FILE
#=================================================
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
ynh_replace_string --match_string="your.mysqlhost.com" --replace_string="localhost" --target_file="$config"
ynh_replace_string --match_string= "mysqlpassword" --replace_string="$db_pwd" --target_file="$config"
ynh_replace_string --match_string="mysqlusername" --replace_string="$db_name" --target_file="$config"
ynh_replace_string --match_string= "mysqldatabasename" --replace_string="$db_name" --target_file="$config"
ynh_replace_string --match_string= "mysite.example" --replace_string="$domain" --target_file="$config"
ynh_replace_string --match_string= "if the auto install failed, put a unique random string here" --replace_string="$random_string" --target_file="$config"
sed -i "s/\['admin_email'\] = '';/\['admin_email'\] = '$email';/g" "$config"
ynh_replace_string --match_string= "//error_reporting(E_ERROR | E_WARNING | E_PARSE );" --replace_string="error_reporting(E_ERROR | E_WARNING | E_PARSE );" --target_file="$config"
ynh_replace_string --match_string= "//ini_set('error_log','php.out');" --replace_string="ini_set('error_log','php.log');" --target_file="$config"
ynh_replace_string --match_string= "//ini_set('log_errors','1');" --replace_string="ini_set('log_errors','1');" --target_file="$config"
ynh_replace_string --match_string= "//ini_set('display_errors', '0');" --replace_string="ini_set('display_errors', '0');" --target_file="$config"
sed -i "s/\['php_path'\] = 'php';/\['php_path'\] = 'php$phpversion';/g" "$config"
# addon LDAP config
ynh_script_progression --message="Push Ldap configuration to .htconfig.php..."
cat ../conf/ldap_conf.php >> $final_path/.htconfig.php
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring NGINX web server..."
# Create a dedicated nginx config
ynh_add_nginx_config
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chmod -R 775 $install_dir/store $install_dir/cache
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..."
ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
# Create a dedicated php-fpm config
ynh_add_fpm_config
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# CRON JOB CONFIGURATION
# COMPOSER
#=================================================
ynh_script_progression --message="Setting up cron job..."
ynh_script_progression --message="Pulling in external libraries with Composer..."
ynh_install_composer
#=================================================
# SPECIFIC SETUP
#=================================================
# PROVISION DATABASE
#=================================================
ynh_script_progression --message="Provisionning database..." --weight=1
if [ $database = "mysql" ]; then
ynh_mysql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $install_dir/install/schema_mysql.sql
elif [ $database = "postgresql" ]; then
ynh_psql_connect_as --user="$db_name" --password="$db_pwd" --database="$db_name" < $install_dir/install/schema_postgres.sql
fi
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression --message="Adding a configuration file..." --weight=1
ynh_add_config --template="../conf/htconfig.sample.php" --destination="$install_dir/.htconfig.php"
# addon ldap config
ynh_script_progression --message="Push LDAP configuration to .htconfig.php..."
cat ../conf/ldap_conf.php >> $install_dir/.htconfig.php
ynh_store_file_checksum --file=$install_dir/.htconfig.php
chmod 600 "$install_dir/.htconfig.php"
chown $app:$app "$install_dir/.htconfig.php"
#=================================================
# SET CRON JOB
#=================================================
ynh_script_progression --message="Setuping cron job..." --weight=1
# Set up cron job
ynh_add_config --template="../conf/poller-cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression --message="Configuring log rotation..."
ynh_script_progression --message="Configuring log rotation..." --weight=1
# Use logrotate to manage application logfile(s)
ynh_use_logrotate "$final_path/php.log"
ynh_use_logrotate "$install_dir/php.log"
#=================================================
# SETUP FAIL2BAN
#=================================================
ynh_script_progression --message="Add Fail2Ban..."
ynh_script_progression --message="Configuring Fail2Ban..." --weight=1
ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5"
#=================================================
# SETUP SSOWAT
#=================================================
ynh_script_progression --message="Configuring permissions..."
ynh_permission_update --permission="main" --add="visitors"
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_systemd_action --service_name=nginx --action=reload
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="$install_dir/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5"
#=================================================
# LDAP ADDON ACTIVATION
#=================================================
ynh_script_progression --message="Enabling ldapauth addon..."
pushd "$final_path"
pushd "$install_dir"
/usr/bin/php${YNH_PHP_VERSION} util/addons install ldapauth
popd
@ -269,4 +163,4 @@ popd
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed"
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -9,98 +9,40 @@
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user="$db_name"
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
database=$(ynh_app_setting_get --app=$app --key=database)
#=================================================
# REMOVE THE DATABASE
#=================================================
if [ $database -eq 1 ]; then
ynh_script_progression --message="Removing MySQL database..."
if [ $database = "mysql" ]; then
ynh_script_progression --message="Removing MySQL database..." --weight=1
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
elif [ $database -eq 2 ]; then
# Removing postgresql database
ynh_script_progression --message="Removing postgreSQL database..."
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
elif [ $database = "postgresql" ]; then
ynh_script_progression --message="Removing PostgreSQL database..." --weight=1
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
fi
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies"
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE APP MAIN DIR
#=================================================
ynh_script_progression --message="Removing app main directory..."
# Remove the app directory securely
ynh_secure_remove --file="$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..."
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1
# Remove the dedicated NGINX config
ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Removing PHP-FPM configuration..."
# Remove the dedicated php-fpm config
# Remove the dedicated PHP-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 THE CRON FILE
#=================================================
# Remove the dedicated Fail2Ban config
ynh_remove_fail2ban_config
# Remove a cron file
ynh_secure_remove --file="/etc/cron.d/$app"
#=================================================
# REMOVE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Removing Fail2Ban configuration..."
ynh_remove_fail2ban_config
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user
ynh_system_user_delete --username=$app
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed"
ynh_script_progression --message="Removal of $app completed" --last

107
scripts/restore Executable file → Normal file
View file

@ -6,85 +6,31 @@
# 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 /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading settings..."
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
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)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
database=$(ynh_app_setting_get --app=$app --key=database)
db_user=$db_name
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..."
test ! -d $final_path || ynh_die --message="There is already a directory: $final_path "
#=================================================
# STANDARD RESTORATION STEPS
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_print_info "Recreating the dedicated system user..."
# Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..."
ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path"
ynh_restore_file --origin_path="$install_dir"
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#=================================================
# RESTORE THE MYSQL DATABASE
# RESTORE THE DATABASE
#=================================================
ynh_script_progression --message="Restoring the database..."
ynh_install_app_dependencies $pkg_dependencies_main
if [ $database -eq 1 ]; then
ynh_script_progression --message="Restoring MySQL database..."
if [ $database = "mysql" ]; then
ynh_script_progression --message="Restoring MySQL database..." --weight=1
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql
elif [ $database -eq 2 ]; then
# Reinstalling postgresql database
ynh_script_progression --message="Reinstalling dependencies..."
# Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies_psql
ynh_script_progression --message="Restoring the PostgreSQL database..."
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
elif [ $database = "postgresql" ]; then
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
ynh_psql_test_if_first_run
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
@ -92,39 +38,28 @@ elif [ $database -eq 2 ]; then
fi
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
# RESTORE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring PHP-FPM configuration..."
ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=1
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
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
#=================================================
# RESTORE THE CRON FILE
#=================================================
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/cron.d/$app"
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
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
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload
@ -133,4 +68,4 @@ ynh_systemd_action --service_name=nginx --action=reload
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app"
ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -12,209 +12,138 @@ source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..."
ynh_script_progression --message="Loading settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
email=$(ynh_user_get_info --username=$admin --key=mail)
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)
upload=$(ynh_app_setting_get --app=$app --key=upload)
version=$(grep STD_VERSION $final_path/boot.php | cut -c 38- | rev | cut -c 5- | rev)
last_update=$(grep update_time: /etc/yunohost/apps/$app/settings.yml | cut -c 14-)
database=$(ynh_app_setting_get --app=$app --key=database)
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
# 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
# If fpm_footprint doesn't exist, create it
if [ -z "$fpm_footprint" ]; then
fpm_footprint=low
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
fi
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..."
# Backup the current version of the app
ynh_backup_before_upgrade
ynh_clean_setup () {
# restore it if the upgrade fails
ynh_restore_upgradebackup
}
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# Migrate legacy permissions to new system
#=================================================
ynh_script_progression --message="Ensuring downward compatibility..."
# If final_path doesn't exist, create it
if [ -z "$final_path" ]; then
final_path=/var/www/$app
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
# If fpm_free_footprint doesn't exist, create it
if [ -z "$fpm_free_footprint" ]; then
fpm_free_footprint=0
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
fi
if ynh_legacy_permissions_exists
then
ynh_legacy_permissions_delete_all
ynh_app_setting_delete --app=$app --key=is_public
# If fpm_usage doesn't exist, create it
if [ -z "$fpm_usage" ]; then
fpm_usage=low
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
fi
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Making sure dedicated system user exists..."
# Create a dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir="$final_path"
# Switch $database to "mysql" or "postgresql"
if [[ $database == "1" ]] 2>/dev/null; then
database="mysql"
ynh_app_setting_set --app=$app --key=database --value=$database
elif [[ $database == "2" ]] 2>/dev/null; then
database="postgresql"
ynh_app_setting_set --app=$app --key=database --value=$database
fi
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
# ynh_setup_source --dest_dir="$final_path"
if [ `cd $final_path && git rev-parse --is-inside-work-tree` ]; then
pushd "$final_path"
git pull --quiet
ynh_install_composer
cd extend/addon/zaddons
git pull --quiet
cd ../../..
filelist=(`ls extend/addon/zaddons`)
cd addon
for a in "${filelist[@]}" ; do
base=`basename $a`
if [ $base = '.git' ]; then
#echo 'ignoring git'
continue;
fi
if [ ! -d ../extend/addon/zaddons/$base ]; then
#echo $a 'not a directory'
continue;
fi
if [ -x $base ]; then
#echo $base 'file exists'
continue;
fi
echo linking $base
ln -s ../extend/addon/zaddons/$base $base
done
for x in `ls` ; do
if [ -L "$x" ] && ! [ -e "$x" ]; then
echo "removing dead symlink $x" ;
rm -- "$x";
fi;
done
popd
chmod -R 775 $final_path/store
else
# Create a temporary directory
tmpdir="$(ynh_smart_mktemp 6000)"
# Backup the config file in the temp dir
cp -a "$final_path/.htconfig.php" "$tmpdir/.htconfig.php"
cp -a "$final_path/store" "$tmpdir/store"
cp -a "$final_path/php.log" "$tmpdir/php.log"
cp -a "$final_path/cache" "$tmpdir/cache"
# Remove the app directory securely
ynh_secure_remove "$final_path"
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
ynh_script_progression --message="Upgrading source files..." --weight=1
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path"
cp -a "$tmpdir/cache" "${final_path}"
cp -a "$tmpdir/store" "${final_path}"
cp -a "$tmpdir/.htconfig.php" "${final_path}"
cp -a "$tmpdir/php.log" "${final_path}"
ynh_secure_remove --file="$tmpdir"
chmod -R 775 $final_path/store
mkdir $final_path/addon
ynh_setup_source --dest_dir="$final_path/addon" --source_id="app_addons"
ynh_setup_source --dest_dir="$install_dir" --keep="store/ .htconfig.php php.log"
ynh_setup_source --dest_dir="$install_dir/addon" --source_id="addons"
fi
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
mkdir -p "$install_dir/store"
mkdir -p "$install_dir/cache/smarty3"
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..."
# Create a dedicated nginx config
ynh_add_nginx_config
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
chmod -R 775 $install_dir/store $install_dir/cache
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..."
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
# Create a dedicated php-fpm config
ynh_add_fpm_config
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
ynh_backup_if_checksum_is_different --file="$final_path/.htconfig.php"
# Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$final_path/.htconfig.php"
# Create a dedicated NGINX config
ynh_add_nginx_config
#=================================================
# SETUP LOGROTATE
# SPECIFIC UPGRADE
#=================================================
ynh_script_progression --message="Upgrading logrotate configuration..."
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=1
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
if [ $database = "mysql" ]; then
db_type=0
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
# Change your databases character set and collation
ynh_mysql_connect_as --user=$db_user --password="$db_pwd" --database=$db_name \
<<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
elif [ $database = "postgresql" ]; then
db_type=1
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
fi
ynh_add_config --template="../conf/htconfig.sample.php" --destination="$install_dir/.htconfig.php"
# addon ldap config
ynh_script_progression --message="Push LDAP configuration to .htconfig.php..."
cat ../conf/ldap_conf.php >> $install_dir/.htconfig.php
ynh_store_file_checksum --file=$install_dir/.htconfig.php
chmod 600 "$install_dir/.htconfig.php"
chown $app:$app "$install_dir/.htconfig.php"
#=================================================
# UPGRADE FAIL2BAN
# UPGRADE CRON JOB
#=================================================
ynh_script_progression --message="Re-configure Fail2Ban..."
ynh_add_fail2ban_config --logpath="$final_path/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5"
#=================================================
# UPGRADE CRON
#=================================================
ynh_script_progression --message="Setting up cron job..."
ynh_script_progression --message="Upgrading cron job..." --weight=1
# Set up cron job
ynh_add_config --template="../conf/poller-cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"
#=================================================
# UPGRADE DEPENDENCIES
# GENERIC FINALIZATION
#=================================================
ynh_script_progression --message="Upgrading dependencies..."
ynh_install_app_dependencies $pkg_dependencies_main
if [ $database -eq 2 ]; then
ynh_install_app_dependencies $pkg_dependencies_psql
fi
# SETUP LOGROTATE
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reloading NGINX web server..."
ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload
# Use logrotate to manage app-specific logfile(s)
ynh_use_logrotate --non-append
# Create a dedicated Fail2Ban config
ynh_add_fail2ban_config --logpath="$install_dir/php.log" --failregex="^.*auth\.php.*failed login attempt.*from IP <HOST>.*$" --max_retry="5"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed"
ynh_script_progression --message="Upgrade of $app completed" --last

29
tests.toml Normal file
View file

@ -0,0 +1,29 @@
test_format = 1.0
[default]
# ------------
# Tests to run
# ------------
exclude = ["change_url"]
# -------------------------------
# Default args to use for install
# -------------------------------
args.database="mysql"
# -------------------------------
# Commits to test upgrade from
# -------------------------------
test_upgrade_from.7c4bcff615c9ea9e87b2d5bad110dc10b1921efc.name = "Upgrade from 8.4.1"
[with_postgresql]
only = ["install.subdir"]
args.database="postgresql"