diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index e36f907..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,44 +0,0 @@ -Changelog -========= - -## [1.0~ynh4](https://github.com/YunoHost-Apps/my_webapp_ynh/pull/60) - 2021-04-23 - -#### Added -* [Add a README_fr](https://github.com/YunoHost-Apps/my_webapp_ynh/pull/60/commits/c84b7d4e97f00e2c7de10d949891cf660f1d8459) - -#### Changed -* [Use php7.3](https://github.com/YunoHost-Apps/my_webapp_ynh/pull/60/commits/b324c78780110e8eae05da47f8f151c1d50bf3c7) -* [New permissions](https://github.com/YunoHost-Apps/my_webapp_ynh/pull/60/commits/a5cc8741477a0f37ffd1b84e08bb3dec8af34a46) -# [Normalization from example_ynh](https://github.com/YunoHost-Apps/my_webapp_ynh/pull/60/commits/a5cc8741477a0f37ffd1b84e08bb3dec8af34a46) - -## [1.0~ynh3](https://github.com/YunoHost-Apps/my_webapp_ynh/pull/42) - 2020-01-01 - -#### Added -* [Add a changelog](https://github.com/YunoHost-Apps/my_webapp_ynh/pull/42/commits/60710bb18e1a4b7a3614e55d23e059af91969ea4) -* [Actions and config-panel](https://github.com/YunoHost-Apps/my_webapp_ynh/pull/42/commits/56e40ac3a10e89a106418695268dec271a04ebb2) - -#### Changed -* [use scalable phpfpm](https://github.com/YunoHost-Apps/my_webapp_ynh/pull/42/commits/6e33fd4c24f9f83bc1378b05aba20d7da3dcb406) -* [Optionnal sftp](https://github.com/YunoHost-Apps/my_webapp_ynh/pull/42/commits/f2e31fa4924c9985233e574c2c2f318eb3579996) -- [Various upgrades](https://github.com/YunoHost-Apps/my_webapp_ynh/pull/42/commits/5ee2886daa40de744139bfee1390703ba958bd30) - -## [1.0~ynh2](https://github.com/YunoHost-Apps/my_webapp_ynh/pull/39) - 2019-05-26 - -#### Changed -- [Normalization from example_ynh](https://github.com/YunoHost-Apps/my_webapp_ynh/pull/39/commits/cccc014552bf85fc682d1fc59e1b9c67ad8ec6f8) - - -## [1.0~ynh1](https://github.com/YunoHost-Apps/my_webapp_ynh/pull/34) - 2019-03-22 - -#### Added -- [Add progression with ynh_print_info](https://github.com/YunoHost-Apps/my_webapp_ynh/pull/34/commits/8c2f9fa5c7a6ab90ebbbee4eb4b82ed2be6ee292) - -#### Changed -- [Normalization from example_ynh](https://github.com/YunoHost-Apps/my_webapp_ynh/pull/34/commits/034e5fc83c8515d2a7781548600ab82b44c8611b) -- [Use php7](https://github.com/YunoHost-Apps/my_webapp_ynh/pull/34/commits/0f0bef3b8ca06d8f36f3de90c3502c529a6bc280) - - -## [1.0](https://github.com/YunoHost-Apps/my_webapp_ynh/pull/31) - 2019-03-13 - -#### Changed -- [Apply example_ynh](https://github.com/YunoHost-Apps/my_webapp_ynh/pull/31) diff --git a/README.md b/README.md index 66c252b..a297cf9 100644 --- a/README.md +++ b/README.md @@ -20,18 +20,14 @@ This application allows you to easily install a custom Web application, providin It can also create a MySQL database - which will be backed up and restored with your application. The connection details will be stored in the file `db_access.txt` located in the root directory. -PHP-FPM version can also be selected among 7.3, 7.4, 8.0, 8.1 and 8.2. +PHP-FPM version can also be selected among `none`, `7.4`, `8.0`, `8.1` and `8.2`. **Once installed, go to the chosen URL to know the user, domain and port you will have to use for the SFTP access.** The password is one you chosen during the installation. Under the Web directory, you will see a `www` folder which contains the public files served by this app. You can put all the files of your custom Web application inside. +If you want to add customized nginx configuration, put it in `/etc/nginx/conf.d/YOUR_DOMAIN.d/my_webapp.d/WHATEVER_NAME.conf` (ensure that the file has the `.conf` extension, and change `my_webapp.d` to `my_webapp__xx.d` if you want to change the configuration of the second or more installation of my_webapp). -**Shipped version:** 1.0~ynh13 -## Disclaimers / important information - -#### SFTP port - -You may have change the SSH port as described in this section: [Modify the SSH port](https://yunohost.org/en/security#modify-the-ssh-port); then you should use this port to update your website with SFTP. +**Shipped version:** 1.0~ynh12 ## Documentation and resources * Upstream app code repository: diff --git a/README_fr.md b/README_fr.md index 4beb9aa..ff90d05 100644 --- a/README_fr.md +++ b/README_fr.md @@ -20,18 +20,14 @@ Cette application vous permet d'installer facilement une application vide person Elle peut également créer une base de données MySQL - qui sera sauvegardée et restaurée avec votre application. Les détails de connexion seront stockés dans le fichier `db_accesss.txt` situé dans le répertoire racine. -La version de PHP-FPM peut aussi être choisie, parmi 7.3, 7.4, 8.0, 8.1 et 8.2. +La version de PHP-FPM peut aussi être choisie, parmi `none`, `7.4`, `8.0`, `8.1` et `8.2`. **Une fois installé, rendez-vous sur l'URL choisie pour connaître l'utilisateur, le domaine et le port que vous devrez utiliser pour l'accès SFTP.** Le mot de passe est celui que vous avez choisi lors de l'installation. Sous le répertoire Web, vous verrez un dossier `www` qui contient les fichiers publics servis par cette application. Vous pouvez mettre tous les fichiers de votre application Web personnalisée à l'intérieur. +Si vous voulez ajouter une configuration personnalisée de nginx, mettez-la dans `/etc/nginx/conf.d/votre_domaine.d/my_webapp.d/WHATEVER_NAME.conf` (assurez-vous que le fichier a l'extension `.conf`, et changez `my_webapp.d` en `my_webapp__xx.d` si vous voulez changer la configuration de la deuxième installation ou plus de my_webapp). -**Version incluse :** 1.0~ynh13 -## Avertissements / informations importantes - -#### Port SFTP - -Vous avez peut-être changé le port SSH comme décrit dans cette section : [Modifier le port SSH](https://yunohost.org/fr/security#modify-the-ssh-port) ; alors vous devriez utiliser ce port pour mettre à jour votre site Web avec SFTP. +**Version incluse :** 1.0~ynh12 ## Documentations et ressources * Dépôt de code officiel de l’app : diff --git a/check_process b/check_process deleted file mode 100644 index afaef57..0000000 --- a/check_process +++ /dev/null @@ -1,120 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - path="/path" - with_sftp=1 - password="myreallystrengthpassword" - is_public=1 - phpversion="7.4" - with_mysql=1 - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - upgrade=1 from_commit=a050e55533ae7bbb63fce44fd1508ad78b8a645c - backup_restore=1 - multi_instance=1 - port_already_use=0 - change_url=1 -;; Test without sftp - ; Manifest - domain="domain.tld" - path="/path" - with_sftp=0 - password="" - is_public=1 - phpversion="7.4" - with_mysql=1 - ; Checks - setup_sub_dir=1 - upgrade=1 - backup_restore=1 -;; Test without mysql - ; Manifest - domain="domain.tld" - path="/path" - with_sftp=1 - password="myreallystrengthpassword" - is_public=1 - phpversion="7.4" - with_mysql=0 - ; Checks - setup_sub_dir=1 - upgrade=1 - backup_restore=1 -;; Test without PHP - ; Manifest - domain="domain.tld" - path="/path" - with_sftp=0 - password="myreallystrengthpassword" - is_public=1 - phpversion="none" - with_mysql=0 - ; Checks - setup_sub_dir=1 - upgrade=1 - backup_restore=1 -;; Test with PHP7.4 - ; Manifest - domain="domain.tld" - path="/path" - with_sftp=0 - password="myreallystrengthpassword" - is_public=1 - phpversion="7.4" - with_mysql=0 - ; Checks - setup_sub_dir=1 - upgrade=1 - backup_restore=1 -;; Test with PHP8.0 - ; Manifest - domain="domain.tld" - path="/path" - with_sftp=0 - password="myreallystrengthpassword" - is_public=1 - phpversion="8.0" - with_mysql=0 - ; Checks - setup_sub_dir=1 - upgrade=1 - backup_restore=1 -;; Test with PHP8.1 - ; Manifest - domain="domain.tld" - path="/path" - with_sftp=0 - password="myreallystrengthpassword" - is_public=1 - phpversion="8.1" - with_mysql=0 - ; Checks - setup_sub_dir=1 - upgrade=1 - backup_restore=1 -;; Test with PHP8.2 - ; Manifest - domain="domain.tld" - path="/path" - with_sftp=0 - password="myreallystrengthpassword" - is_public=1 - phpversion="8.2" - with_mysql=0 - ; Checks - setup_sub_dir=1 - upgrade=1 - backup_restore=1 -;;; Options -Email= -Notification=change -;;; Upgrade options - ; commit=a050e55533ae7bbb63fce44fd1508ad78b8a645c - name=May 26, 2019 - manifest_arg=domain=DOMAIN&path=PATH&password=myreallystrengthpassword&is_public=1&with_mysql=1 diff --git a/conf/example-custom-nginx-config.conf b/conf/example-custom-nginx-config.conf new file mode 100644 index 0000000..0d72ff4 --- /dev/null +++ b/conf/example-custom-nginx-config.conf @@ -0,0 +1,2 @@ +# Common parameter to increase upload size limit in conjunction with dedicated PHP-FPM file +#client_max_body_size 1G; \ No newline at end of file diff --git a/conf/extra_php-fpm.conf b/conf/extra_php-fpm.conf index a2e3d58..4af9c64 100644 --- a/conf/extra_php-fpm.conf +++ b/conf/extra_php-fpm.conf @@ -1,6 +1,6 @@ ; Additional php.ini defines, specific to this pool of workers. -php_value[upload_max_filesize] = 1G -php_value[post_max_size] = 1G +php_value[upload_max_filesize] = 500M +php_value[post_max_size] = 500M php_value[default_charset] = UTF-8 php_value[always_populate_raw_post_data] = -1 diff --git a/conf/nginx-php.conf b/conf/nginx-php.conf new file mode 100644 index 0000000..f68f202 --- /dev/null +++ b/conf/nginx-php.conf @@ -0,0 +1,10 @@ +# Execute and serve PHP files +location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $request_filename; +} diff --git a/conf/nginx_no_php.conf b/conf/nginx.conf similarity index 80% rename from conf/nginx_no_php.conf rename to conf/nginx.conf index e0eacb3..9f696ae 100644 --- a/conf/nginx_no_php.conf +++ b/conf/nginx.conf @@ -2,10 +2,7 @@ location __PATH__/ { # Path to source - alias __FINALPATH__/www/; - - # Common parameter to increase upload size limit in conjunction with dedicated PHP-FPM file - #client_max_body_size 1G; + alias __INSTALL_DIR__/www/; # Default indexes and catch-all index index.html index.php; @@ -16,6 +13,7 @@ location __PATH__/ { log_not_found off; access_log off; } + location = __PATH__/robots.txt { allow all; log_not_found off; @@ -27,6 +25,8 @@ location __PATH__/ { deny all; } + include conf.d/__DOMAIN__.d/__APP__.d/*.conf; + # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; } diff --git a/conf/nginx_with_php.conf b/conf/nginx_with_php.conf deleted file mode 100644 index a2367c5..0000000 --- a/conf/nginx_with_php.conf +++ /dev/null @@ -1,43 +0,0 @@ -#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; -location __PATH__/ { - - # Path to source - alias __FINALPATH__/www/; - - # Common parameter to increase upload size limit in conjunction with dedicated PHP-FPM file - #client_max_body_size 1G; - - # Default indexes and catch-all - index index.html index.php; - try_files $uri $uri/ __PATH__/index.php?$args; - - # Prevent useless logs - location = __PATH__/favicon.ico { - log_not_found off; - access_log off; - } - location = __PATH__/robots.txt { - allow all; - log_not_found off; - access_log off; - } - - # Deny access to hidden files and directories - location ~ ^__PATH__/(.+/|)\.(?!well-known\/) { - deny all; - } - - # Execute and serve PHP files - location ~ [^/]\.php(/|$) { - fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; - fastcgi_index index.php; - include fastcgi_params; - fastcgi_param REMOTE_USER $remote_user; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param SCRIPT_FILENAME $request_filename; - } - - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; -} diff --git a/config_panel.toml b/config_panel.toml index bff497e..b229f0f 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -24,7 +24,7 @@ name = "My Webapp configuration" [main.php_fpm_config.phpversion] ask = "PHP version" type = "select" - choices = ["none", "7.3", "7.4", "8.0", "8.1", "8.2"] + choices = ["none", "7.4", "8.0", "8.1", "8.2"] default = "none" [main.php_fpm_config.fpm_footprint] diff --git a/doc/ADMIN.md b/doc/ADMIN.md new file mode 100644 index 0000000..b72bee4 --- /dev/null +++ b/doc/ADMIN.md @@ -0,0 +1,17 @@ +### Login using SFTP + +Once installed, go to the chosen URL to know the username, domain and port you will have to use for the SFTP access. + +- Username: __ID__ +- Password: password chosen during installation +- Port: 22 (unless change to another port) + +To connect, you'll need an SFTP app such as [Filezilla](https://filezilla-project.org/) for Windows, Mac or Linux. You can also use your default file manager on [Mac](https://support.apple.com/guide/mac-help/connect-mac-shared-computers-servers-mchlp1140/mac) or Linux. + +### Adding or editing files + +Once logged in SFTP, under the Web directory, you will see a `www` folder which contains the public files served by this app. You can put all the files of your custom Web application inside. + +### Forgot your SFTP password? + +If you forgot your SFTP password, you can change it in YunoHost's webadmin interface in `Apps > My webapp > My Webapp configuration`. diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md new file mode 100644 index 0000000..84e839a --- /dev/null +++ b/doc/ADMIN_fr.md @@ -0,0 +1,21 @@ +### Connexion avec SFTP + +Une fois installée, rendez-vous sur l'URL choisie pour connaître le nom d'utilisateur, le domaine et le port que vous devrez utiliser pour l'accès SFTP. + +- Nom d'utilisateur: __ID__ +- Mot de passe: mot de passe défini lors de l'installation +- Port: 22 (sauf si modifier pour un autre port) + +Pour vous connectez, vous devrez utiliser une application SFTP tel que [Filezilla](https://filezilla-project.org/) pour Windows, Mac ou Linux. Vous pouvez aussi directement utiliser votre gestionnaire de fichiers sous Linux ou [Mac](https://support.apple.com/guide/mac-help/connect-mac-shared-computers-servers-mchlp1140/mac). + +### Ajouter ou modifier les fichiers + +Après vous être connecté avec SFTP, sous le répertoire Web, vous verrez un dossier `www` qui contient les fichiers publics servis par cette application. Vous pouvez mettre tous les fichiers de votre application Web personnalisée à l'intérieur. + +### Oubli du mot de passe SFTP + +Si vous avez oublié votre mot de passe SFTP, vous pouvez le changer dans la webadmin de Yunohost dans `Applications > Votre webapp > My Webapp configuration`. + +## Résolution de problèmes + +Si vous n'arrivez pas à vous connecter et que vous avez vérifié que le nom d'utilisateur et le mot de passe sont bons, vérifiez si SFTP est activé pour votre app diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index 9a5eea2..f24ccce 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -2,6 +2,8 @@ This application allows you to easily install a custom Web application, providin It can also create a MySQL database - which will be backed up and restored with your application. The connection details will be stored in the file `db_access.txt` located in the root directory. -PHP-FPM version can also be selected among 7.3, 7.4, 8.0, 8.1 and 8.2. +PHP-FPM version can also be selected among `none`, `7.4`, `8.0`, `8.1` and `8.2`. **Once installed, go to the chosen URL to know the user, domain and port you will have to use for the SFTP access.** The password is one you chosen during the installation. Under the Web directory, you will see a `www` folder which contains the public files served by this app. You can put all the files of your custom Web application inside. + +If you want to add customized nginx configuration, put it in `/etc/nginx/conf.d/YOUR_DOMAIN.d/my_webapp.d/WHATEVER_NAME.conf` (ensure that the file has the `.conf` extension, and change `my_webapp.d` to `my_webapp__xx.d` if you want to change the configuration of the second or more installation of my_webapp). diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md index b1eef70..956bd4a 100644 --- a/doc/DESCRIPTION_fr.md +++ b/doc/DESCRIPTION_fr.md @@ -2,6 +2,8 @@ Cette application vous permet d'installer facilement une application vide person Elle peut également créer une base de données MySQL - qui sera sauvegardée et restaurée avec votre application. Les détails de connexion seront stockés dans le fichier `db_accesss.txt` situé dans le répertoire racine. -La version de PHP-FPM peut aussi être choisie, parmi 7.3, 7.4, 8.0, 8.1 et 8.2. +La version de PHP-FPM peut aussi être choisie, parmi `none`, `7.4`, `8.0`, `8.1` et `8.2`. **Une fois installé, rendez-vous sur l'URL choisie pour connaître l'utilisateur, le domaine et le port que vous devrez utiliser pour l'accès SFTP.** Le mot de passe est celui que vous avez choisi lors de l'installation. Sous le répertoire Web, vous verrez un dossier `www` qui contient les fichiers publics servis par cette application. Vous pouvez mettre tous les fichiers de votre application Web personnalisée à l'intérieur. + +Si vous voulez ajouter une configuration personnalisée de nginx, mettez-la dans `/etc/nginx/conf.d/votre_domaine.d/my_webapp.d/WHATEVER_NAME.conf` (assurez-vous que le fichier a l'extension `.conf`, et changez `my_webapp.d` en `my_webapp__xx.d` si vous voulez changer la configuration de la deuxième installation ou plus de my_webapp). diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index 1f6de18..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1,3 +0,0 @@ -#### SFTP port - -You may have change the SSH port as described in this section: [Modify the SSH port](https://yunohost.org/en/security#modify-the-ssh-port); then you should use this port to update your website with SFTP. diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md deleted file mode 100644 index a95b44b..0000000 --- a/doc/DISCLAIMER_fr.md +++ /dev/null @@ -1,3 +0,0 @@ -#### Port SFTP - -Vous avez peut-être changé le port SSH comme décrit dans cette section : [Modifier le port SSH](https://yunohost.org/fr/security#modify-the-ssh-port) ; alors vous devriez utiliser ce port pour mettre à jour votre site Web avec SFTP. diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md new file mode 100644 index 0000000..3658b58 --- /dev/null +++ b/doc/POST_INSTALL.md @@ -0,0 +1,16 @@ +If you have requested a MYSQL database, please find information about this SQL database: + +Database user: __DB_USER__ +Database name: __DB_NAME__ +Password: __DB_PWD__ + +You can connect to this repository by using SFTP with the following credentials. + +Domain: __DOMAIN__ +Port: 22 (unless change to another port) +User: __ID__ +Password: password chosen during installation + +This app is simply a blank web app container. You have to put your own app inside. + +Please put your files into this directory: __INSTALL_DIR__/www/ diff --git a/doc/POST_INSTALL_fr.md b/doc/POST_INSTALL_fr.md new file mode 100644 index 0000000..af9317f --- /dev/null +++ b/doc/POST_INSTALL_fr.md @@ -0,0 +1,14 @@ +Si vous avez demandé une base de données MYSQL, voici les informations de cette base de données SQL : + +Utilisateur de la base de données : __DB_USER__ +Nom de la base de données : __DB_NAME__ +Mot de passe : __DB_PWD__ + +Vous pouvez vous connecter à ce répertoir en utilisant SFTP avec les informations d'identification suivantes : + +Domaine : __DOMAIN__ +Port : 22 (sauf si modifier pour un autre port) +ID de l'utilisateur : __ID__ +Mot de passe : mot de passe défini lors de l'installation + +Cette application est un simple conteneur vierge d'application Web. Vous devez mettre votre propre application à l'intérieur de ce répertoire : __INSTALL_DIR__/www/ diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 2b6527a..0000000 --- a/manifest.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "name": "My Webapp", - "id": "my_webapp", - "packaging_format": 1, - "description": { - "en": "Custom Web app with SFTP access to serve static (HTML, CSS, JS) and PHP files", - "fr": "Application Web personnalisée avec accès SFTP pour servir des fichiers statiques (HTML, CSS, JS) et PHP" - }, - "version": "1.0~ynh13", - "url": "https://github.com/YunoHost-Apps/my_webapp_ynh", - "upstream": { - "license": "GPL-3.0-only", - "code": "https://github.com/YunoHost-Apps/my_webapp_ynh" - }, - "license": "GPL-3.0-only", - "maintainer": { - "name": "", - "email": "" - }, - "previous_maintainers": [{ - "name": "Maniack Crudelis", - "email": "maniackc_dev@crudelis.fr" - }], - "requirements": { - "yunohost": ">= 11.0.9" - }, - "multi_instance": true, - "services": [ - "nginx", - "php7.4-fpm", - "mysql" - ], - "arguments": { - "install" : [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "path", - "type": "path", - "example": "/site", - "default": "/site" - }, - { - "name": "with_sftp", - "type": "boolean", - "ask": { - "en": "Do you need a SFTP access?", - "fr": "Avez-vous besoin d'un accès SFTP ?" - }, - "default": true - }, - { - "name": "password", - "type": "password", - "optional": true - }, - { - "name": "is_public", - "type": "boolean", - "default": true - }, - { - "name": "phpversion", - "type": "string", - "ask": { - "en": "Choose a PHP version you want to use for your app", - "fr": "Choisissez une version PHP que vous souhaitez utiliser pour votre application" - }, - "choices" : ["none", "7.3", "7.4", "8.0", "8.1", "8.2"], - "default" : "7.4" - }, - { - "name": "with_mysql", - "type": "boolean", - "ask": { - "en": "Do you need a MySQL database?", - "fr": "Avez-vous besoin d'une base de données MySQL ?" - }, - "default": false - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..35d325b --- /dev/null +++ b/manifest.toml @@ -0,0 +1,81 @@ +packaging_format = 2 + +id = "my_webapp" +name = "My Webapp" +description.en = "Custom Web app with SFTP access to serve static (HTML, CSS, JS) and PHP files" +description.fr = "Application Web personnalisée avec accès SFTP pour servir des fichiers statiques (HTML, CSS, JS) et PHP" + +version = "1.0~ynh12" + +maintainers = [] + +[upstream] +license = "GPL-3.0-only" +code = "https://github.com/YunoHost-Apps/my_webapp_ynh" + +[integration] +yunohost = ">= 11.1.18" +architectures = "all" +multi_instance = true +ldap = "not_relevant" +sso = "not_relevant" +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" + +[install] + [install.domain] + type = "domain" + + [install.path] + type = "path" + default = "/site" + + [install.with_sftp] + ask.en = "Do you need a SFTP access?" + ask.fr = "Avez-vous besoin d'un accès SFTP ?" + type = "boolean" + default = true + + [install.password] + type = "password" + optional = true + + [install.init_main_permission] + type = "group" + default = "visitors" + + [install.phpversion] + ask.en = "Choose a PHP version you want to use for your app" + ask.fr = "Choisissez une version PHP que vous souhaitez utiliser pour votre application" + type = "string" + choices = ["none", "7.4", "8.0", "8.1", "8.2"] + default = "8.0" + + [install.with_mysql] + ask.en = "Do you need a MySQL database?" + ask.fr = "Avez-vous besoin d'une base de données MySQL ?" + type = "boolean" + default = false + +[resources] + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" + + [resources.apt] + packages = "nginx" # Kind of "dummy" value to be sure to have a non-empty dep list + packages_from_raw_bash = """ + if [[ "$with_mysql" = 1 ]] + then + echo "mariadb-server" + fi + + if [[ "$phpversion" != none ]] + then + echo "php${phpversion}-fpm php${phpversion}-mysql" + fi + """ diff --git a/scripts/_common.sh b/scripts/_common.sh index 31498b2..d400d3d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,151 +8,10 @@ # EXPERIMENTAL HELPERS #================================================= -# Send an email to inform the administrator -# -# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type] -# | arg: -m --app_message= - The file with the content to send to the administrator. -# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root -# example: "root admin@domain" -# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you -# example: "root admin@domain user1 user2" -# | arg: -t, --type= - Type of mail, could be 'backup', 'change_url', 'install', 'remove', 'restore', 'upgrade' -ynh_send_readme_to_admin() { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [m]=app_message= [r]=recipients= [t]=type= ) - local app_message - local recipients - local type - # Manage arguments with getopts - - ynh_handle_getopts_args "$@" - app_message="${app_message:-}" - recipients="${recipients:-root}" - type="${type:-install}" - - # Get the value of admin_mail_html - admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) - admin_mail_html="${admin_mail_html:-0}" - - # Retrieve the email of users - find_mails () { - local list_mails="$1" - local mail - local recipients=" " - # Read each mail in argument - for mail in $list_mails - do - # Keep root or a real email address as it is - if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@" - then - recipients="$recipients $mail" - else - # But replace an user name without a domain after by its email - if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null) - then - recipients="$recipients $mail" - fi - fi - done - echo "$recipients" - } - recipients=$(find_mails "$recipients") - - # Subject base - local mail_subject="☁️🆈🅽🅷☁️: \`$app\`" - - # Adapt the subject according to the type of mail required. - if [ "$type" = "backup" ]; then - mail_subject="$mail_subject has just been backup." - elif [ "$type" = "change_url" ]; then - mail_subject="$mail_subject has just been moved to a new URL!" - elif [ "$type" = "remove" ]; then - mail_subject="$mail_subject has just been removed!" - elif [ "$type" = "restore" ]; then - mail_subject="$mail_subject has just been restored!" - elif [ "$type" = "upgrade" ]; then - mail_subject="$mail_subject has just been upgraded!" - else # install - mail_subject="$mail_subject has just been installed!" - fi - - local mail_message="This is an automated message from your beloved YunoHost server. - -Specific information for the application $app. - -$(if [ -n "$app_message" ] -then - cat "$app_message" -else - echo "...No specific information..." -fi) - ---- -Automatic diagnosis data from YunoHost - -__PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')__PRE_TAG2__" - - # Store the message into a file for further modifications. - echo "$mail_message" > mail_to_send - - # If a html email is required. Apply html tags to the message. - if [ "$admin_mail_html" -eq 1 ] - then - # Insert 'br' tags at each ending of lines. - ynh_replace_string "$" "
" mail_to_send - - # Insert starting HTML tags - sed --in-place '1s@^@\n\n\n\n@' mail_to_send - - # Keep tabulations - ynh_replace_string " " "\ \ " mail_to_send - ynh_replace_string "\t" "\ \ " mail_to_send - - # Insert url links tags - ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "\1" mail_to_send - - # Insert pre tags - ynh_replace_string "__PRE_TAG1__" "
" mail_to_send
-		ynh_replace_string "__PRE_TAG2__" "<\pre>" mail_to_send
-
-		# Insert finishing HTML tags
-		echo -e "\n\n" >> mail_to_send
-
-	# Otherwise, remove tags to keep a plain text.
-	else
-		# Remove URL tags
-		ynh_replace_string "__URL_TAG[1,3]__" "" mail_to_send
-		ynh_replace_string "__URL_TAG2__" ": " mail_to_send
-
-		# Remove PRE tags
-		ynh_replace_string "__PRE_TAG[1-2]__" "" mail_to_send
-	fi
-
-	# Define binary to use for mail command
-	if [ -e /usr/bin/bsd-mailx ]
-	then
-		local mail_bin=/usr/bin/bsd-mailx
-	else
-		local mail_bin=/usr/bin/mail.mailutils
-	fi
-
-	if [ "$admin_mail_html" -eq 1 ]
-	then
-		content_type="text/html"
-	else
-		content_type="text/plain"
-	fi
-
-	# Send the email to the recipients
-	cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients"
-}
-
-#=================================================
-
 ynh_maintenance_mode_ON () {
-	# Load value of $path_url and $domain from the config if their not set
-	if [ -z $path_url ]; then
-		path_url=$(ynh_app_setting_get $app path)
+	# Load value of $path and $domain from the config if their not set
+	if [ -z $path ]; then
+		path=$(ynh_app_setting_get $app path)
 	fi
 	if [ -z $domain ]; then
 		domain=$(ynh_app_setting_get $app domain)
@@ -182,10 +41,10 @@ ynh_maintenance_mode_ON () {
 " > "/var/www/html/maintenance.$app.html"
 
 	# Create a new nginx config file to redirect all access to the app to the maintenance notice instead.
-	echo "# All request to the app will be redirected to ${path_url}_maintenance and fall on the maintenance notice
-rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/? redirect;
+	echo "# All request to the app will be redirected to ${path}_maintenance and fall on the maintenance notice
+rewrite ^${path}/(.*)$ ${path}_maintenance/? redirect;
 # Use another location, to not be in conflict with the original config file
-location ${path_url}_maintenance/ {
+location ${path}_maintenance/ {
 alias /var/www/html/ ;
 
 try_files maintenance.$app.html =503;
@@ -196,7 +55,7 @@ include conf.d/yunohost_panel.conf.inc;
 
 	# The current config file will redirect all requests to the root of the app.
 	# To keep the full path, we can use the following rewrite rule:
-	# 	rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/\$1? redirect;
+	# 	rewrite ^${path}/(.*)$ ${path}_maintenance/\$1? redirect;
 	# The difference will be in the $1 at the end, which keep the following queries.
 	# But, if it works perfectly for a html request, there's an issue with any php files.
 	# This files are treated as simple files, and will be downloaded by the browser.
@@ -206,16 +65,16 @@ include conf.d/yunohost_panel.conf.inc;
 }
 
 ynh_maintenance_mode_OFF () {
-	# Load value of $path_url and $domain from the config if their not set
-	if [ -z $path_url ]; then
-		path_url=$(ynh_app_setting_get $app path)
+	# Load value of $path and $domain from the config if their not set
+	if [ -z $path ]; then
+		path=$(ynh_app_setting_get $app path)
 	fi
 	if [ -z $domain ]; then
 		domain=$(ynh_app_setting_get $app domain)
 	fi
 
-	# Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app.
-	echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
+	# Rewrite the nginx config file to redirect from ${path}_maintenance to the real url of the app.
+	echo "rewrite ^${path}_maintenance/(.*)$ ${path}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf"
 	systemctl reload nginx
 
 	# Sleep 4 seconds to let the browser reload the pages and redirect the user to the app.
@@ -228,143 +87,6 @@ ynh_maintenance_mode_OFF () {
 	systemctl reload nginx
 }
 
-#=================================================
-
-# Create a changelog for an app after an upgrade from the file CHANGELOG.md.
-#
-# usage: ynh_app_changelog [--format=markdown/html/plain] [--output=changelog_file] --changelog=changelog_source]
-# | arg: -f --format= - Format in which the changelog will be printed
-#       markdown: Default format.
-#       html:     Turn urls into html format.
-#       plain:    Plain text changelog
-# | arg: -o --output= - Output file for the changelog file (Default ./changelog)
-# | arg: -c --changelog= - CHANGELOG.md source (Default ../CHANGELOG.md)
-#
-# The changelog is printed into the file ./changelog and ./changelog_lite
-ynh_app_changelog () {
-    # Declare an array to define the options of this helper.
-    local legacy_args=foc
-    declare -Ar args_array=( [f]=format= [o]=output= [c]=changelog= )
-    local format
-    local output
-    local changelog
-    # Manage arguments with getopts
-    ynh_handle_getopts_args "$@"
-    format=${format:-markdown}
-    output=${output:-changelog}
-    changelog=${changelog:-../CHANGELOG.md}
-
-    local original_changelog="$changelog"
-    local temp_changelog="changelog_temp"
-    local final_changelog="$output"
-
-    if [ ! -n "$original_changelog" ]
-    then
-        echo "No changelog available..." > "$final_changelog"
-        echo "No changelog available..." > "${final_changelog}_lite"
-        return 0
-    fi
-
-    local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version")
-    local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version")
-
-    # Get the line of the version to update to into the changelog
-    local update_version_line=$(grep --max-count=1 --line-number "^## \[$update_version" "$original_changelog" | cut -d':' -f1)
-    # If there's no entry for this version yet into the changelog
-    # Get the first available version
-    if [ -z "$update_version_line" ]
-    then
-        update_version_line=$(grep --max-count=1 --line-number "^##" "$original_changelog" | cut -d':' -f1)
-    fi
-
-    # Get the length of the complete changelog.
-    local changelog_length=$(wc --lines "$original_changelog" | awk '{print $1}')
-    # Cut the file before the version to update to.
-    tail --lines=$(( $changelog_length - $update_version_line + 1 )) "$original_changelog" > "$temp_changelog"
-
-    # Get the length of the troncated changelog.
-    changelog_length=$(wc --lines "$temp_changelog" | awk '{print $1}')
-    # Get the line of the current version into the changelog
-    # Keep only the last line found
-    local current_version_line=$(grep --line-number "^## \[$current_version" "$temp_changelog" | cut -d':' -f1 | tail --lines=1)
-    # If there's no entry for this version into the changelog
-    # Get the last available version
-    if [ -z "$current_version_line" ]
-    then
-        current_version_line=$(grep --line-number "^##" "$original_changelog" | cut -d':' -f1 | tail --lines=1)
-    fi
-    # Cut the file before the current version.
-    # Then grep the previous version into the changelog to get the line number of the previous version
-    local previous_version_line=$(tail --lines=$(( $changelog_length - $current_version_line )) \
-        "$temp_changelog" | grep --max-count=1 --line-number "^## " | cut -d':' -f1)
-    # If there's no previous version into the changelog
-    # Go until the end of the changelog
-    if [ -z "$previous_version_line" ]
-    then
-        previous_version_line=$changelog_length
-    fi
-
-    # Cut the file after the previous version to keep only the changelog between the current version and the version to update to.
-    head --lines=$(( $current_version_line + $previous_version_line - 1 )) "$temp_changelog" | tee "$final_changelog"
-
-    if [ "$format" = "html" ]
-    then
-        # Replace markdown links by html links
-        ynh_replace_string --match_string="\[\(.*\)\](\(.*\)))" --replace_string="\1)" --target_file="$final_changelog"
-        ynh_replace_string --match_string="\[\(.*\)\](\(.*\))" --replace_string="\1" --target_file="$final_changelog"
-    elif [ "$format" = "plain" ]
-    then
-        # Change title format.
-        ynh_replace_string --match_string="^##.*\[\(.*\)\](\(.*\)) - \(.*\)$" --replace_string="## \1 (\3) - \2" --target_file="$final_changelog"
-        # Change modifications lines format.
-        ynh_replace_string --match_string="^\([-*]\).*\[\(.*\)\]\(.*\)" --replace_string="\1 \2 \3" --target_file="$final_changelog"
-    fi
-    # else markdown. As the file is already in markdown, nothing to do.
-
-    # Keep only important changes into the changelog
-    # Remove all minor changes
-    sed '/^-/d' "$final_changelog" > "${final_changelog}_lite"
-    # Remove all blank lines (to keep a clear workspace)
-    sed --in-place '/^$/d' "${final_changelog}_lite"
-    # Add a blank line at the end
-    echo "" >> "${final_changelog}_lite"
-
-    # Clean titles if there's no significative changes
-    local line
-    local previous_line=""
-    while read line <&3
-    do
-        if [ -n "$previous_line" ]
-        then
-            # Remove the line if it's a title or a blank line, and the previous one was a title as well.
-            if ( [ "${line:0:1}" = "#" ] || [ ${#line} -eq 0 ] ) && [ "${previous_line:0:1}" = "#" ]
-            then
-                ynh_replace_special_string --match_string="${previous_line//[/.}" --replace_string="" --target_file="${final_changelog}_lite"
-            fi
-        fi
-        previous_line="$line"
-    done 3< "${final_changelog}_lite"
-
-    # Remove all blank lines again
-    sed --in-place '/^$/d' "${final_changelog}_lite"
-
-    # Restore changelog format with blank lines
-    ynh_replace_string --match_string="^##.*" --replace_string="\n\n&\n" --target_file="${final_changelog}_lite"
-    # Remove the 2 first blank lines
-    sed --in-place '1,2d' "${final_changelog}_lite"
-    # Add a blank line at the end
-    echo "" >> "${final_changelog}_lite"
-
-    # If changelog are empty, add an info
-    if [ $(wc --words "$final_changelog" | awk '{print $1}') -eq 0 ]
-    then
-        echo "No changes from the changelog..." > "$final_changelog"
-    fi
-    if [ $(wc --words "${final_changelog}_lite" | awk '{print $1}') -eq 0 ]
-    then
-        echo "No significative changes from the changelog..." > "${final_changelog}_lite"
-    fi
-}
 
 ynh_system_user_add_group() {
     # Declare an array to define the options of this helper.
diff --git a/scripts/actions/create_database b/scripts/actions/create_database
deleted file mode 100755
index f8ddb6f..0000000
--- a/scripts/actions/create_database
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/bin/bash
-
-#=================================================
-# GENERIC STARTING
-#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-
-source scripts/_common.sh
-source /usr/share/yunohost/helpers
-
-#=================================================
-# RETRIEVE ARGUMENTS
-#=================================================
-
-with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql)
-final_path=$(ynh_app_setting_get --app=$app --key=final_path)
-
-app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
-
-#=================================================
-# CHECK IF ARGUMENTS ARE CORRECT
-#=================================================
-
-#=================================================
-# CHECK IF AN ACTION HAS TO BE DONE
-#=================================================
-
-#=================================================
-# SPECIFIC ACTION
-#=================================================
-# REMOVE THE PREVIOUS DATABASE
-#=================================================
-ynh_script_progression --message="Removing the previous database..." --weight=6
-
-if [ $with_mysql -eq 1 ]
-then
-	yunohost app action run $app remove_database
-fi
-
-#=================================================
-# CREATE A NEW DATABASE
-#=================================================
-ynh_script_progression --message="Creating a new database..." --weight=4
-
-db_name=$(ynh_sanitize_dbid --db_name=$app)
-
-# Reuse the previous password if existing
-db_pwd=$(grep "pass:" "$final_path/db_access.txt" | cut -d' ' -f2 2> /dev/null)
-
-ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd
-
-echo -e "# MySQL Database
-    name: ${db_name}\nuser: ${db_name}\npass: ${db_pwd}" > "$final_path/db_access.txt"
-
-# Update the config of the app
-ynh_app_setting_set --app=$app --key=with_mysql --value=1
-ynh_app_setting_set --app=$app --key=db_name --value=$db_name
-
-#=================================================
-# END OF SCRIPT
-#=================================================
-
-ynh_script_progression --message="Execution completed" --last
diff --git a/scripts/actions/remove_database b/scripts/actions/remove_database
deleted file mode 100755
index d7c4477..0000000
--- a/scripts/actions/remove_database
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/bash
-
-#=================================================
-# GENERIC STARTING
-#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-
-source scripts/_common.sh
-source /usr/share/yunohost/helpers
-
-#=================================================
-# RETRIEVE ARGUMENTS
-#=================================================
-
-with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql)
-
-app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
-
-#=================================================
-# CHECK IF ARGUMENTS ARE CORRECT
-#=================================================
-
-#=================================================
-# CHECK IF AN ACTION HAS TO BE DONE
-#=================================================
-
-if [ $with_mysql -eq 0 ]
-then
-	ynh_die --message="There's no database to remove." --ret_code=0
-fi
-
-#=================================================
-# SPECIFIC ACTION
-#=================================================
-# REMOVE THE DATABASE
-#=================================================
-ynh_script_progression --message="Removing the database..." --weight=9
-
-db_name=$(ynh_app_setting_get  --app=$app --key=db_name)
-ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name
-
-# Update the config of the app
-ynh_app_setting_set --app=$app --key=with_mysql --value=0
-
-#=================================================
-# END OF SCRIPT
-#=================================================
-
-ynh_script_progression --message="Execution completed" --last
diff --git a/scripts/actions/sftp b/scripts/actions/sftp
deleted file mode 100755
index 13c8d5b..0000000
--- a/scripts/actions/sftp
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/bin/bash
-
-#=================================================
-# GENERIC STARTING
-#=================================================
-# IMPORT GENERIC HELPERS
-#=================================================
-
-source scripts/_common.sh
-source /usr/share/yunohost/helpers
-
-#=================================================
-# RETRIEVE ARGUMENTS
-#=================================================
-
-app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID}
-
-with_sftp=${YNH_ACTION_WITH_SFTP}
-
-#=================================================
-# CHECK IF ARGUMENTS ARE CORRECT
-#=================================================
-
-#=================================================
-# CHECK IF AN ACTION HAS TO BE DONE
-#=================================================
-
-with_sftp_old=$(ynh_app_setting_get --app=$app --key=with_sftp)
-
-if [ $with_sftp -eq $with_sftp_old ]
-then
-    ynh_die --message="with_sftp is already set as $with_sftp." --ret_code=0
-fi
-
-#=================================================
-# SPECIFIC ACTION
-#=================================================
-# MOVE TO PUBLIC OR PRIVATE
-#=================================================
-
-if [ $with_sftp -eq 1 ]
-then
-    ynh_script_progression --message="Configuring SSH to add a SFTP access..." --weight=3
-
-    ynh_add_config --template="conf/ssh_regenconf_hook" --destination="/usr/share/yunohost/hooks/conf_regen/90-ssh_$app"
-    
-else
-    ynh_script_progression --message="Removing the custom ssh config for the SFTP access..." --weight=3
-
-    # Remove regen-conf hook
-    ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/90-ssh_$app"
-fi
-
-yunohost tools regen-conf ssh
-
-# Update the config of the app
-ynh_app_setting_set --app=$app --key=with_sftp --value=$with_sftp
-
-#=================================================
-# END OF SCRIPT
-#=================================================
-
-ynh_script_progression --message="Execution completed" --last
diff --git a/scripts/backup b/scripts/backup
index 2e90618..17b1472 100644
--- a/scripts/backup
+++ b/scripts/backup
@@ -9,27 +9,6 @@
 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_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)
-with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql)
-with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp)
-phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
-
 #=================================================
 # DECLARE DATA AND CONF FILES TO BACKUP
 #=================================================
@@ -39,13 +18,14 @@ 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
 #=================================================
 
 ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
+ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.d"
 
 #=================================================
 # BACKUP THE PHP-FPM CONFIGURATION
diff --git a/scripts/change_url b/scripts/change_url
index 39f7c11..4433872 100644
--- a/scripts/change_url
+++ b/scripts/change_url
@@ -9,69 +9,29 @@
 source _common.sh
 source /usr/share/yunohost/helpers
 
-#=================================================
-# RETRIEVE ARGUMENTS
-#=================================================
-
-old_domain=$YNH_APP_OLD_DOMAIN
-old_path=$YNH_APP_OLD_PATH
-
-new_domain=$YNH_APP_NEW_DOMAIN
-new_path=$YNH_APP_NEW_PATH
-
-app=$YNH_APP_INSTANCE_NAME
-
-#=================================================
-# LOAD SETTINGS
-#=================================================
-ynh_script_progression --message="Loading installation settings..."
-
-# Needed for helper "ynh_add_nginx_config"
-final_path=$(ynh_app_setting_get --app=$app --key=final_path)
-phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
-
 #=================================================
 # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
 #=================================================
 ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=5
 
 # Backup the current version of the app
-ynh_backup_before_upgrade
 ynh_clean_setup () {
 	# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
 	ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
+	ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.d"
 
 	# restore it if the upgrade fails
 	ynh_restore_upgradebackup
 }
-# Exit if an error occurs during the execution of the script
-ynh_abort_if_errors
 
 #=================================================
 # ACTIVATE MAINTENANCE MODE
 #=================================================
-ynh_script_progression --message="Activating maintenance mode..."
 
 path_url=$old_path
 domain=$old_domain
 ynh_maintenance_mode_ON
 
-#=================================================
-# CHECK WHICH PARTS SHOULD BE CHANGED
-#=================================================
-
-change_domain=0
-if [ "$old_domain" != "$new_domain" ]
-then
-	change_domain=1
-fi
-
-change_path=0
-if [ "$old_path" != "$new_path" ]
-then
-	change_path=1
-fi
-
 #=================================================
 # STANDARD MODIFICATIONS
 #=================================================
@@ -80,14 +40,7 @@ fi
 ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
 
 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
-
-# Prepare nginx.conf
-if [ $phpversion != "none" ]
-then
-    cp ../conf/nginx{_with_php,}.conf
-else
-    cp ../conf/nginx{_no_php,}.conf
-fi
+nginx_extra_conf_dir=/etc/nginx/conf.d/$old_domain.d/$app.d
 
 # Change the path in the NGINX config file
 if [ $change_path -eq 1 ]
@@ -108,25 +61,24 @@ if [ $change_domain -eq 1 ]
 then
 	# Delete file checksum for the old conf file location
 	ynh_delete_file_checksum --file="$nginx_conf_path"
-	mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
+	ynh_delete_file_checksum --file="$nginx_extra_conf_dir/php.conf"
+
+	path_url="$new_path"
+	domain="$old_domain"
+	ynh_remove_nginx_config
+
+	domain="$new_domain"
+	ynh_add_nginx_config
+
+	mv $nginx_extra_conf_dir /etc/nginx/conf.d/$new_domain.d/$app.d
 
 	# Store file checksum for the new config file location
-	ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
+	ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.d/php.conf"
 fi
 
-#=================================================
-# GENERIC FINALISATION
-#=================================================
-# RELOAD NGINX
-#=================================================
-ynh_script_progression --message="Reloading NGINX web server..."
-
-ynh_systemd_action --service_name=nginx --action=reload
-
 #=================================================
 # DEACTIVE MAINTENANCE MODE
 #=================================================
-ynh_script_progression --message="Disabling maintenance mode..."
 
 path_url=$old_path
 domain=$old_domain
diff --git a/scripts/config b/scripts/config
index 9039486..21b6f17 100644
--- a/scripts/config
+++ b/scripts/config
@@ -15,9 +15,9 @@ ynh_abort_if_errors
 # RETRIEVE ARGUMENTS
 #=================================================
 
-final_path=$(ynh_app_setting_get $app final_path)
+install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
 domain=$(ynh_app_setting_get --app=$app --key=domain)
-path_url=$(ynh_app_setting_get --app=$app --key=path)
+path=$(ynh_app_setting_get --app=$app --key=path)
 
 current_fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
 fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
@@ -119,11 +119,14 @@ ynh_app_config_apply() {
         # ^ ynh_add_config replaces __PHPVERSION__ by __PHP_YNH_VERSION__...
         ynh_app_setting_set --app=$app --key=phpversion --value="$phpversion"
 
+        nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d"
+        mkdir -p "$nginx_extra_conf_dir"
         if [ "$phpversion" == "none" ]
         then
-            cp ../conf/nginx{_no_php,}.conf
+            ynh_delete_file_checksum --file="$nginx_extra_conf_dir/php.conf"
+            ynh_secure_remove --file="$nginx_extra_conf_dir/php.conf"
         else
-            cp ../conf/nginx{_with_php,}.conf
+            ynh_add_config --template="nginx-php.conf" --destination="$nginx_extra_conf_dir/php.conf"
             ynh_install_app_dependencies "php${phpversion}-fpm"
             ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion
             # ^ the helper takes care of ynh_app_setting_set the phpversion
diff --git a/scripts/install b/scripts/install
index f2f0ace..a976713 100644
--- a/scripts/install
+++ b/scripts/install
@@ -9,69 +9,27 @@
 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=$YNH_APP_ARG_PATH
-with_sftp=$YNH_APP_ARG_WITH_SFTP
 password=$YNH_APP_ARG_PASSWORD
-is_public=$YNH_APP_ARG_IS_PUBLIC
-phpversion=$YNH_APP_ARG_PHPVERSION
-
-with_mysql=$YNH_APP_ARG_WITH_MYSQL
-
-app=$YNH_APP_INSTANCE_NAME
 app_nb=$YNH_APP_INSTANCE_NUMBER
+ssh_port=$(grep "^Port" /etc/ssh/sshd_config | awk '{print $2}')
 
 #=================================================
 # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
 #=================================================
 ynh_script_progression --message="Validating installation parameters..." --weight=2
 
-final_path=/var/www/$app
-test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
-
 [ $with_sftp -eq 0 ] || [ "$password" != "" ] || ynh_die --message="You need to set a password to enable SFTP"
 
-# Register (book) web path
-ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
-
 #=================================================
 # STORE SETTINGS FROM MANIFEST
 #=================================================
-ynh_script_progression --message="Storing installation settings..."
+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=with_mysql --value=$with_mysql
-ynh_app_setting_set --app=$app --key=with_sftp --value=$with_sftp
-ynh_app_setting_set --app=$app --key=password --value="$password"
-ynh_app_setting_set --app=$app --key=final_path --value=$final_path
-ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion
-
-ynh_app_setting_set --app=$app --key=admin_mail_html --value=1
-
-#=================================================
-# STANDARD MODIFICATIONS
-#=================================================
-# INSTALL DEPENDENCIES
-#=================================================
-
-if [ $phpversion != "none" ]
-then
-    ynh_script_progression --message="Installing dependencies..." --weight=2
-
-    ynh_install_app_dependencies "php${phpversion}-fpm"
-fi
+ynh_app_setting_set --app=$app --key=password --value=$password
 
 #=================================================
 # CREATE A MYSQL DATABASE
@@ -81,11 +39,13 @@ if [ $with_mysql -eq 1 ]
 then
     ynh_script_progression --message="Creating a MySQL database..." --weight=2
 
-    ynh_install_app_dependencies "php${phpversion}-mysql"
-
     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_mysql_setup_db --db_user=$db_name --db_name=$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
+    ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
 fi
 
 #=================================================
@@ -93,17 +53,19 @@ fi
 #=================================================
 ynh_script_progression --message="Configuring NGINX web server..." --weight=2
 
-# Prepare nginx.conf
+nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d"
+mkdir -p "$nginx_extra_conf_dir"
+
+# Prepare nginx extra conf
 if [ $phpversion != "none" ]
 then
-    cp ../conf/nginx{_with_php,}.conf
+    ynh_add_config --template="nginx-php.conf" --destination="$nginx_extra_conf_dir/php.conf"
     YNH_PHP_VERSION="$phpversion"
-else
-    cp ../conf/nginx{_no_php,}.conf
 fi
 
 # Create a dedicated NGINX config
 ynh_add_nginx_config
+ynh_add_config --template="example-custom-nginx-config.conf" --destination="$nginx_extra_conf_dir/sample.conf"
 
 #=================================================
 # CREATE DEDICATED USER
@@ -117,7 +79,7 @@ else
     groups=""
 fi
 
-ynh_system_user_create --username=$app --home_dir="$final_path" --groups="$groups"
+    ynh_system_user_create --username=$app --home_dir="$install_dir" --groups="$groups"
 
 if [ $with_sftp -eq 1 ]
 then
@@ -131,120 +93,43 @@ fi
 # MODIFY A CONFIG FILE
 #=================================================
 
-mkdir -p "$final_path/www"
+mkdir -p "$install_dir/www"
 
 if [ $with_sftp -eq 1 ]
 then
-
-    ynh_add_config --template="../sources/www/index.html" --destination="$final_path/www/index.html"
-
+    ynh_add_config --template="../sources/www/index.html" --destination="$install_dir/www/index.html"
 else
-    # Copy files to the right place
-    cp "../sources/www/index_no_sftp.html" "$final_path/www/index.html"
+    ynh_add_config --template="../sources/www/index_no_sftp.html" --destination="$install_dir/www/index.html"
 fi
 
-if [ $with_mysql -eq 1 ]; then
-    # Store the database access
-    echo -e "# MySQL Database
-name: ${db_name}\nuser: ${db_name}\npass: ${db_pwd}" > ../sources/db_access.txt
-
-    # Copy files to the right place
-    cp -r "../sources/db_access.txt" "$final_path/db_access.txt"
-fi
-
-chown -R $app:www-data "$final_path"
+chown -R $app:www-data "$install_dir"
 # Home directory of the user needs to be owned by root to allow
 # SFTP connections
-chown root:root "$final_path"
-setfacl -m g:$app:r-x "$final_path"
-setfacl -m g:www-data:r-x "$final_path"
-chmod 750 "$final_path"
+chown root:root "$install_dir"
+setfacl -m g:$app:r-x "$install_dir"
+setfacl -m g:www-data:r-x "$install_dir"
+chmod 750 "$install_dir"
 
 #=================================================
 # PHP-FPM CONFIGURATION
 #=================================================
 
+fpm_footprint="low"
+fpm_free_footprint=0
+fpm_usage="low"
+
+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
+
 if [ $phpversion != "none" ]
 then
     ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
-    
-    fpm_footprint="low"
-    fpm_free_footprint=0
-    fpm_usage="low"
-
-    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
 
     # Create a dedicatedPHP-FPM config
     ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion
-else
-    # This is needed for the config panel to work even though PHP is not actually used
-    ynh_app_setting_set --app=$app --key=fpm_footprint --value=low
-    ynh_app_setting_set --app=$app --key=fpm_usage --value=low
-    ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=0
 fi
 
-#=================================================
-# GENERIC FINALIZATION
-#=================================================
-# SETUP SSOWAT
-#=================================================
-ynh_script_progression --message="Configuring permissions..."
-
-# Make app public if necessary
-if [ $is_public -eq 1 ]
-then
-    ynh_permission_update --permission="main" --add="visitors"
-fi
-
-#=================================================
-# RELOAD NGINX
-#=================================================
-ynh_script_progression --message="Reloading NGINX web server..."
-
-ynh_systemd_action --service_name=nginx --action=reload
-
-#=================================================
-# SEND A README FOR THE ADMIN
-#=================================================
-
-# Get main domain and buid the url of the admin panel of the app.
-admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
-
-if [ $with_mysql -eq 1 ]
-then
-    sql_infos="
-You've asked for a database, please find here the information about this SQL database.
-$(cat "$final_path/db_access.txt")
-"
-else
-    sql_infos=""
-fi
-
-if [ $with_sftp -eq 1 ]
-then
-    sftp_infos="You can connect to this repository by using SFTP with the following credentials.
-Domain: $domain
-Port: $(grep "^Port" /etc/ssh/sshd_config | awk '{print $2}')
-User: $app
-Password: The one you set at installation."
-else
-    sftp_infos=""
-fi
-
-echo "This app is simply a blank web app container. You have to put your own app inside.
-$sql_infos
-Please put your files into this directory: $final_path/www/
-$sftp_infos
-
-You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
-You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.
-
-If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/my_webapp_ynh__URL_TAG3__." > mail_to_send
-
-ynh_send_readme_to_admin --app_message="mail_to_send" --recipients=root --type=install
-
 #=================================================
 # END OF SCRIPT
 #=================================================
diff --git a/scripts/remove b/scripts/remove
index e9952b0..f86af18 100644
--- a/scripts/remove
+++ b/scripts/remove
@@ -9,21 +9,6 @@
 source _common.sh
 source /usr/share/yunohost/helpers
 
-#=================================================
-# LOAD SETTINGS
-#=================================================
-ynh_script_progression --message="Loading installation settings..." --weight=2
-
-app=$YNH_APP_INSTANCE_NAME
-
-domain=$(ynh_app_setting_get --app=$app --key=domain)
-with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql)
-with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp)
-
-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)
-
 #=================================================
 # STANDARD REMOVE
 #=================================================
@@ -33,18 +18,13 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
 if [ $with_mysql -eq 1 ]; then
     ynh_script_progression --message="Removing the MySQL database..." --weight=2
 
+    db_name=$(ynh_app_setting_get --app=$app --key=db_name)
+    db_user=$db_name
+
     # Remove a database if it exists, along with the associated user
     ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
 fi
 
-#=================================================
-# 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
 #=================================================
@@ -52,6 +32,7 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
 
 # Remove the dedicated NGINX config
 ynh_remove_nginx_config
+ynh_secure_remove --file="/etc/nginx/conf.d/$domain.d/$app.d"
 
 #=================================================
 # REMOVE PHP-FPM CONFIGURATION
@@ -61,20 +42,6 @@ ynh_script_progression --message="Removing PHP-FPM configuration..."
 # Remove the dedicated PHP-FPM config
 ynh_remove_fpm_config
 
-#=================================================
-# SPECIFIC REMOVE
-#=================================================
-
-#=================================================
-# 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
 #=================================================
diff --git a/scripts/restore b/scripts/restore
index dec9279..8db3265 100644
--- a/scripts/restore
+++ b/scripts/restore
@@ -9,55 +9,12 @@
 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..." --weight=2
-
-app=$YNH_APP_INSTANCE_NAME
-
-domain=$(ynh_app_setting_get --app=$app --key=domain)
-path_url=$(ynh_app_setting_get --app=$app --key=path)
-final_path=$(ynh_app_setting_get --app=$app --key=final_path)
-db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql)
-with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp)
-password=$(ynh_app_setting_get --app=$app --key=password)
-phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
-
-#=================================================
-# CHECK IF THE APP CAN BE RESTORED
-#=================================================
-ynh_script_progression --message="Validating restoration parameters..." --weight=2
-
-test ! -d $final_path \
-	|| ynh_die --message="There is already a directory: $final_path "
-
-#=================================================
-# STANDARD RESTORATION STEPS
-#=================================================
-# REINSTALL DEPENDENCIES
-#=================================================
-
-if [ $phpversion != "none" ]
-then
-	ynh_script_progression --message="Reinstalling dependencies..." --weight=2
-
-	ynh_install_app_dependencies "php${phpversion}-fpm"
-fi
-
 #=================================================
 # RESTORE THE NGINX CONFIGURATION
 #=================================================
 
 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
+ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.d/"
 
 #=================================================
 # RESTORE THE MYSQL DATABASE
@@ -66,11 +23,11 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
 if [ $with_mysql -eq 1 ]; then
     ynh_script_progression --message="Restoring the MySQL database..."
 
-    ynh_install_app_dependencies "php${phpversion}-mysql"
-
-    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
+    db_name=$(ynh_app_setting_get --app=$app --key=db_name)
+    db_user=$db_name
+    db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
+    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
 fi
 
 #=================================================
@@ -85,7 +42,7 @@ else
     groups=""
 fi
 
-ynh_system_user_create --username=$app --home_dir="$final_path" --groups="$groups"
+ynh_system_user_create --username=$app --home_dir="$install_dir" --groups="$groups"
 
 if [ -n "$password" ]
 then
@@ -98,16 +55,16 @@ fi
 #=================================================
 ynh_script_progression --message="Restoring the app main directory..."
 
-ynh_restore_file --origin_path="$final_path"
+ynh_restore_file --origin_path="$install_dir"
 
 # Restore permissions on app files
-chown -R $app:www-data "$final_path"
+chown -R $app:www-data "$install_dir"
 # Home directory of the user needs to be owned by root to allow
 # SFTP connections
-chown root:root "$final_path"
-setfacl -m g:$app:r-x "$final_path"
-setfacl -m g:www-data:r-x "$final_path"
-chmod 750 "$final_path"
+chown root:root "$install_dir"
+setfacl -m g:$app:r-x "$install_dir"
+setfacl -m g:www-data:r-x "$install_dir"
+chmod 750 "$install_dir"
 
 #=================================================
 # RESTORE THE PHP-FPM CONFIGURATION
@@ -118,10 +75,6 @@ then
 	ynh_restore_file --origin_path="/etc/php/${phpversion}/fpm/pool.d/$app.conf"
 fi
 
-#=================================================
-# SPECIFIC RESTORATION
-#=================================================
-
 #=================================================
 # GENERIC FINALIZATION
 #=================================================
@@ -136,20 +89,6 @@ fi
 
 ynh_systemd_action --service_name=nginx --action=reload
 
-#=================================================
-# SEND A README FOR THE ADMIN
-#=================================================
-
-# Get main domain and buid the url of the admin panel of the app.
-admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
-
-echo "You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
-You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.
-
-If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/my_webapp_ynh__URL_TAG3__." > mail_to_send
-
-ynh_send_readme_to_admin --app_message="mail_to_send" --recipients=root --type=restore
-
 #=================================================
 # END OF SCRIPT
 #=================================================
diff --git a/scripts/upgrade b/scripts/upgrade
index f65ad0e..19a6549 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -9,91 +9,43 @@
 source _common.sh
 source /usr/share/yunohost/helpers
 
-#=================================================
-# LOAD SETTINGS
-#=================================================
-ynh_script_progression --message="Loading installation settings..." --weight=2
-
-app=$YNH_APP_INSTANCE_NAME
-
-domain=$(ynh_app_setting_get --app=$app --key=domain)
-path_url=$(ynh_app_setting_get --app=$app --key=path)
-final_path=$(ynh_app_setting_get --app=$app --key=final_path)
-db_name=$(ynh_app_setting_get --app=$app --key=db_name)
-with_mysql=$(ynh_app_setting_get --app=$app --key=with_mysql)
-with_sftp=$(ynh_app_setting_get --app=$app --key=with_sftp)
-password=$(ynh_app_setting_get --app=$app --key=password)
-phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
-
-admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html)
-
-fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
-fpm_free_footprint=$(ynh_app_setting_get --app=$app --key=fpm_free_footprint)
-fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
-
 #=================================================
 # CHECK VERSION
 #=================================================
 
 upgrade_type=$(ynh_check_app_version_changed)
 
-#=================================================
-# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
-#=================================================
-ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3
-
-# 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
-
 #=================================================
 # ENSURE DOWNWARD COMPATIBILITY
 #=================================================
 ynh_script_progression --message="Ensuring downward compatibility..."
 
-# If db_name doesn't exist, create it
-if [ -z "$db_name" ]; then
-	db_name=$(ynh_sanitize_dbid --db_name=$app)
-	ynh_app_setting_set --app=$app --key=db_name --value=$db_name
-fi
-
-# If 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
-fi
-
 # If admin_mail_html doesn't exist, create it
-if [ -z "$admin_mail_html" ]; then
+if [ -z "${admin_mail_html:-}" ]; then
 	admin_mail_html=1
-	ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html
+		ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html
 fi
 
 # If fpm_footprint doesn't exist, create it
-if [ -z "$fpm_footprint" ]; then
+if [ -z "${fpm_footprint:-}" ]; then
 	fpm_footprint=low
 	ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
 fi
 
 # If fpm_free_footprint doesn't exist, create it
-if [ -z "$fpm_free_footprint" ]; then
+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 fpm_usage doesn't exist, create it
-if [ -z "$fpm_usage" ]; then
+if [ -z "${fpm_usage:-}" ]; then
 	fpm_usage=low
 	ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
 fi
 
 # If with_sftp doesn't exist, create it
-if [ -z "$with_sftp" ]; then
+if [ -z "${with_sftp:-}" ]; then
 	with_sftp=1
 	ynh_app_setting_set --app=$app --key=with_sftp --value=$with_sftp
 fi
@@ -112,58 +64,35 @@ then
     ynh_app_setting_delete --app=$app --key=user
 fi
 
-# Cleaning legacy permissions
-if ynh_legacy_permissions_exists; then
-	ynh_legacy_permissions_delete_all
-
-	ynh_app_setting_delete --app=$app --key=is_public
-fi
-
 # Ensure password is a setting even if empty, for the config panel
 ynh_app_setting_set --app=$app --key=password --value="$password"
 
 #=================================================
 # ACTIVATE MAINTENANCE MODE
 #=================================================
-ynh_script_progression --message="Activating maintenance mode..."
 
 ynh_maintenance_mode_ON
 
-#=================================================
-# STANDARD UPGRADE STEPS
-#=================================================
-# INSTALL DEPENDENCIES
-#=================================================
-
-if [ $phpversion != "none" ]
-then
-    ynh_script_progression --message="Installing dependencies..." --weight=2
-
-    ynh_install_app_dependencies "php${phpversion}-fpm"
-fi
-
-if [ $with_mysql -eq 1 ]
-then
-    ynh_install_app_dependencies "php${phpversion}-mysql"
-fi
-
 #=================================================
 # NGINX CONFIGURATION
 #=================================================
-
 ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
 
 # Prepare nginx.conf
+nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d"
+
+mkdir -p "$nginx_extra_conf_dir"
+
+# Prepare nginx extra conf
 if [ $phpversion != "none" ]
 then
-    cp ../conf/nginx{_with_php,}.conf
+    ynh_add_config --template="nginx-php.conf" --destination="$nginx_extra_conf_dir/php.conf"
     YNH_PHP_VERSION="$phpversion"
-else
-    cp ../conf/nginx{_no_php,}.conf
 fi
 
 # Create a dedicated NGINX config
 ynh_add_nginx_config
+ynh_add_config --template="example-custom-nginx-config.conf" --destination="$nginx_extra_conf_dir/sample.conf"
 
 #=================================================
 # CREATE DEDICATED USER
@@ -177,7 +106,7 @@ else
     groups=""
 fi
 
-ynh_system_user_create --username=$app --home_dir="$final_path" --groups="$groups"
+ynh_system_user_create --username=$app --home_dir="$install_dir" --groups="$groups"
 
 if [ -n "$password" ]
 then
@@ -201,69 +130,26 @@ then
     ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion
 fi
 
-#=================================================
-# SPECIFIC UPGRADE
-#=================================================
-
 #=================================================
 # GENERIC FINALIZATION
 #=================================================
 # SECURE FILES AND DIRECTORIES
 #=================================================
 
-chown -R $app:www-data "$final_path"
+chown -R $app:www-data "$install_dir"
 # Home directory of the user needs to be owned by root to allow
 # SFTP connections
-chown root:root "$final_path"
-setfacl -m g:$app:r-x "$final_path"
-setfacl -m g:www-data:r-x "$final_path"
-chmod 750 "$final_path"
-
-#=================================================
-# RELOAD NGINX
-#=================================================
-ynh_script_progression --message="Reloading NGINX web server..."
-
-ynh_systemd_action --service_name=nginx --action=reload
+chown root:root "$install_dir"
+setfacl -m g:$app:r-x "$install_dir"
+setfacl -m g:www-data:r-x "$install_dir"
+chmod 750 "$install_dir"
 
 #=================================================
 # DEACTIVE MAINTENANCE MODE
 #=================================================
-ynh_script_progression --message="Disabling maintenance mode..."
 
 ynh_maintenance_mode_OFF
 
-#=================================================
-# SEND A README FOR THE ADMIN
-#=================================================
-
-# Get main domain and buid the url of the admin panel of the app.
-admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app"
-
-# Build the changelog
-# Get the value of admin_mail_html
-admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
-admin_mail_html="${admin_mail_html:-0}"
-# If a html email is required. Apply html to the changelog.
-if [ "$admin_mail_html" -eq 1 ]; then
-    format=html
-else
-    format=plain
-fi
-ynh_app_changelog --format=$format
-
-echo "You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__.
-You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__.
-
-If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/my_webapp_ynh__URL_TAG3__.
-
----
-
-Changelog since your last upgrade:
-$(cat changelog)" > mail_to_send
-
-ynh_send_readme_to_admin --app_message="mail_to_send" --recipients=root --type=upgrade
-
 #=================================================
 # END OF SCRIPT
 #=================================================
diff --git a/sources/www/index.html b/sources/www/index.html
index 1942aed..24608b1 100644
--- a/sources/www/index.html
+++ b/sources/www/index.html
@@ -1,11 +1,11 @@
 
 
   
-    Custom Web App
+    My Webapp
   
   
     

It works!

-

Congratulation, you have just installed your custom web app.

+

Congratulation, you have just installed My Webapp.

Edit this site

@@ -20,9 +20,9 @@

Domain
__DOMAIN__
Port
-
22 (or the port you defined if you changed the SSH port)
+
__SSH_PORT__
User
-
__APP__
+
__ID__
Password
the one you set at installation
diff --git a/sources/www/index_no_sftp.html b/sources/www/index_no_sftp.html index 7dab7ea..a6a61d1 100644 --- a/sources/www/index_no_sftp.html +++ b/sources/www/index_no_sftp.html @@ -1,11 +1,11 @@ - Custom Web App + My Webapp

It works!

-

Congratulation, you have just installed your custom web app.

+

Congratulation, you have just installed My Webapp.

Edit this site

diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..ce3886c --- /dev/null +++ b/tests.toml @@ -0,0 +1,21 @@ +test_format = 1.0 + +[default] + + # ------------------------------- + # Default args to use for install + # ------------------------------- + + args.with_sftp = "1" + args.with_mysql = "1" + args.phpversion = "8.0" + +[80_test] + + only = ["install.subdir", "backup_restore", "upgrade" ] + args.phpversion = "8.0" + +[none_test] + + only = ["install.subdir", "backup_restore", "upgrade" ] + args.phpversion = "none"