Compare commits

...
Sign in to create a new pull request.

4 commits

Author SHA1 Message Date
Éric Gaspar
bbfd053a93 Merge branch 'helpers-2.1' of https://github.com/YunoHost-Apps/my_webapp_ynh into helpers-2.1 2024-06-23 21:55:46 +02:00
Éric Gaspar
052a5cf96c cleaning 2024-06-23 21:55:41 +02:00
yunohost-bot
2128b4bc23 Auto-update READMEs 2024-06-23 19:51:56 +00:00
Éric Gaspar
0f3fc48543 cleaning 2024-06-23 21:51:49 +02:00
14 changed files with 211 additions and 248 deletions

2
.gitignore vendored
View file

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

View file

@ -1,6 +1,7 @@
# All available README files by language # All available README files by language
- [Read the README in English](README.md) - [Read the README in English](README.md)
- [Lea el README en español](README_es.md)
- [Irakurri README euskaraz](README_eu.md) - [Irakurri README euskaraz](README_eu.md)
- [Lire le README en français](README_fr.md) - [Lire le README en français](README_fr.md)
- [Le o README en galego](README_gl.md) - [Le o README en galego](README_gl.md)

48
README_es.md Normal file
View file

@ -0,0 +1,48 @@
<!--
Este archivo README esta generado automaticamente<https://github.com/YunoHost/apps/tree/master/tools/readme_generator>
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)
[![Instalar My Webapp con Yunhost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=my_webapp)
*[Leer este README en otros idiomas.](./ALL_README.md)*
> *Este paquete le permite instalarMy Webapp rapidamente y simplement en un servidor YunoHost.*
> *Si no tiene YunoHost, visita [the guide](https://yunohost.org/install) para aprender como instalarla.*
## Descripción general
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ón actual:** 1.0~ynh17
## Documentaciones y recursos
- Repositorio del código fuente oficial de la aplicación : <https://github.com/YunoHost-Apps/my_webapp_ynh>
- Catálogo YunoHost: <https://apps.yunohost.org/app/my_webapp>
- Reportar un error: <https://github.com/YunoHost-Apps/my_webapp_ynh/issues>
## Información para desarrolladores
Por favor enviar sus correcciones a la [`branch testing`](https://github.com/YunoHost-Apps/my_webapp_ynh/tree/testing
Para probar la rama `testing`, sigue asÍ:
```bash
sudo yunohost app install https://github.com/YunoHost-Apps/my_webapp_ynh/tree/testing --debug
o
sudo yunohost app upgrade my_webapp -u https://github.com/YunoHost-Apps/my_webapp_ynh/tree/testing --debug
```
**Mas informaciones sobre el empaquetado de aplicaciones:** <https://yunohost.org/packaging_apps>

View file

@ -1,6 +1,4 @@
; Additional php.ini defines, specific to this pool of workers. ; 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[default_charset] = UTF-8
php_value[always_populate_raw_post_data] = -1 php_value[always_populate_raw_post_data] = -1

View file

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

View file

@ -14,7 +14,8 @@ license = "GPL-3.0-only"
code = "https://github.com/YunoHost-Apps/my_webapp_ynh" code = "https://github.com/YunoHost-Apps/my_webapp_ynh"
[integration] [integration]
yunohost = ">= 11.2.4" yunohost = ">= 11.2.16"
helpers_version = "2.1"
architectures = "all" architectures = "all"
multi_instance = true multi_instance = true
ldap = "not_relevant" ldap = "not_relevant"

View file

@ -1,11 +1,7 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#================================================= #=================================================
ynh_maintenance_mode_ON () { ynh_maintenance_mode_ON () {
@ -18,7 +14,7 @@ ynh_maintenance_mode_ON () {
fi fi
mkdir -p /var/www/html/ mkdir -p /var/www/html/
# Create an html to serve as maintenance notice # Create an html to serve as maintenance notice
echo "<!DOCTYPE html> echo "<!DOCTYPE html>
<html> <html>
@ -87,7 +83,6 @@ ynh_maintenance_mode_OFF () {
systemctl reload nginx systemctl reload nginx
} }
ynh_system_user_add_group() { ynh_system_user_add_group() {
# Declare an array to define the options of this helper. # Declare an array to define the options of this helper.
local legacy_args=uhs local legacy_args=uhs
@ -105,7 +100,6 @@ ynh_system_user_add_group() {
done done
} }
ynh_system_user_del_group() { ynh_system_user_del_group() {
# Declare an array to define the options of this helper. # Declare an array to define the options of this helper.
local legacy_args=uhs local legacy_args=uhs

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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