Compare commits

..

29 commits

Author SHA1 Message Date
Alexandre Aubin
9a1cf68d98
Merge pull request #141 from YunoHost-Apps/testing
Testing
2024-08-07 15:17:05 +02:00
yunohost-bot
f1545592a8 Auto-update READMEs 2024-08-07 13:16:58 +00:00
Alexandre Aubin
e59b8f1417
Update manifest.toml: bump version 2024-08-07 15:16:54 +02:00
Alexandre Aubin
d291edbc72
wtf... 2024-08-07 15:15:51 +02:00
Kayou
6566e1ce4f
Merge pull request #140 from YunoHost-Apps/testing
Testing
2024-07-29 16:35:04 +02:00
yunohost-bot
991cab74e4 Auto-update READMEs 2024-07-29 14:32:02 +00:00
Kayou
db825702a0
bump package 2024-07-29 16:31:58 +02:00
Kayou
477d98f4a6
do not remove old fpm config if phpversion was none 2024-07-29 16:31:40 +02:00
yunohost-bot
ea932c9763 Auto-update READMEs 2024-07-29 08:07:53 +00:00
Kayou
a41c46b182
Merge pull request #129 from YunoHost-Apps/testing
Testing
2024-07-29 10:07:46 +02:00
Kayou
89fbb93c76
fix restore script 2024-07-24 11:59:06 +02:00
Kayou
19f09d8569
Note to self - open your eyes BEFORE writing code 2024-07-24 10:14:09 +02:00
Kayou
db7dcbdd1b
fix change_url² 2024-07-23 17:43:36 +02:00
Kayou
eca97b65aa
fix change url 2024-07-23 16:36:00 +02:00
Kayou
7226257ce8
add all tests for custom_error_file_test 2024-07-23 14:04:28 +02:00
Kayou
df628b6cd1
add a test for custom_error_file 2024-07-23 14:01:30 +02:00
Kayou
f92817b922
add custom_error_file in the manifest, default to false 2024-07-23 13:57:51 +02:00
Kayou
55c0bbb594
fix indent 2024-07-23 13:52:14 +02:00
Kayou
cb465e8573
reenable ynh_delete_file_checksum of the nginx error conf file, let's wait the CI 2024-07-23 13:48:14 +02:00
Kayou
72ae3827de
Reinstall all the dependencies when changing php version² (remove php-fpm deps if phpversion is none) 2024-07-23 13:43:07 +02:00
yunohost-bot
f7e3c828ec Auto-update READMEs 2024-07-23 11:36:02 +00:00
Kayou
7d29233133
Merge pull request #138 from grenagit/master
Fix password change
2024-07-23 13:35:57 +02:00
yunohost-bot
81ecb8ba90 Auto-update READMEs 2024-07-03 16:09:59 +00:00
tituspijean
cefdd63e38
Typo 2024-07-03 18:09:55 +02:00
yunohost-bot
da1fc5e54b Auto-update READMEs 2024-06-24 10:13:24 +00:00
eric_G
c886821dcd
Merge branch 'master' into testing 2024-06-24 12:13:21 +02:00
Félix Piédallu
e4ff31c6c8 Update READMEs 2024-06-23 13:33:55 +02:00
Grena
0f47d1c6cb Add french translation of SFTP access into config panel 2024-06-05 10:46:55 +02:00
Grena
cab30de685 Fix password change 2024-06-05 10:30:49 +02:00
23 changed files with 376 additions and 201 deletions

2
.gitignore vendored
View file

@ -1,4 +1,2 @@
*~
*.sw[po]
*.sw[op]
.DS_Store

View file

@ -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)

View file

@ -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)
@ -24,9 +24,10 @@ 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.
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~ynh17
**Shipped version:** 1.0~ynh19
## Documentation and resources
- Upstream app code repository: <https://github.com/YunoHost-Apps/my_webapp_ynh>

View file

@ -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)
@ -24,9 +24,10 @@ 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.
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~ynh17
**Versión actual:** 1.0~ynh19
## Documentaciones y recursos
- Repositorio del código fuente oficial de la aplicación : <https://github.com/YunoHost-Apps/my_webapp_ynh>

View file

@ -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)
@ -24,9 +24,10 @@ 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.
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~ynh17
**Paketatutako bertsioa:** 1.0~ynh19
## Dokumentazioa eta baliabideak
- Jatorrizko aplikazioaren kode-gordailua: <https://github.com/YunoHost-Apps/my_webapp_ynh>

View file

@ -5,7 +5,7 @@ Il NE doit PAS être modifié à la main.
# My Webapp pour YunoHost
[![Niveau dinté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 dinté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)
@ -26,7 +26,7 @@ La version de PHP-FPM peut aussi être choisie, parmi `none`, `7.4`, `8.0`, `8.1
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~ynh17
**Version incluse:** 1.0~ynh19
## Documentations et ressources
- Dépôt de code officiel de lapp: <https://github.com/YunoHost-Apps/my_webapp_ynh>

View file

@ -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)
@ -24,9 +24,10 @@ 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.
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~ynh17
**Versión proporcionada:** 1.0~ynh19
## Documentación e recursos
- Repositorio de orixe do código: <https://github.com/YunoHost-Apps/my_webapp_ynh>

49
README_id.md Normal file
View file

@ -0,0 +1,49 @@
<!--
N.B.: README ini dibuat secara otomatis oleh <https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
Ini TIDAK boleh diedit dengan tangan.
-->
# 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~ynh19
## Dokumentasi dan sumber daya
- Depot kode aplikasi hulu: <https://github.com/YunoHost-Apps/my_webapp_ynh>
- Gudang YunoHost: <https://apps.yunohost.org/app/my_webapp>
- Laporkan bug: <https://github.com/YunoHost-Apps/my_webapp_ynh/issues>
## 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:** <https://yunohost.org/packaging_apps>

View file

@ -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)
@ -24,9 +24,10 @@ 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.
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~ynh17
**分发版本:** 1.0~ynh19
## 文档与资源
- 上游应用代码库: <https://github.com/YunoHost-Apps/my_webapp_ynh>

View file

@ -1,4 +1,6 @@
; Additional php.ini defines, specific to this pool of workers.
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

View file

@ -1,7 +1,7 @@
# Execute and serve PHP files
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHP_VERSION__-fpm-__APP__.sock;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;

View file

@ -4,19 +4,23 @@ 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 laccè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"

View file

@ -6,4 +6,4 @@ 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.
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.

View file

@ -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~ynh17"
version = "1.0~ynh19"
maintainers = []
@ -14,8 +14,7 @@ license = "GPL-3.0-only"
code = "https://github.com/YunoHost-Apps/my_webapp_ynh"
[integration]
yunohost = ">= 11.2.16"
helpers_version = "2.1"
yunohost = ">= 11.2.4"
architectures = "all"
multi_instance = true
ldap = "not_relevant"
@ -60,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]

View file

@ -1,7 +1,11 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES AND CUSTOM HELPERS
# COMMON VARIABLES
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
ynh_maintenance_mode_ON () {
@ -83,6 +87,7 @@ ynh_maintenance_mode_OFF () {
systemctl reload nginx
}
ynh_system_user_add_group() {
# Declare an array to define the options of this helper.
local legacy_args=uhs
@ -100,6 +105,7 @@ ynh_system_user_add_group() {
done
}
ynh_system_user_del_group() {
# Declare an array to define the options of this helper.
local legacy_args=uhs

View file

@ -1,30 +1,39 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
ynh_print_info "Declaring files to be backed up..."
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup "$install_dir"
ynh_backup --src_path="$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.d"
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
#=================================================
if [ $php_version != "none" ]
if [ $phpversion != "none" ]
then
ynh_backup "/etc/php/${php_version}/fpm/pool.d/$app.conf"
ynh_backup --src_path="/etc/php/${phpversion}/fpm/pool.d/$app.conf"
fi
#=================================================
@ -33,12 +42,12 @@ fi
if [ $database != "none" ]
then
ynh_print_info "Backing up the database..."
ynh_print_info --message="Backing up the database..."
if [ $database == "mysql" ]; then
ynh_mysql_dump_db > db.sql*
ynh_mysql_dump_db --database="$db_name" > db.sql
elif [ $database == "postgresql" ]; then
ynh_psql_dump_db > db.sql
ynh_psql_dump_db --database="$db_name" > db.sql
fi
fi
@ -46,4 +55,4 @@ fi
# END OF SCRIPT
#=================================================
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,21 +1,27 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#=================================================
ynh_script_progression "Backing up the app before changing its URL (may take a while)..."
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_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_safe_rm "/etc/nginx/conf.d/$new_domain.d/$app.conf"
ynh_safe_rm "/etc/nginx/conf.d/$new_domain.d/$app.d"
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
#REMOVEME? ynh_restore_upgradebackup
ynh_restore_upgradebackup
}
#=================================================
@ -26,20 +32,21 @@ path_url=$old_path
domain=$old_domain
ynh_maintenance_mode_ON
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression "Updating NGINX web server configuration..."
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
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 ]
ynh_print_info "Change the path in the Nginx config file"
then
# Make a backup of the original NGINX config file if modified
ynh_backup_if_checksum_is_different "$nginx_conf_path"
ynh_backup_if_checksum_is_different --file="$nginx_conf_path"
# Set global variables for NGINX helper
domain="$old_domain"
@ -48,33 +55,39 @@ then
# Update custom error file path if needed
if [ $custom_error_file -eq 1 ]
then
ynh_config_add --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf"
ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf"
fi
# Create a dedicated NGINX configssh
ynh_config_add_nginx
# Create a dedicated NGINX config
ynh_add_nginx_config
fi
# Change the domain for NGINX
if [ $change_domain -eq 1 ]
then
# Delete file checksum for the old conf file location
ynh_delete_file_checksum "$nginx_conf_path"
ynh_delete_file_checksum "$nginx_extra_conf_dir/php.conf"
#ynh_delete_file_checksum "$nginx_extra_conf_dir/nginx-code-error.conf"
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"
ynh_config_remove_nginx
ynh_remove_nginx_config
domain="$new_domain"
ynh_config_add_nginx
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 "/etc/nginx/conf.d/$new_domain.d/$app.d/php.conf"
#ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.d/nginx-code-error.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
#=================================================
@ -89,4 +102,4 @@ ynh_maintenance_mode_OFF
# END OF SCRIPT
#=================================================
ynh_script_progression "Change of URL completed for $app"
ynh_script_progression --message="Change of URL completed for $app" --last

View file

@ -1,5 +1,11 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -9,13 +15,13 @@ ynh_abort_if_errors
# RETRIEVE ARGUMENTS
#=================================================
install_dir=$(ynh_app_setting_get --key=install_dir)
domain=$(ynh_app_setting_get --key=domain)
path=$(ynh_app_setting_get --key=path)
install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
domain=$(ynh_app_setting_get --app=$app --key=domain)
path=$(ynh_app_setting_get --app=$app --key=path)
current_fpm_footprint=$(ynh_app_setting_get --key=fpm_footprint)
# REMOVEME ? Everything about fpm_footprint is removed in helpers2.1... | fpm_footprint=$(ynh_app_setting_get --key=fpm_footprint)
# REMOVEME ? Everything about fpm_usage is removed in helpers2.1... | fpm_usage=$(ynh_app_setting_get --key=fpm_usage)
current_fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
#=================================================
# SPECIFIC GETTERS FOR TOML SHORT KEY
@ -53,26 +59,28 @@ get__free_footprint() {
#=================================================
set__password() {
if [ "$password" == "" ]
if [ ! "$password" == "" ]
then
ynh_app_setting_set --key=password --value="$password"
ynh_app_setting_set --app=$app --key=password --value="$password"
fi
}
# REMOVEME ? Everything about fpm_footprint is removed in helpers2.1... | set__fpm_footprint() {
# REMOVEME ? Everything about fpm_footprint is removed in helpers2.1... | if [ "$fpm_footprint" != "specific" ]
set__fpm_footprint() {
if [ "$fpm_footprint" != "specific" ]
then
# REMOVEME ? Everything about fpm_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_footprint --value="$fpm_footprint"
ynh_app_setting_set --app=$app --key=fpm_footprint --value="$fpm_footprint"
fi
}
# REMOVEME ? Everything about fpm_free_footprint is removed in helpers2.1... | set__fpm_free_footprint() {
# REMOVEME ? Everything about fpm_footprint is removed in helpers2.1... | if [ "$fpm_footprint" = "specific" ]
set__fpm_free_footprint() {
if [ "$fpm_footprint" = "specific" ]
then
# REMOVEME ? Everything about fpm_free_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_footprint --value="$fpm_free_footprint"
ynh_app_setting_set --app=$app --key=fpm_footprint --value="$fpm_free_footprint"
fi
}
#=================================================
# GENERIC FINALIZATION
#=================================================
ynh_app_config_validate() {
@ -80,19 +88,19 @@ ynh_app_config_validate() {
if [ "${changed[with_sftp]}" == "true" ] && [ $with_sftp -eq 1 ] && [ "$password" == "" ]
then
ynh_die "You need to set a password to enable SFTP"
ynh_die --message="You need to set a password to enable SFTP"
fi
if [ "${changed[fpm_usage]}" == "true" ] || [ "${changed[fpm_footprint]}" == "true" ] || [ "${changed[fpm_free_footprint]}" == "true" ]; then
# REMOVEME ? Everything about fpm_free_footprint is removed in helpers2.1... | # If fpm_footprint is set to 'specific', use $fpm_free_footprint value.
# REMOVEME ? Everything about fpm_footprint is removed in helpers2.1... | if [ "$fpm_footprint" = "specific" ]
# If fpm_footprint is set to 'specific', use $fpm_free_footprint value.
if [ "$fpm_footprint" = "specific" ]
then
# REMOVEME ? Everything about fpm_free_footprint is removed in helpers2.1... | fpm_footprint=$fpm_free_footprint
fpm_footprint=$fpm_free_footprint
fi
# REMOVEME ? Everything about fpm_footprint is removed in helpers2.1... | if [ "$fpm_footprint" == "0" ]
if [ "$fpm_footprint" == "0" ]
then
ynh_print_warn "When selecting 'specific', you have to set a footprint value into the field below."
ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below."
exit 0
fi
@ -102,32 +110,36 @@ ynh_app_config_validate() {
ynh_app_config_apply() {
_ynh_app_config_apply
if [ "${changed[php_version]}" == "true" ]
if [ "${changed[phpversion]}" == "true" ]
then
ynh_app_setting_set --key=php_version --value="${old[php_version]}"
ynh_config_remove_phpfpm
ynh_apt_remove_dependencies
YNH_PHP_VERSION=$php_version
# ^ ynh_config_add replaces __PHP_VERSION__ by __PHP_YNH_VERSION__...
ynh_app_setting_set --key=php_version --value="$php_version"
if [ "${old[phpversion]}" != "none" ]
then
ynh_app_setting_set --app=$app --key=phpversion --value="${old[phpversion]}"
ynh_remove_fpm_config
fi
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 [ "$php_version" == "none" ]
if [ "$phpversion" == "none" ]
then
ynh_delete_file_checksum "$nginx_extra_conf_dir/php.conf"
ynh_safe_rm "$nginx_extra_conf_dir/php.conf"
ynh_delete_file_checksum --file="$nginx_extra_conf_dir/php.conf"
ynh_secure_remove --file="$nginx_extra_conf_dir/php.conf"
else
ynh_config_add --template="nginx-php.conf" --destination="$nginx_extra_conf_dir/php.conf"
database=$(ynh_app_setting_get --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_apt_install_dependencies "$dependencies $dependencies_from_raw_bash"
ynh_config_add_phpfpm
# ^ the helper takes care of ynh_app_setting_set the php_version
ynh_add_config --template="nginx-php.conf" --destination="$nginx_extra_conf_dir/php.conf"
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion
# ^ the helper takes care of ynh_app_setting_set the phpversion
fi
ynh_config_add_nginx
ynh_add_nginx_config
fi
if [ "${changed[with_sftp]}" == "true" ] && [ $with_sftp -eq 1 ]
@ -143,26 +155,30 @@ ynh_app_config_apply() {
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"
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_config_add --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf"
elif [ $custom_error_file -eq 0 ]
then
ynh_safe_rm "$nginx_extra_conf_dir/error-code.conf"
fi
ynh_systemctl --service=nginx --action=reload
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 [ "$php_version" != "none" ]
if [ "$phpversion" != "none" ]
then
ynh_config_add_phpfpm
ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
fi
}
ynh_app_config_run $1

View file

@ -1,10 +1,14 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
ynh_app_setting_set --key=php_upload_max_filesize --value=500M
#=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST
#=================================================
@ -16,65 +20,68 @@ ssh_port=$(grep "^Port" /etc/ssh/sshd_config | awk '{print $2}')
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression "Validating installation parameters..."
ynh_script_progression --message="Validating installation parameters..." --weight=2
[ $with_sftp -eq 0 ] || [ "$password" != "" ] || ynh_die "You need to set a password to enable SFTP"
[ $with_sftp -eq 0 ] || [ "$password" != "" ] || ynh_die --message="You need to set a password to enable SFTP"
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_script_progression "Storing installation settings..."
ynh_script_progression --message="Storing installation settings..." --weight=1
ynh_app_setting_set --key=password --value=$password
ynh_app_setting_set --app=$app --key=password --value=$password
#=================================================
# CREATE A MYSQL DATABASE
#=================================================
if [ $database != "none" ]; then
ynh_script_progression "Creating a database..."
ynh_script_progression --message="Creating a database..." --weight=2
db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name
db_pwd=$(ynh_string_random --length=30)
ynh_app_setting_set --key=db_name --value=$db_name
ynh_app_setting_set --key=db_user --value=$db_user
ynh_app_setting_set --key=db_pwd --value=$db_pwd
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_app_setting_set --app=$app --key=db_user --value=$db_user
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
if [ $database == "mysql" ]; then
# FIXME ynh_mysql_create_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
elif [ $database == "postgresql" ]; then
# FIXME ynh_psql_create_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
fi
fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression "Configuring NGINX web server..."
ynh_script_progression --message="Configuring NGINX web server..." --weight=2
nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d"
mkdir -p "$nginx_extra_conf_dir"
# Prepare nginx extra conf
if [ $php_version != "none" ]
if [ $phpversion != "none" ]
then
ynh_config_add --template="nginx-php.conf" --destination="$nginx_extra_conf_dir/php.conf"
YNH_PHP_VERSION="$php_version"
ynh_add_config --template="nginx-php.conf" --destination="$nginx_extra_conf_dir/php.conf"
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
# Add the custom error build with the application
ynh_config_add --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf"
ynh_app_setting_set --key=custom_error_file --value="true"
# Create a dedicated NGINX config
ynh_config_add_nginx
ynh_config_add --template="example-custom-nginx-config.conf" --destination="$nginx_extra_conf_dir/sample.conf"
ynh_add_nginx_config
ynh_add_config --template="example-custom-nginx-config.conf" --destination="$nginx_extra_conf_dir/sample.conf"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression "Configuring system user..."
ynh_script_progression --message="Configuring system user..."
if [ $with_sftp -eq 1 ]
then
@ -101,9 +108,9 @@ mkdir -p "$install_dir/www"
if [ $with_sftp -eq 1 ]
then
ynh_config_add --template="../sources/www/index.html" --destination="$install_dir/www/index.html"
ynh_add_config --template="../sources/www/index.html" --destination="$install_dir/www/index.html"
else
ynh_config_add --template="../sources/www/index_no_sftp.html" --destination="$install_dir/www/index.html"
ynh_add_config --template="../sources/www/index_no_sftp.html" --destination="$install_dir/www/index.html"
fi
chown -R $app:www-data "$install_dir"
@ -118,15 +125,24 @@ chmod 750 "$install_dir"
# PHP-FPM CONFIGURATION
#=================================================
if [ $php_version != "none" ]
then
ynh_script_progression "Configuring PHP-FPM..."
fpm_footprint="low"
fpm_free_footprint=0
fpm_usage="low"
ynh_config_add_phpfpm
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
# Create a dedicatedPHP-FPM config
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion
fi
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Installation of $app completed"
ynh_script_progression --message="Installation of $app completed" --last

View file

@ -1,5 +1,11 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -10,38 +16,38 @@ source /usr/share/yunohost/helpers
#=================================================
if [ $database != "none" ]; then
ynh_script_progression "Removing the database..."
ynh_script_progression --message="Removing the database..." --weight=2
db_name=$(ynh_app_setting_get --key=db_name)
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
if [ $database == "mysql" ]; then
# FIXME ynh_mysql_drop_db && ynh_mysql_drop_user --db_user=$db_user --db_name=$db_name
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
elif [ $database == "postgresql" ]; then
# FIXME ynh_psql_drop_db && ynh_psql_drop_user --db_user=$db_user --db_name=$db_name
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
fi
fi
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression "Removing NGINX web server configuration..."
ynh_script_progression --message="Removing NGINX web server configuration..." --weight=2
# Remove the dedicated NGINX config
ynh_config_remove_nginx
ynh_safe_rm "/etc/nginx/conf.d/$domain.d/$app.d"
ynh_remove_nginx_config
ynh_secure_remove --file="/etc/nginx/conf.d/$domain.d/$app.d"
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression "Removing PHP-FPM configuration..."
ynh_script_progression --message="Removing PHP-FPM configuration..."
# Remove the dedicated PHP-FPM config
ynh_config_remove_phpfpm
ynh_remove_fpm_config
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Removal of $app completed"
ynh_script_progression --message="Removal of $app completed" --last

View file

@ -1,5 +1,11 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -7,33 +13,33 @@ source /usr/share/yunohost/helpers
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.d/"
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
#=================================================
if [ $database != "none" ]; then
ynh_script_progression "Restoring the database..."
ynh_script_progression --message="Restoring the database..."
db_name=$(ynh_app_setting_get --key=db_name)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
db_pwd=$(ynh_app_setting_get --key=db_pwd)
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
if [ $database == "mysql" ]; then
# FIXME ynh_mysql_create_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_db_shell < ./db.sql
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
elif [ $database == "postgresql" ]; then
# FIXME ynh_psql_create_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_db_shell < ./db.sql
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
fi
fi
#=================================================
# RECREATE THE DEDICATED USER
#=================================================
ynh_script_progression "Recreating the dedicated system user..."
ynh_script_progression --message="Recreating the dedicated system user..." --weight=2
if [ $with_sftp -eq 1 ]
then
@ -53,9 +59,9 @@ fi
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression "Restoring the app main directory..."
ynh_script_progression --message="Restoring the app main directory..."
ynh_restore "$install_dir"
ynh_restore_file --origin_path="$install_dir"
# Restore permissions on app files
chown -R $app:www-data "$install_dir"
@ -70,25 +76,27 @@ chmod 750 "$install_dir"
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
if [ $php_version != "none" ]
if [ $phpversion != "none" ]
then
ynh_restore "/etc/php/${php_version}/fpm/pool.d/$app.conf"
ynh_restore_file --origin_path="/etc/php/${phpversion}/fpm/pool.d/$app.conf"
fi
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression "Reloading NGINX web server and PHP-FPM..."
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
if [ $php_version != "none" ]
if [ $phpversion != "none" ]
then
ynh_systemctl --service=php${php_version}-fpm --action=reload
ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload
fi
ynh_systemctl --service=nginx --action=reload
ynh_systemd_action --service_name=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Restoration completed for $app"
ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -1,14 +1,24 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
ynh_app_setting_set_default --key=php_upload_max_filesize --value=500M
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression "Ensuring downward compatibility..."
ynh_script_progression --message="Ensuring downward compatibility..."
# If database doesn't exist, create it and remove with_mysql setting
if [ -z "${database:-}" ]; then
@ -18,47 +28,62 @@ if [ -z "${database:-}" ]; then
database="none"
fi
ynh_app_setting_set --key=database --value=$database
ynh_app_setting_delete --key=with_mysql
ynh_app_setting_set --app=$app --key=database --value=$database
ynh_app_setting_delete --app=$app --key=with_mysql
fi
# If admin_mail_html doesn't exist, create it
# FIXME: maybe replace with: ynh_app_setting_set_default --key=admin_mail_html --value=1
if [ -z "${admin_mail_html:-}" ]; then
admin_mail_html=1
ynh_app_setting_set --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
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
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
fpm_usage=low
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
fi
# If with_sftp doesn't exist, create it
# FIXME: maybe replace with: ynh_app_setting_set_default --key=with_sftp --value=1
if [ -z "${with_sftp:-}" ]; then
with_sftp=1
ynh_app_setting_set --key=with_sftp --value=$with_sftp
ynh_app_setting_set --app=$app --key=with_sftp --value=$with_sftp
fi
# If php_version doesn't exist, create it. We assume it is the default system one.
if [ -z "$php_version" ]; then
php_version=$YNH_DEFAULT_PHP_VERSION
ynh_app_setting_set --key=php_version --value=$php_version
# If phpversion doesn't exist, create it. We assume it is the default system one.
if [ -z "$phpversion" ]; then
phpversion=$YNH_DEFAULT_PHP_VERSION
ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion
fi
# If custom_error_file doesn't exist, create it.
# FIXME: maybe replace with: ynh_app_setting_set_default --key=custom_error_file --value=1
if [ -z "${custom_error_file:-}" ]; then
custom_error_file=1
ynh_app_setting_set --key=custom_error_file --value=$custom_error_file
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 --key=user)" ]
if [ -n "$(ynh_app_setting_get --app=$app --key=user)" ]
then
ynh_systemctl --service=php${php_version}-fpm --action=stop
ynh_system_user_delete --username="$(ynh_app_setting_get --key=user)"
ynh_app_setting_delete --key=user
ynh_systemd_action --service_name=php${phpversion}-fpm --action=stop
ynh_system_user_delete --username="$(ynh_app_setting_get --app=$app --key=user)"
ynh_app_setting_delete --app=$app --key=user
fi
# Ensure password is a setting even if empty, for the config panel
ynh_app_setting_set --key=password --value="$password"
ynh_app_setting_set --app=$app --key=password --value="$password"
#=================================================
# ACTIVATE MAINTENANCE MODE
@ -69,7 +94,7 @@ ynh_maintenance_mode_ON
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression "Upgrading NGINX web server 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"
@ -77,26 +102,26 @@ nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d"
mkdir -p "$nginx_extra_conf_dir"
# Prepare nginx extra conf
if [ $php_version != "none" ]
if [ $phpversion != "none" ]
then
ynh_config_add --template="nginx-php.conf" --destination="$nginx_extra_conf_dir/php.conf"
YNH_PHP_VERSION="$php_version"
ynh_add_config --template="nginx-php.conf" --destination="$nginx_extra_conf_dir/php.conf"
YNH_PHP_VERSION="$phpversion"
fi
# Add the config error code
if [ $custom_error_file -eq 1 ]
then
ynh_config_add --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf"
ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf"
fi
# Create a dedicated NGINX config
ynh_config_add_nginx
ynh_config_add --template="example-custom-nginx-config.conf" --destination="$nginx_extra_conf_dir/sample.conf"
ynh_add_nginx_config
ynh_add_config --template="example-custom-nginx-config.conf" --destination="$nginx_extra_conf_dir/sample.conf"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression "Making sure dedicated system user exists..."
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=2
if [ $with_sftp -eq 1 ]
then
@ -121,13 +146,16 @@ usermod -g "$app" "$app"
# PHP-FPM CONFIGURATION
#=================================================
if [ $php_version != "none" ]
if [ $phpversion != "none" ]
then
ynh_script_progression "Upgrading PHP-FPM configuration..."
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2
ynh_config_add_phpfpm
# Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion
fi
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
@ -150,4 +178,4 @@ ynh_maintenance_mode_OFF
# END OF SCRIPT
#=================================================
ynh_script_progression "Upgrade of $app completed"
ynh_script_progression --message="Upgrade of $app completed" --last

View file

@ -7,6 +7,7 @@ test_format = 1.0
# -------------------------------
args.with_sftp = "1"
args.custom_error_file = "0"
args.password = "SuperDuper_StrongPassw0rd"
args.database = "none"
args.phpversion = "8.3"
@ -33,7 +34,6 @@ test_format = 1.0
[none_test]
only = ["install.subdir", "backup_restore", "upgrade" ]
args.phpversion = "none"
[mysql_test]
@ -50,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"