diff --git a/ALL_README.md b/ALL_README.md index 152f2e7..4ed64dd 100644 --- a/ALL_README.md +++ b/ALL_README.md @@ -5,4 +5,5 @@ - [Irakurri README euskaraz](README_eu.md) - [Lire le README en français](README_fr.md) - [Le o README en galego](README_gl.md) +- [Baca README dalam bahasa bahasa Indonesia](README_id.md) - [阅读中文(简体)的 README](README_zh_Hans.md) diff --git a/README.md b/README.md index 4c3f60d..c3ff178 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ It shall NOT be edited by hand. # My Webapp for YunoHost -[![Integration level](https://dash.yunohost.org/integration/my_webapp.svg)](https://dash.yunohost.org/appci/app/my_webapp) ![Working status](https://ci-apps.yunohost.org/ci/badges/my_webapp.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/my_webapp.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/my_webapp.svg)](https://ci-apps.yunohost.org/ci/apps/my_webapp/) ![Working status](https://ci-apps.yunohost.org/ci/badges/my_webapp.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/my_webapp.maintain.svg) [![Install My Webapp with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=my_webapp) @@ -18,14 +18,16 @@ It shall NOT be edited by hand. This application allows you to easily install a custom Web application, providing files access with [SFTP](https://yunohost.org/en/filezilla). -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. +It can also create a MySQL or PostgreSQL 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 `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. +You can also customize 404 errors - if you enable the option in the config panel. Simply create an `error` folder in the `www` root directory, containing your custom `html` files. -**Shipped version:** 1.0~ynh15 + +**Shipped version:** 1.0~ynh17 ## Documentation and resources - Upstream app code repository: diff --git a/README_es.md b/README_es.md index 0ec9f3e..1c54236 100644 --- a/README_es.md +++ b/README_es.md @@ -5,7 +5,7 @@ No se debe editar a mano. # My Webapp para Yunohost -[![Nivel de integración](https://dash.yunohost.org/integration/my_webapp.svg)](https://dash.yunohost.org/appci/app/my_webapp) ![Estado funcional](https://ci-apps.yunohost.org/ci/badges/my_webapp.status.svg) ![Estado En Mantención](https://ci-apps.yunohost.org/ci/badges/my_webapp.maintain.svg) +[![Nivel de integración](https://dash.yunohost.org/integration/my_webapp.svg)](https://ci-apps.yunohost.org/ci/apps/my_webapp/) ![Estado funcional](https://ci-apps.yunohost.org/ci/badges/my_webapp.status.svg) ![Estado En Mantención](https://ci-apps.yunohost.org/ci/badges/my_webapp.maintain.svg) [![Instalar My Webapp con Yunhost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=my_webapp) @@ -18,14 +18,16 @@ No se debe editar a mano. This application allows you to easily install a custom Web application, providing files access with [SFTP](https://yunohost.org/en/filezilla). -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. +It can also create a MySQL or PostgreSQL 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 `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. +You can also customize 404 errors - if you enable the option in the config panel. Simply create an `error` folder in the `www` root directory, containing your custom `html` files. -**Versión actual:** 1.0~ynh15 + +**Versión actual:** 1.0~ynh17 ## Documentaciones y recursos - Repositorio del código fuente oficial de la aplicación : diff --git a/README_eu.md b/README_eu.md index daf5165..48ee029 100644 --- a/README_eu.md +++ b/README_eu.md @@ -5,7 +5,7 @@ EZ editatu eskuz. # My Webapp YunoHost-erako -[![Integrazio maila](https://dash.yunohost.org/integration/my_webapp.svg)](https://dash.yunohost.org/appci/app/my_webapp) ![Funtzionamendu egoera](https://ci-apps.yunohost.org/ci/badges/my_webapp.status.svg) ![Mantentze egoera](https://ci-apps.yunohost.org/ci/badges/my_webapp.maintain.svg) +[![Integrazio maila](https://dash.yunohost.org/integration/my_webapp.svg)](https://ci-apps.yunohost.org/ci/apps/my_webapp/) ![Funtzionamendu egoera](https://ci-apps.yunohost.org/ci/badges/my_webapp.status.svg) ![Mantentze egoera](https://ci-apps.yunohost.org/ci/badges/my_webapp.maintain.svg) [![Instalatu My Webapp YunoHost-ekin](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=my_webapp) @@ -18,14 +18,16 @@ EZ editatu eskuz. This application allows you to easily install a custom Web application, providing files access with [SFTP](https://yunohost.org/en/filezilla). -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. +It can also create a MySQL or PostgreSQL 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 `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. +You can also customize 404 errors - if you enable the option in the config panel. Simply create an `error` folder in the `www` root directory, containing your custom `html` files. -**Paketatutako bertsioa:** 1.0~ynh15 + +**Paketatutako bertsioa:** 1.0~ynh17 ## Dokumentazioa eta baliabideak - Jatorrizko aplikazioaren kode-gordailua: diff --git a/README_fr.md b/README_fr.md index e655124..548272f 100644 --- a/README_fr.md +++ b/README_fr.md @@ -5,7 +5,7 @@ Il NE doit PAS être modifié à la main. # My Webapp pour YunoHost -[![Niveau d’intégration](https://dash.yunohost.org/integration/my_webapp.svg)](https://dash.yunohost.org/appci/app/my_webapp) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/my_webapp.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/my_webapp.maintain.svg) +[![Niveau d’intégration](https://dash.yunohost.org/integration/my_webapp.svg)](https://ci-apps.yunohost.org/ci/apps/my_webapp/) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/my_webapp.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/my_webapp.maintain.svg) [![Installer My Webapp avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=my_webapp) @@ -18,14 +18,15 @@ Il NE doit PAS être modifié à la main. Cette application vous permet d'installer facilement une application vide personnalisée, fourni un accès aux fichiers avec [SFTP](https://yunohost.org/fr/filezilla). -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. +Elle peut également créer une base de données MySQL ou PostgreSQL - 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 `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. +L'application vous permet aussi de gérer - si vous activez l'option dans le panneau de configuration - la gestion des erreurs 404, il vous suffit de créer un dossier `error` dans le répertoire racine `www` et d'y placer vos fichiers d'erreur `html` -**Version incluse :** 1.0~ynh15 +**Version incluse :** 1.0~ynh17 ## Documentations et ressources - Dépôt de code officiel de l’app : diff --git a/README_gl.md b/README_gl.md index 89883f5..82af726 100644 --- a/README_gl.md +++ b/README_gl.md @@ -5,7 +5,7 @@ NON debe editarse manualmente. # My Webapp para YunoHost -[![Nivel de integración](https://dash.yunohost.org/integration/my_webapp.svg)](https://dash.yunohost.org/appci/app/my_webapp) ![Estado de funcionamento](https://ci-apps.yunohost.org/ci/badges/my_webapp.status.svg) ![Estado de mantemento](https://ci-apps.yunohost.org/ci/badges/my_webapp.maintain.svg) +[![Nivel de integración](https://dash.yunohost.org/integration/my_webapp.svg)](https://ci-apps.yunohost.org/ci/apps/my_webapp/) ![Estado de funcionamento](https://ci-apps.yunohost.org/ci/badges/my_webapp.status.svg) ![Estado de mantemento](https://ci-apps.yunohost.org/ci/badges/my_webapp.maintain.svg) [![Instalar My Webapp con YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=my_webapp) @@ -18,14 +18,16 @@ NON debe editarse manualmente. This application allows you to easily install a custom Web application, providing files access with [SFTP](https://yunohost.org/en/filezilla). -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. +It can also create a MySQL or PostgreSQL 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 `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. +You can also customize 404 errors - if you enable the option in the config panel. Simply create an `error` folder in the `www` root directory, containing your custom `html` files. -**Versión proporcionada:** 1.0~ynh15 + +**Versión proporcionada:** 1.0~ynh17 ## Documentación e recursos - Repositorio de orixe do código: diff --git a/README_id.md b/README_id.md new file mode 100644 index 0000000..c65247b --- /dev/null +++ b/README_id.md @@ -0,0 +1,49 @@ + + +# My Webapp untuk YunoHost + +[![Tingkat integrasi](https://dash.yunohost.org/integration/my_webapp.svg)](https://ci-apps.yunohost.org/ci/apps/my_webapp/) ![Status kerja](https://ci-apps.yunohost.org/ci/badges/my_webapp.status.svg) ![Status pemeliharaan](https://ci-apps.yunohost.org/ci/badges/my_webapp.maintain.svg) + +[![Pasang My Webapp dengan YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=my_webapp) + +*[Baca README ini dengan bahasa yang lain.](./ALL_README.md)* + +> *Paket ini memperbolehkan Anda untuk memasang My Webapp secara cepat dan mudah pada server YunoHost.* +> *Bila Anda tidak mempunyai YunoHost, silakan berkonsultasi dengan [panduan](https://yunohost.org/install) untuk mempelajari bagaimana untuk memasangnya.* + +## Ringkasan + +This application allows you to easily install a custom Web application, providing files access with [SFTP](https://yunohost.org/en/filezilla). + +It can also create a MySQL or PostgreSQL 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 `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. + +You can also customize 404 errors - if you enable the option in the config panel. Simply create an `error` folder in the `www` root directory, containing your custom `html` files. + + +**Versi terkirim:** 1.0~ynh17 +## Dokumentasi dan sumber daya + +- Repositori kode aplikasi hulu: +- Gudang YunoHost: +- Laporkan bug: + +## Info developer + +Silakan kirim pull request ke [`testing` branch](https://github.com/YunoHost-Apps/my_webapp_ynh/tree/testing). + +Untuk mencoba branch `testing`, silakan dilanjutkan seperti: + +```bash +sudo yunohost app install https://github.com/YunoHost-Apps/my_webapp_ynh/tree/testing --debug +atau +sudo yunohost app upgrade my_webapp -u https://github.com/YunoHost-Apps/my_webapp_ynh/tree/testing --debug +``` + +**Info lebih lanjut mengenai pemaketan aplikasi:** diff --git a/README_zh_Hans.md b/README_zh_Hans.md index 29c3154..15676af 100644 --- a/README_zh_Hans.md +++ b/README_zh_Hans.md @@ -5,7 +5,7 @@ # YunoHost 上的 My Webapp -[![集成程度](https://dash.yunohost.org/integration/my_webapp.svg)](https://dash.yunohost.org/appci/app/my_webapp) ![工作状态](https://ci-apps.yunohost.org/ci/badges/my_webapp.status.svg) ![维护状态](https://ci-apps.yunohost.org/ci/badges/my_webapp.maintain.svg) +[![集成程度](https://dash.yunohost.org/integration/my_webapp.svg)](https://ci-apps.yunohost.org/ci/apps/my_webapp/) ![工作状态](https://ci-apps.yunohost.org/ci/badges/my_webapp.status.svg) ![维护状态](https://ci-apps.yunohost.org/ci/badges/my_webapp.maintain.svg) [![使用 YunoHost 安装 My Webapp](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=my_webapp) @@ -18,14 +18,16 @@ This application allows you to easily install a custom Web application, providing files access with [SFTP](https://yunohost.org/en/filezilla). -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. +It can also create a MySQL or PostgreSQL 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 `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. +You can also customize 404 errors - if you enable the option in the config panel. Simply create an `error` folder in the `www` root directory, containing your custom `html` files. -**分发版本:** 1.0~ynh15 + +**分发版本:** 1.0~ynh17 ## 文档与资源 - 上游应用代码库: diff --git a/conf/nginx-code-error.conf b/conf/nginx-code-error.conf new file mode 100644 index 0000000..5ded6cc --- /dev/null +++ b/conf/nginx-code-error.conf @@ -0,0 +1,7 @@ +# Build error access +error_page 403 __PATH__/error/403.html; +error_page 404 __PATH__/error/404.html; + +location ^~ __PATH__/error/ { + internal; +} diff --git a/conf/nginx.conf b/conf/nginx.conf index 9f696ae..2b2c03f 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -5,8 +5,8 @@ location __PATH__/ { alias __INSTALL_DIR__/www/; # Default indexes and catch-all - index index.html index.php; - try_files $uri $uri/ __PATH__/index.php?$args; + index index.php index.html; + try_files $uri $uri/ __PATH__/index.php?$args =404; # Prevent useless logs location = __PATH__/favicon.ico { diff --git a/config_panel.toml b/config_panel.toml index b229f0f..d86d79c 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -4,19 +4,32 @@ version = "1.0" name = "My Webapp configuration" [main.sftp] - name = "SFTP access" + name.en = "SFTP access" + name.fr = "Accès SFTP" [main.sftp.with_sftp] - ask = "Do you need a SFTP access?" + ask.en = "Do you need a SFTP access?" + ask.fr = "Avez-vous besoin d'un accès SFTP ?" type = "boolean" default = true [main.sftp.password] - ask = "Set a password for the SFTP access" + ask.en = "Set a password for the SFTP access" + ask.fr = "Définir un mot de passe pour l’accès SFTP" type = "password" optional = true visible = "with_sftp" - help = "If a password already exist, leave blank and it will not be replaced." + help.en = "If a password already exist, leave blank and it will not be replaced." + help.fr = "Si un mot de passe existe déjà, laissez vide et il ne sera pas remplacé." + + [main.code_error] + name = "Html Custom error" + + [main.code_error.custom_error_file] + ask = "Activate the custom error file use" + type = "boolean" + default = false + help = "Once custom error enabled, you can add/create a custom `404.html` file in a directory `www\\error`." [main.php_fpm_config] name = "PHP-FPM configuration" @@ -24,7 +37,7 @@ name = "My Webapp configuration" [main.php_fpm_config.phpversion] ask = "PHP version" type = "select" - choices = ["none", "7.4", "8.0", "8.1", "8.2"] + choices = ["none", "7.4", "8.0", "8.1", "8.2", "8.3"] default = "none" [main.php_fpm_config.fpm_footprint] diff --git a/doc/ADMIN.md b/doc/ADMIN.md index 454a9bb..586e310 100644 --- a/doc/ADMIN.md +++ b/doc/ADMIN.md @@ -26,6 +26,10 @@ The `php` command will point to the PHP version installed for the app. Once logged in, 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. +### 403 and 404 error handling + +The web server configuration supports http error handling `403` and `404` (access denied and resource not found). Create an `error` folder at `__INSTALL_DIR__/www/error`, and put your `403.html` and `404.html` files in there. + ### Customizing the nginx configuration If you want to add tweak the nginx configuration for this app, it is recommended to edit `/etc/nginx/conf.d/__DOMAIN__.d/__ID__.d/WHATEVER_NAME.conf` (ensure that the file has the `.conf` extension) and reload the nginx after making sure that the configuration is valid using `nginx -t`. diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md index 3f3b568..a9c0371 100644 --- a/doc/ADMIN_fr.md +++ b/doc/ADMIN_fr.md @@ -26,6 +26,10 @@ La commande `php` pointera vers la version de PHP installée pour l'app. Après vous être connecté, 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. +### Gestion des erreurs 403 et 404 + +La configuration du serveur web prend en charge la gestion des erreurs http `403` et `404` (accès refusé et ressource non trouvée). Ajoutez un dossier `error` à l'emplacement `__INSTALL_DIR__/www/error`, puis ajoutez-y vos fichiers `403.html` et `404.html`. + ### Personnaliser la configuration nginx Si vous souhaitez ajuster la configuration nginx pour cette app, il est recommandé d'éditer `/etc/nginx/conf.d/__DOMAIN__.d/__ID__.d/WHATEVER_NAME.conf` (assurez-vous que le fichier a l'extension `.conf`) puis rechargez nginx après vous être assuré que la configuration est valide à l'aide de `nginx -t`. diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index de48a9d..8ff7d95 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -1,7 +1,9 @@ This application allows you to easily install a custom Web application, providing files access with [SFTP](https://yunohost.org/en/filezilla). -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. +It can also create a MySQL or PostgreSQL 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 `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. + +You can also customize 404 errors - if you enable the option in the config panel. Simply create an `error` folder in the `www` root directory, containing your custom `html` files. diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md index 2bf7f20..b277384 100644 --- a/doc/DESCRIPTION_fr.md +++ b/doc/DESCRIPTION_fr.md @@ -1,7 +1,9 @@ Cette application vous permet d'installer facilement une application vide personnalisée, fourni un accès aux fichiers avec [SFTP](https://yunohost.org/fr/filezilla). -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. +Elle peut également créer une base de données MySQL ou PostgreSQL - 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 `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. + +L'application vous permet aussi de gérer - si vous activez l'option dans le panneau de configuration - la gestion des erreurs 404, il vous suffit de créer un dossier `error` dans le répertoire racine `www` et d'y placer vos fichiers d'erreur `html` \ No newline at end of file diff --git a/manifest.toml b/manifest.toml index 2be35b6..ee49d7d 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ 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~ynh15" +version = "1.0~ynh17" maintainers = [] @@ -49,8 +49,8 @@ ram.runtime = "50M" 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 = "select" - choices = ["none", "7.4", "8.0", "8.1", "8.2"] - default = "8.0" + choices = ["none", "7.4", "8.0", "8.1", "8.2", "8.3"] + default = "8.3" [install.database] ask.en = "Do you need a database?" @@ -59,6 +59,12 @@ ram.runtime = "50M" choices = [ "none", "mysql", "postgresql" ] default = "none" + [install.custom_error_file] + ask = "Activate the custom error file use" + type = "boolean" + default = false + help = "Once custom error enabled, you can add/create a custom `404.html` file in a directory `www/error`." + [resources] [resources.system_user] @@ -70,15 +76,15 @@ ram.runtime = "50M" [resources.apt] packages = "nginx" # Kind of "dummy" value to be sure to have a non-empty dep list packages_from_raw_bash = """ - if [[ "$database" == "mysql" ]]; then + if [[ "$database" == "mysql" ]]; then echo "mariadb-server" - + if [[ "$phpversion" != none ]]; then echo "php${phpversion}-mysql" fi elif [[ "$database" == "postgresql" ]]; then echo "postgresql postgresql-contrib" - + if [[ "$phpversion" != none ]]; then echo "php${phpversion}-pgsql" fi diff --git a/scripts/change_url b/scripts/change_url index 4433872..b50b097 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -52,6 +52,12 @@ then domain="$old_domain" path_url="$new_path" + # Update custom error file path if needed + if [ $custom_error_file -eq 1 ] + then + ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" + fi + # Create a dedicated NGINX config ynh_add_nginx_config fi @@ -62,6 +68,7 @@ then # Delete file checksum for the old conf file location ynh_delete_file_checksum --file="$nginx_conf_path" ynh_delete_file_checksum --file="$nginx_extra_conf_dir/php.conf" + ynh_delete_file_checksum --file="$nginx_extra_conf_dir/error-code.conf" path_url="$new_path" domain="$old_domain" @@ -73,7 +80,14 @@ then 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.d/php.conf" + if [ $phpversion != "none" ] + then + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.d/php.conf" + fi + if [ $custom_error_file -eq 1 ] + then + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.d/error-code.conf" + fi fi #================================================= diff --git a/scripts/config b/scripts/config index 21b6f17..3d3e50b 100644 --- a/scripts/config +++ b/scripts/config @@ -59,7 +59,7 @@ get__free_footprint() { #================================================= set__password() { - if [ "$password" == "" ] + if [ ! "$password" == "" ] then ynh_app_setting_set --app=$app --key=password --value="$password" fi @@ -114,11 +114,16 @@ ynh_app_config_apply() { then ynh_app_setting_set --app=$app --key=phpversion --value="${old[phpversion]}" ynh_remove_fpm_config - # ^ the helper includes ynh_remove_app_dependencies + ynh_remove_app_dependencies YNH_PHP_VERSION=$phpversion # ^ ynh_add_config replaces __PHPVERSION__ by __PHP_YNH_VERSION__... ynh_app_setting_set --app=$app --key=phpversion --value="$phpversion" + database=$(ynh_app_setting_get --app=$app --key=database) + dependencies="$(ynh_read_manifest -k "resources.apt.packages")" + dependencies_from_raw_bash=$(eval "$(ynh_read_manifest -k "resources.apt.packages_from_raw_bash")" | tr "\n" " ") + ynh_install_app_dependencies "$dependencies $dependencies_from_raw_bash" + nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d" mkdir -p "$nginx_extra_conf_dir" if [ "$phpversion" == "none" ] @@ -127,7 +132,6 @@ ynh_app_config_apply() { ynh_secure_remove --file="$nginx_extra_conf_dir/php.conf" else 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 fi @@ -147,6 +151,26 @@ ynh_app_config_apply() { then ynh_system_user_del_group --username=$app --groups="sftp.app" fi + + if [ "${changed[password]}" == "true" ] && [ ! "$password" == "" ] + then + chpasswd <<< "${app}:${password}" + fi + + if [ "${changed[custom_error_file]}" == "true" ] + then + CUSTOM_ERROR_FILE=$custom_error_file + nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d" + + if [ $custom_error_file -eq 1 ] + then + ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" + elif [ $custom_error_file -eq 0 ] + then + ynh_secure_remove --file="$nginx_extra_conf_dir/error-code.conf" + fi + ynh_systemd_action --service_name=nginx --action=reload + fi if [ "$phpversion" != "none" ] then diff --git a/scripts/install b/scripts/install index 9ef3cba..f039e84 100644 --- a/scripts/install +++ b/scripts/install @@ -67,6 +67,13 @@ then YNH_PHP_VERSION="$phpversion" fi +if [ $custom_error_file -eq 1 ] +then + # Add the custom error build with the application + ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.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" diff --git a/scripts/restore b/scripts/restore index cd4f1af..7e0bac9 100644 --- a/scripts/restore +++ b/scripts/restore @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= 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/" +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.d" #================================================= # RESTORE THE MYSQL DATABASE diff --git a/scripts/upgrade b/scripts/upgrade index ef64b1e..a0852cc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -68,6 +68,12 @@ if [ -z "$phpversion" ]; then ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion fi +# If custom_error_file doesn't exist, create it. +if [ -z "${custom_error_file:-}" ]; then + custom_error_file=0 + ynh_app_setting_set --app=$app --key=custom_error_file --value=$custom_error_file +fi + # Delete old user if [ -n "$(ynh_app_setting_get --app=$app --key=user)" ] then @@ -102,6 +108,12 @@ then YNH_PHP_VERSION="$phpversion" fi +# Add the config error code +if [ $custom_error_file -eq 1 ] +then + ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.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" diff --git a/tests.toml b/tests.toml index a94ffe7..80bece3 100644 --- a/tests.toml +++ b/tests.toml @@ -7,9 +7,10 @@ test_format = 1.0 # ------------------------------- args.with_sftp = "1" + args.custom_error_file = "0" args.password = "SuperDuper_StrongPassw0rd" args.database = "none" - args.phpversion = "8.0" + args.phpversion = "8.3" test_upgrade_from.bf5d3ed.name = "1.0~ynh14" test_upgrade_from.bf5d3ed.args.with_mysql = "0" test_upgrade_from.bf5d3ed.args.domain = "sub.domain.tld" @@ -21,9 +22,18 @@ test_format = 1.0 only = ["install.subdir", "backup_restore", "upgrade" ] args.phpversion = "8.0" -[none_test] +[81_test] only = ["install.subdir", "backup_restore", "upgrade" ] + args.phpversion = "8.1" + +[82_test] + + only = ["install.subdir", "backup_restore", "upgrade" ] + args.phpversion = "8.2" + +[none_test] + args.phpversion = "none" [mysql_test] @@ -40,3 +50,12 @@ test_format = 1.0 only = ["install.subdir", "backup_restore", "upgrade" ] args.database = "postgresql" + +[custom_error_file_test] + + args.custom_error_file = "1" + test_upgrade_from.bf5d3ed.name = "1.0~ynh14" + test_upgrade_from.bf5d3ed.args.with_mysql = "0" + test_upgrade_from.bf5d3ed.args.domain = "sub.domain.tld" + test_upgrade_from.bf5d3ed.args.path = "/" + test_upgrade_from.bf5d3ed.args.password = "SuperDuper_StrongPassw0rd"