1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/my_webapp_ynh.git synced 2024-09-03 19:46:26 +02:00
This commit is contained in:
YunoHost Bot 2024-09-02 00:42:38 +02:00 committed by GitHub
commit 457534e87d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 186 additions and 246 deletions

2
.gitignore vendored
View file

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

View file

@ -1,6 +1,4 @@
; 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__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_pass unix:/var/run/php/php__PHP_VERSION__-fpm-__APP__.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param REMOTE_USER $remote_user;

View file

@ -13,7 +13,8 @@ maintainers = []
license = "GPL-3.0-only"
[integration]
yunohost = ">= 11.2.4"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = "all"
multi_instance = true
ldap = "not_relevant"
@ -68,6 +69,7 @@ ram.runtime = "50M"
[resources.system_user]
[resources.install_dir]
group = "www-data:r-x"
[resources.permissions]
main.url = "/"

View file

@ -1,11 +1,7 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
ynh_maintenance_mode_ON () {
@ -18,7 +14,7 @@ ynh_maintenance_mode_ON () {
fi
mkdir -p /var/www/html/
# Create an html to serve as maintenance notice
echo "<!DOCTYPE html>
<html>
@ -87,10 +83,9 @@ 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
#REMOVEME? local legacy_args=uhs
local -A args_array=([u]=username= [g]=groups=)
local username
local groups
@ -105,10 +100,9 @@ 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
#REMOVEME? local legacy_args=uhs
local -A args_array=([u]=username= [g]=groups=)
local username
local groups

View file

@ -1,39 +1,30 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
ynh_print_info "Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$install_dir"
ynh_backup "$install_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.d"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.d"
#=================================================
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
if [ $phpversion != "none" ]
if [ $php_version != "none" ]
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
#=================================================
@ -42,12 +33,12 @@ fi
if [ $database != "none" ]
then
ynh_print_info --message="Backing up the database..."
ynh_print_info "Backing up the database..."
if [ $database == "mysql" ]; then
ynh_mysql_dump_db --database="$db_name" > db.sql
ynh_mysql_dump_db > db.sql
elif [ $database == "postgresql" ]; then
ynh_psql_dump_db --database="$db_name" > db.sql
ynh_psql_dump_db > db.sql
fi
fi
@ -55,4 +46,4 @@ fi
# 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
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# 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
ynh_clean_setup () {
#REMOVEME? ynh_clean_setup () {
# Remove the new domain config file, the remove script won't do it as it doesn't know yet its location.
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf"
ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.d"
ynh_safe_rm "/etc/nginx/conf.d/$new_domain.d/$app.conf"
ynh_safe_rm "/etc/nginx/conf.d/$new_domain.d/$app.d"
# restore it if the upgrade fails
ynh_restore_upgradebackup
#REMOVEME? ynh_restore_upgradebackup
}
#=================================================
@ -32,12 +26,10 @@ path_url=$old_path
domain=$old_domain
ynh_maintenance_mode_ON
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# 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_extra_conf_dir=/etc/nginx/conf.d/$old_domain.d/$app.d
@ -46,7 +38,7 @@ nginx_extra_conf_dir=/etc/nginx/conf.d/$old_domain.d/$app.d
if [ $change_path -eq 1 ]
then
# 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
domain="$old_domain"
@ -55,38 +47,38 @@ then
# Update custom error file path if needed
if [ $custom_error_file -eq 1 ]
then
ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf"
ynh_config_add --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf"
fi
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
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 --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"
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/error-code.conf"
path_url="$new_path"
domain="$old_domain"
ynh_remove_nginx_config
ynh_config_remove_nginx
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
# Store file checksum for the new config file location
if [ $phpversion != "none" ]
if [ $php_version != "none" ]
then
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"
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"
ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.d/error-code.conf"
fi
fi
@ -102,4 +94,4 @@ ynh_maintenance_mode_OFF
# 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,27 +1,21 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
ynh_abort_if_errors
#REMOVEME? ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
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)
install_dir=$(ynh_app_setting_get --key=install_dir)
domain=$(ynh_app_setting_get --key=domain)
path=$(ynh_app_setting_get --key=path)
current_fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
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)
#=================================================
# SPECIFIC GETTERS FOR TOML SHORT KEY
@ -61,26 +55,24 @@ get__free_footprint() {
set__password() {
if [ ! "$password" == "" ]
then
ynh_app_setting_set --app=$app --key=password --value="$password"
ynh_app_setting_set --key=password --value="$password"
fi
}
set__fpm_footprint() {
if [ "$fpm_footprint" != "specific" ]
#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" ]
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
}
set__fpm_free_footprint() {
if [ "$fpm_footprint" = "specific" ]
#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" ]
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
}
#=================================================
# GENERIC FINALIZATION
#=================================================
ynh_app_config_validate() {
@ -88,19 +80,19 @@ ynh_app_config_validate() {
if [ "${changed[with_sftp]}" == "true" ] && [ $with_sftp -eq 1 ] && [ "$password" == "" ]
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
if [ "${changed[fpm_usage]}" == "true" ] || [ "${changed[fpm_footprint]}" == "true" ] || [ "${changed[fpm_free_footprint]}" == "true" ]; then
# If fpm_footprint is set to 'specific', use $fpm_free_footprint value.
if [ "$fpm_footprint" = "specific" ]
#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" ]
then
fpm_footprint=$fpm_free_footprint
#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | fpm_footprint=$fpm_free_footprint
fi
if [ "$fpm_footprint" == "0" ]
#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | if [ "$fpm_footprint" == "0" ]
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
fi
@ -110,36 +102,36 @@ ynh_app_config_validate() {
ynh_app_config_apply() {
_ynh_app_config_apply
if [ "${changed[phpversion]}" == "true" ]
if [ "${changed[php_version]}" == "true" ]
then
if [ "${old[phpversion]}" != "none" ]
if [ "${old[php_version]}" != "none" ]
then
ynh_app_setting_set --app=$app --key=phpversion --value="${old[phpversion]}"
ynh_remove_fpm_config
ynh_app_setting_set --key=php_version --value="${old[php_version]}"
ynh_config_remove_phpfpm
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"
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"
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_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"
nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d"
mkdir -p "$nginx_extra_conf_dir"
if [ "$phpversion" == "none" ]
if [ "$php_version" == "none" ]
then
ynh_delete_file_checksum --file="$nginx_extra_conf_dir/php.conf"
ynh_secure_remove --file="$nginx_extra_conf_dir/php.conf"
ynh_delete_file_checksum "$nginx_extra_conf_dir/php.conf"
ynh_safe_rm "$nginx_extra_conf_dir/php.conf"
else
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
ynh_config_add --template="nginx-php.conf" --destination="$nginx_extra_conf_dir/php.conf"
ynh_config_add_phpfpm
# ^ the helper takes care of ynh_app_setting_set the php_version
fi
ynh_add_nginx_config
ynh_config_add_nginx
fi
if [ "${changed[with_sftp]}" == "true" ] && [ $with_sftp -eq 1 ]
@ -154,7 +146,7 @@ ynh_app_config_apply() {
then
ynh_system_user_del_group --username=$app --groups="sftp.app"
fi
if [ "${changed[password]}" == "true" ] && [ ! "$password" == "" ]
then
chpasswd <<< "${app}:${password}"
@ -167,17 +159,17 @@ ynh_app_config_apply() {
if [ $custom_error_file -eq 1 ]
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 ]
then
ynh_secure_remove --file="$nginx_extra_conf_dir/error-code.conf"
ynh_safe_rm "$nginx_extra_conf_dir/error-code.conf"
fi
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemctl --service=nginx --action=reload
fi
if [ "$phpversion" != "none" ]
if [ "$php_version" != "none" ]
then
ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
ynh_config_add_phpfpm
fi
}

View file

@ -1,14 +1,10 @@
#!/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
#=================================================
@ -20,68 +16,67 @@ ssh_port=$(grep "^Port" /etc/ssh/sshd_config | awk '{print $2}')
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --weight=2
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
#=================================================
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
#=================================================
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_user=$db_name
db_pwd=$(ynh_string_random --length=30)
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_app_setting_set --app=$app --key=db_user --value=$db_user
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
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
if [ $database == "mysql" ]; then
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
# FIXMEhelpers2.1 ynh_mysql_create_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
elif [ $database == "postgresql" ]; then
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
# FIXMEhelpers2.1 ynh_psql_create_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
fi
fi
#=================================================
# 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"
mkdir -p "$nginx_extra_conf_dir"
# Prepare nginx extra conf
if [ $phpversion != "none" ]
if [ $php_version != "none" ]
then
ynh_add_config --template="nginx-php.conf" --destination="$nginx_extra_conf_dir/php.conf"
YNH_PHP_VERSION="$phpversion"
ynh_config_add --template="nginx-php.conf" --destination="$nginx_extra_conf_dir/php.conf"
YNH_PHP_VERSION="$php_version"
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"
ynh_config_add --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf"
fi
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_add_config --template="example-custom-nginx-config.conf" --destination="$nginx_extra_conf_dir/sample.conf"
ynh_config_add_nginx
ynh_config_add --template="example-custom-nginx-config.conf" --destination="$nginx_extra_conf_dir/sample.conf"
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..."
ynh_script_progression "Configuring system user..."
if [ $with_sftp -eq 1 ]
then
@ -108,41 +103,40 @@ mkdir -p "$install_dir/www"
if [ $with_sftp -eq 1 ]
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
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
chown -R $app:www-data "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
# Home directory of the user needs to be owned by root to allow
# SFTP connections
chown root:root "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root:root "$install_dir"
setfacl -m g:$app:r-x "$install_dir"
setfacl -m g:www-data:r-x "$install_dir"
chmod 750 "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
fpm_footprint="low"
fpm_free_footprint=0
fpm_usage="low"
#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | fpm_footprint="low"
#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | fpm_free_footprint=0
#REMOVEME? Everything about fpm_usage is removed in helpers2.1... | 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
#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_footprint --value=$fpm_footprint
#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_free_footprint --value=$fpm_free_footprint
#REMOVEME? Everything about fpm_usage is removed in helpers2.1... | ynh_app_setting_set --key=fpm_usage --value=$fpm_usage
if [ $phpversion != "none" ]
if [ $php_version != "none" ]
then
ynh_script_progression --message="Configuring PHP-FPM..." --weight=2
ynh_script_progression "Configuring PHP-FPM..."
# Create a dedicatedPHP-FPM config
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion
ynh_config_add_phpfpm
fi
#=================================================
# 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
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
@ -16,38 +10,38 @@ source /usr/share/yunohost/helpers
#=================================================
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
# Remove a database if it exists, along with the associated user
if [ $database == "mysql" ]; then
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name
# FIXMEhelpers2.1 ynh_mysql_drop_db && ynh_mysql_drop_user --db_user=$db_user --db_name=$db_name
elif [ $database == "postgresql" ]; then
ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
# FIXMEhelpers2.1 ynh_psql_drop_db && ynh_psql_drop_user --db_user=$db_user --db_name=$db_name
fi
fi
#=================================================
# 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
ynh_remove_nginx_config
ynh_secure_remove --file="/etc/nginx/conf.d/$domain.d/$app.d"
ynh_config_remove_nginx
ynh_safe_rm "/etc/nginx/conf.d/$domain.d/$app.d"
#=================================================
# 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
ynh_remove_fpm_config
ynh_config_remove_phpfpm
#=================================================
# 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
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -13,33 +7,33 @@ source /usr/share/yunohost/helpers
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.d"
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.d"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
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_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
db_pwd=$(ynh_app_setting_get --key=db_pwd)
if [ $database == "mysql" ]; then
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
# FIXMEhelpers2.1 ynh_mysql_create_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_mysql_db_shell < ./db.sql
elif [ $database == "postgresql" ]; then
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
# FIXMEhelpers2.1 ynh_psql_create_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
ynh_psql_db_shell < ./db.sql
fi
fi
#=================================================
# 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 ]
then
@ -59,44 +53,41 @@ fi
#=================================================
# 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
chown -R $app:www-data "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
# Home directory of the user needs to be owned by root to allow
# SFTP connections
chown root:root "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root:root "$install_dir"
setfacl -m g:$app:r-x "$install_dir"
setfacl -m g:www-data:r-x "$install_dir"
chmod 750 "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
if [ $phpversion != "none" ]
if [ $php_version != "none" ]
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
#=================================================
# GENERIC FINALIZATION
#=================================================
# 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
ynh_systemd_action --service_name=php${phpversion}-fpm --action=reload
ynh_systemctl --service=php${php_version}-fpm --action=reload
fi
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemctl --service=nginx --action=reload
#=================================================
# 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
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
ynh_app_setting_set_default --key=php_upload_max_filesize --value=500M
#=================================================
# 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 [ -z "${database:-}" ]; then
@ -27,63 +17,66 @@ if [ -z "${database:-}" ]; then
else
database="none"
fi
ynh_app_setting_set --app=$app --key=database --value=$database
ynh_app_setting_delete --app=$app --key=with_mysql
ynh_app_setting_set --key=database --value=$database
ynh_app_setting_delete --key=with_mysql
fi
# If admin_mail_html doesn't exist, create it
# FIXMEhelpers2.1: 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 --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
#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | ynh_app_setting_set --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
#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | ynh_app_setting_set --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
#REMOVEME? Everything about fpm_usage is removed in helpers2.1... | ynh_app_setting_set --key=fpm_usage --value=$fpm_usage
fi
# If with_sftp doesn't exist, create it
# FIXMEhelpers2.1: 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 --app=$app --key=with_sftp --value=$with_sftp
ynh_app_setting_set --key=with_sftp --value=$with_sftp
fi
# 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
# 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
fi
# If custom_error_file doesn't exist, create it.
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=custom_error_file --value=0
if [ -z "${custom_error_file:-}" ]; then
custom_error_file=0
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
# Delete old user
if [ -n "$(ynh_app_setting_get --app=$app --key=user)" ]
if [ -n "$(ynh_app_setting_get --key=user)" ]
then
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
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
fi
# 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
@ -94,7 +87,7 @@ ynh_maintenance_mode_ON
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
ynh_script_progression "Upgrading NGINX web server configuration..."
# Prepare nginx.conf
nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d"
@ -102,26 +95,26 @@ nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d"
mkdir -p "$nginx_extra_conf_dir"
# Prepare nginx extra conf
if [ $phpversion != "none" ]
if [ $php_version != "none" ]
then
ynh_add_config --template="nginx-php.conf" --destination="$nginx_extra_conf_dir/php.conf"
YNH_PHP_VERSION="$phpversion"
ynh_config_add --template="nginx-php.conf" --destination="$nginx_extra_conf_dir/php.conf"
YNH_PHP_VERSION="$php_version"
fi
# Add the config error code
if [ $custom_error_file -eq 1 ]
then
ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf"
ynh_config_add --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf"
fi
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_add_config --template="example-custom-nginx-config.conf" --destination="$nginx_extra_conf_dir/sample.conf"
ynh_config_add_nginx
ynh_config_add --template="example-custom-nginx-config.conf" --destination="$nginx_extra_conf_dir/sample.conf"
#=================================================
# 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 ]
then
@ -146,28 +139,25 @@ usermod -g "$app" "$app"
# PHP-FPM CONFIGURATION
#=================================================
if [ $phpversion != "none" ]
if [ $php_version != "none" ]
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_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --phpversion=$phpversion
ynh_config_add_phpfpm
fi
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
chown -R $app:www-data "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
# Home directory of the user needs to be owned by root to allow
# SFTP connections
chown root:root "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown root:root "$install_dir"
setfacl -m g:$app:r-x "$install_dir"
setfacl -m g:www-data:r-x "$install_dir"
chmod 750 "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
#=================================================
# DEACTIVE MAINTENANCE MODE
#=================================================
@ -178,4 +168,4 @@ ynh_maintenance_mode_OFF
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed" --last
ynh_script_progression "Upgrade of $app completed"