From dcc5a94d57fd898536badaab3de65062d44eed8b Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 01:14:13 +0200 Subject: [PATCH 001/207] try to update source to 0.9.5 --- conf/app.src | 4 ++-- manifest.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/conf/app.src b/conf/app.src index 3704ec4..e58db5a 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-0.9.2.tar.bz2 -SOURCE_SUM=d0a95b0aea2b2001dcd30088f6ebddf65f7a4fce5db2aaa3359c3692b1ded0e9 +SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-0.9.5.tar.bz2 +SOURCE_SUM=48f8d62d8c86b3aef2d090b2a7d04873c9642d6efc451389f58a5d6e89d89612 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.bz2 SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index fe81f6c..c4b3781 100644 --- a/manifest.json +++ b/manifest.json @@ -9,7 +9,7 @@ "en": "Software to manage association", "fr": "Logiciel libre de gestion d'association" }, - "version": "0.9.2~ynh1", + "version": "0.9.5~ynh1", "url": "http://garradin.eu/a-propos/", "license": "GPL-3.0-or-later", "maintainer": { @@ -19,7 +19,7 @@ "multi_instance": true, "services": [ "nginx", - "php5-fpm" + "php7.0-fpm" ], "arguments": { "install" : [ From 4e92de26e696904554ba58d9925ce1af3dab416d Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 02:03:44 +0200 Subject: [PATCH 002/207] try to update source to 0.9.5 --- conf/php-fpm.conf | 30 +++++++++++++++--------------- manifest.json | 2 +- scripts/backup | 6 +++--- scripts/install | 4 ++-- scripts/restore | 14 +++++++------- scripts/upgrade | 4 ++-- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 8affbc2..9f3942f 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -30,7 +30,7 @@ group = __USER__ ; specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. -listen = /var/run/php5-fpm-__NAMETOCHANGE__.sock +listen = /var/run/php7.2-fpm-__NAMETOCHANGE__.sock ; Set listen(2) backlog. A value of '-1' means unlimited. ; Default Value: 128 (-1 on FreeBSD and OpenBSD) @@ -38,13 +38,13 @@ listen = /var/run/php5-fpm-__NAMETOCHANGE__.sock ; Set permissions for unix socket, if one is used. In Linux, read/write ; permissions must be set in order to allow connections from a web server. Many -; BSD-derived systems allow connections regardless of permissions. +; BSD-derived systems allow connections regardless of permissions. ; Default Values: user and group are set as the running user ; mode is set to 0660 listen.owner = www-data listen.group = www-data ;listen.mode = 0660 - + ; List of ipv4 addresses of FastCGI clients which are allowed to connect. ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address @@ -117,7 +117,7 @@ pm.max_spare_servers = 3 ; Note: Used only when pm is set to 'ondemand' ; Default Value: 10s ;pm.process_idle_timeout = 10s; - + ; The number of requests each child process should execute before respawning. ; This can be useful to work around memory leaks in 3rd party libraries. For ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. @@ -170,7 +170,7 @@ pm.max_requests = 500 ; ; By default the status page only outputs short status. Passing 'full' in the ; query string will also return status for each pool process. -; Example: +; Example: ; http://www.foo.bar/status?full ; http://www.foo.bar/status?json&full ; http://www.foo.bar/status?html&full @@ -283,7 +283,7 @@ pm.max_requests = 500 ; - .... ; %p: PID of the child that serviced the request ; %P: PID of the parent of the child that serviced the request -; %q: the query string +; %q: the query string ; %Q: the '?' character if query string exists ; %r: the request URI (without the query string, see %q and %Q) ; %R: remote IP address @@ -298,40 +298,40 @@ pm.max_requests = 500 ; ; Default: "%R - %u %t \"%m %r\" %s" ;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" - + ; The log file for slow requests ; Default Value: not set ; Note: slowlog is mandatory if request_slowlog_timeout is set slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log - + ; The timeout for serving a single request after which a PHP backtrace will be ; dumped to the 'slowlog' file. A value of '0s' means 'off'. ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) ; Default Value: 0 request_slowlog_timeout = 5s - + ; The timeout for serving a single request after which the worker process will ; be killed. This option should be used when the 'max_execution_time' ini option ; does not stop script execution for some reason. A value of '0' means 'off'. ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) ; Default Value: 0 request_terminate_timeout = 1d - + ; Set open file descriptor rlimit. ; Default Value: system defined value ;rlimit_files = 1024 - + ; Set max core size rlimit. ; Possible Values: 'unlimited' or an integer greater or equal to 0 ; Default Value: system defined value ;rlimit_core = 0 - + ; Chroot to this directory at the start. This value must be defined as an ; absolute path. When this value is not set, chroot is not used. ; Note: you can prefix with '$prefix' to chroot to the pool prefix or one ; of its subdirectories. If the pool prefix is not set, the global prefix ; will be used instead. -; Note: chrooting is a great security feature and should be used whenever +; Note: chrooting is a great security feature and should be used whenever ; possible. However, all PHP paths will be relative to the chroot ; (error_log, sessions.save_path, ...). ; Default Value: not set @@ -356,7 +356,7 @@ catch_workers_output = yes ; Note: set an empty value to allow all extensions. ; Default Value: .php ;security.limit_extensions = .php .php3 .php4 .php5 - + ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from ; the current environment. ; Default Value: clean env @@ -370,7 +370,7 @@ catch_workers_output = yes ; overwrite the values previously defined in the php.ini. The directives are the ; same as the PHP SAPI: ; php_value/php_flag - you can set classic ini defines which can -; be overwritten from PHP call 'ini_set'. +; be overwritten from PHP call 'ini_set'. ; php_admin_value/php_admin_flag - these directives won't be overwritten by ; PHP call 'ini_set' ; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. diff --git a/manifest.json b/manifest.json index c4b3781..9912a59 100644 --- a/manifest.json +++ b/manifest.json @@ -19,7 +19,7 @@ "multi_instance": true, "services": [ "nginx", - "php7.0-fpm" + "php7.2-fpm" ], "arguments": { "install" : [ diff --git a/scripts/backup b/scripts/backup index 7b2dac6..63031a1 100644 --- a/scripts/backup +++ b/scripts/backup @@ -48,10 +48,10 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_backup "/etc/php5/fpm/pool.d/$app.conf" -ynh_backup "/etc/php5/fpm/conf.d/20-$app.ini" +ynh_backup "/etc/php7.2/fpm/pool.d/$app.conf" +ynh_backup "/etc/php7.2/fpm/conf.d/20-$app.ini" -# Backup directory location for the app from where the script is executed and +# Backup directory location for the app from where the script is executed and # which will be compressed afterward backup_dir=$YNH_APP_BACKUP_DIR diff --git a/scripts/install b/scripts/install index 908093e..379791b 100644 --- a/scripts/install +++ b/scripts/install @@ -53,9 +53,9 @@ ynh_app_setting_set $app is_public $is_public # Install dependency to convert tracks to a readable format for the browser #================================================= -if [ "$(lsb_release --codename --short)" != "jessie" ] +if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_install_app_dependencies php-sqlite3 + ynh_install_app_dependencies php7.2-sqlite3 else ynh_install_app_dependencies php5-sqlite fi diff --git a/scripts/restore b/scripts/restore index 043dfe2..68bdcf8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -71,10 +71,10 @@ chown -R $app:$app $final_path #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= -if [ "$(lsb_release --codename --short)" != "jessie" ] +if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf" - ynh_restore_file "/etc/php/7.0/fpm/conf.d/20-$app.ini" + ynh_restore_file "/etc/php/7.2/fpm/pool.d/$app.conf" + ynh_restore_file "/etc/php/7.2/fpm/conf.d/20-$app.ini" else ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf" ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini" @@ -86,9 +86,9 @@ fi # REINSTALL DEPENDENCIES #================================================= -if [ "$(lsb_release --codename --short)" != "jessie" ] +if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_install_app_dependencies php7.0-sqlite3 + ynh_install_app_dependencies php7.2-sqlite3 else ynh_install_app_dependencies php5-sqlite fi @@ -98,9 +98,9 @@ fi #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -if [ "$(lsb_release --codename --short)" != "jessie" ] +if [ "$(lsb_release --codename --short)" != "jessie" ] then - systemctl reload php7.0-fpm + systemctl reload php7.2-fpm else systemctl reload php5-fpm fi diff --git a/scripts/upgrade b/scripts/upgrade index 8490bf5..f9c7584 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -55,9 +55,9 @@ ynh_abort_if_errors # Install dependency to convert tracks to a readable format for the browser #================================================= -if [ "$(lsb_release --codename --short)" != "jessie" ] +if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_install_app_dependencies php-sqlite3 + ynh_install_app_dependencies php7.2-sqlite3 else ynh_install_app_dependencies php5-sqlite fi From 0297926dccbb3a5759680ed830c41044f913c2d0 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 17:43:53 +0200 Subject: [PATCH 003/207] refactoring and try to update version --- scripts/_common.sh | 602 ++++++++++++++++++++++++++++++++++++ scripts/_ynh_add_fpm_config | 146 +++++++++ scripts/backup | 71 +++-- scripts/config | 97 ++++++ scripts/install | 46 ++- scripts/remove | 15 +- scripts/restore | 78 ++++- 7 files changed, 1008 insertions(+), 47 deletions(-) create mode 100644 scripts/_ynh_add_fpm_config create mode 100644 scripts/config diff --git a/scripts/_common.sh b/scripts/_common.sh index 24bd7ba..fe27b7a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,7 +7,609 @@ # # usage: ynh_remove_file_checksum file # | arg: file - The file for which the checksum will be deleted +# Install another version of php. +# +# usage: ynh_install_php --phpversion=phpversion [--package=packages] +# | arg: -v, --phpversion - Version of php to install. +# | arg: -p, --package - Additionnal php packages to install + +#================================================= +# COMMON VARIABLES +#================================================= + +YNH_PHP_VERSION="7.2" +extra_pkg_dependencies="php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-redis php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-sqlite3" + + +# Remove the specific version of php used by the app. +# +# usage: ynh_install_php +ynh_remove_php () { + # Get the version of php used by this app + local phpversion=$(ynh_app_setting_get $app phpversion) + + if [ "$phpversion" == "7.0" ] || [ -z "$phpversion" ] + then + if [ "$phpversion" == "7.0" ] + then + ynh_print_err "Do not use ynh_remove_php to install php7.0" + fi + return 0 + fi + + # Remove the line for this app + sed --in-place "/$YNH_APP_INSTANCE_NAME:$phpversion/d" "/etc/php/ynh_app_version" + + # If no other app uses this version of php, remove it. + if ! grep --quiet "$phpversion" "/etc/php/ynh_app_version" + then + # Purge php dependences for this version. + ynh_package_autopurge "php$phpversion php${phpversion}-fpm php${phpversion}-common" + # Remove the service from the admin panel + yunohost service remove php${phpversion}-fpm + fi + + # If no other app uses alternate php versions, remove the extra repo for php + if [ ! -s "/etc/php/ynh_app_version" ] + then + ynh_secure_remove /etc/php/ynh_app_version + fi +} ynh_delete_file_checksum () { local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' ynh_app_setting_delete $app $checksum_setting_name } + + #================================================= + # CHANGE THE FAKE DEPENDENCIES PACKAGE + #================================================= + + # Check if a variable $pkg_dependencies exists + # If this variable doesn't exist, this part shall be managed in the upgrade script. + if [ -n "${pkg_dependencies:-}" ] + then + # Define the name of the package + local old_package_name="${old_app//_/-}-ynh-deps" + local new_package_name="${new_app//_/-}-ynh-deps" + + if ynh_package_is_installed "$old_package_name" + then + # Install a new fake package + app=$new_app + ynh_install_app_dependencies $pkg_dependencies + # Then remove the old one + app=$old_app + ynh_remove_app_dependencies + fi + fi + + # Define the values to configure php-fpm +# +# usage: ynh_get_scalable_phpfpm --usage=usage --footprint=footprint [--print] +# | arg: -f, --footprint - Memory footprint of the service (low/medium/high). +# low - Less than 20Mb of ram by pool. +# medium - Between 20Mb and 40Mb of ram by pool. +# high - More than 40Mb of ram by pool. +# Or specify exactly the footprint, the load of the service as Mb by pool instead of having a standard value. +# To have this value, use the following command and stress the service. +# watch -n0.5 ps -o user,cmd,%cpu,rss -u APP +# +# | arg: -u, --usage - Expected usage of the service (low/medium/high). +# low - Personal usage, behind the sso. +# medium - Low usage, few people or/and publicly accessible. +# high - High usage, frequently visited website. +# +# | arg: -p, --print - Print the result +# +# +# +# The footprint of the service will be used to defined the maximum footprint we can allow, which is half the maximum RAM. +# So it will be used to defined 'pm.max_children' +# A lower value for the footprint will allow more children for 'pm.max_children'. And so for +# 'pm.start_servers', 'pm.min_spare_servers' and 'pm.max_spare_servers' which are defined from the +# value of 'pm.max_children' +# NOTE: 'pm.max_children' can't exceed 4 times the number of processor's cores. +# +# The usage value will defined the way php will handle the children for the pool. +# A value set as 'low' will set the process manager to 'ondemand'. Children will start only if the +# service is used, otherwise no child will stay alive. This config gives the lower footprint when the +# service is idle. But will use more proc since it has to start a child as soon it's used. +# Set as 'medium', the process manager will be at dynamic. If the service is idle, a number of children +# equal to pm.min_spare_servers will stay alive. So the service can be quick to answer to any request. +# The number of children can grow if needed. The footprint can stay low if the service is idle, but +# not null. The impact on the proc is a little bit less than 'ondemand' as there's always a few +# children already available. +# Set as 'high', the process manager will be set at 'static'. There will be always as many children as +# 'pm.max_children', the footprint is important (but will be set as maximum a quarter of the maximum +# RAM) but the impact on the proc is lower. The service will be quick to answer as there's always many +# children ready to answer. +ynh_get_scalable_phpfpm () { + local legacy_args=ufp + # Declare an array to define the options of this helper. + declare -Ar args_array=( [u]=usage= [f]=footprint= [p]=print ) + local usage + local footprint + local print + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + # Set all characters as lowercase + footprint=${footprint,,} + usage=${usage,,} + print=${print:-0} + + if [ "$footprint" = "low" ] + then + footprint=20 + elif [ "$footprint" = "medium" ] + then + footprint=35 + elif [ "$footprint" = "high" ] + then + footprint=50 + fi + + # Define the way the process manager handle child processes. + if [ "$usage" = "low" ] + then + php_pm=ondemand + elif [ "$usage" = "medium" ] + then + php_pm=dynamic + elif [ "$usage" = "high" ] + then + php_pm=static + else + ynh_die --message="Does not recognize '$usage' as an usage value." + fi + + # Get the total of RAM available, except swap. + local max_ram=$(ynh_check_ram --no_swap) + + less0() { + # Do not allow value below 1 + if [ $1 -le 0 ] + then + echo 1 + else + echo $1 + fi + } + + # Define pm.max_children + # The value of pm.max_children is the total amount of ram divide by 2 and divide again by the footprint of a pool for this app. + # So if php-fpm start the maximum of children, it won't exceed half of the ram. + php_max_children=$(( $max_ram / 2 / $footprint )) + # If process manager is set as static, use half less children. + # Used as static, there's always as many children as the value of pm.max_children + if [ "$php_pm" = "static" ] + then + php_max_children=$(( $php_max_children / 2 )) + fi + php_max_children=$(less0 $php_max_children) + + # To not overload the proc, limit the number of children to 4 times the number of cores. + local core_number=$(nproc) + local max_proc=$(( $core_number * 4 )) + if [ $php_max_children -gt $max_proc ] + then + php_max_children=$max_proc + fi + + if [ "$php_pm" = "dynamic" ] + then + # Define pm.start_servers, pm.min_spare_servers and pm.max_spare_servers for a dynamic process manager + php_min_spare_servers=$(( $php_max_children / 8 )) + php_min_spare_servers=$(less0 $php_min_spare_servers) + + php_max_spare_servers=$(( $php_max_children / 2 )) + php_max_spare_servers=$(less0 $php_max_spare_servers) + + php_start_servers=$(( $php_min_spare_servers + ( $php_max_spare_servers - $php_min_spare_servers ) /2 )) + php_start_servers=$(less0 $php_start_servers) + else + php_min_spare_servers=0 + php_max_spare_servers=0 + php_start_servers=0 + fi + + if [ $print -eq 1 ] + then + ynh_debug --message="Footprint=${footprint}Mb by pool." + ynh_debug --message="Process manager=$php_pm" + ynh_debug --message="Max RAM=${max_ram}Mb" + if [ "$php_pm" != "static" ]; then + ynh_debug --message="\nMax estimated footprint=$(( $php_max_children * $footprint ))" + ynh_debug --message="Min estimated footprint=$(( $php_min_spare_servers * $footprint ))" + fi + if [ "$php_pm" = "dynamic" ]; then + ynh_debug --message="Estimated average footprint=$(( $php_max_spare_servers * $footprint ))" + elif [ "$php_pm" = "static" ]; then + ynh_debug --message="Estimated footprint=$(( $php_max_children * $footprint ))" + fi + ynh_debug --message="\nRaw php-fpm values:" + ynh_debug --message="pm.max_children = $php_max_children" + if [ "$php_pm" = "dynamic" ]; then + ynh_debug --message="pm.start_servers = $php_start_servers" + ynh_debug --message="pm.min_spare_servers = $php_min_spare_servers" + ynh_debug --message="pm.max_spare_servers = $php_max_spare_servers" + fi + fi +} + +# Install another version of php. +# +# usage: ynh_install_php --phpversion=phpversion [--package=packages] +# | arg: -v, --phpversion - Version of php to install. +# | arg: -p, --package - Additionnal php packages to install +ynh_install_php () { + # Declare an array to define the options of this helper. + local legacy_args=vp + declare -Ar args_array=( [v]=phpversion= [p]=package= ) + local phpversion + local package + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + package=${package:-} + + # Store phpversion into the config of this app + ynh_app_setting_set $app phpversion $phpversion + + if [ "$phpversion" == "7.0" ] + then + ynh_die "Do not use ynh_install_php to install php7.0" + fi + + # Store the ID of this app and the version of php requested for it + echo "$YNH_APP_INSTANCE_NAME:$phpversion" | tee --append "/etc/php/ynh_app_version" + + # Add an extra repository for those packages + ynh_install_extra_repo --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --priority=995 --name=extra_php_version + + # Install requested dependencies from this extra repository. + # Install php-fpm first, otherwise php will install apache as a dependency. + ynh_add_app_dependencies --package="php${phpversion}-fpm" + ynh_add_app_dependencies --package="php$phpversion php${phpversion}-common $package" + + # Set php7.0 back as the default version for php-cli. + update-alternatives --set php /usr/bin/php7.0 + + # Pin this extra repository after packages are installed to prevent sury of doing shit + ynh_pin_repo --package="*" --pin="origin \"packages.sury.org\"" --priority=200 --name=extra_php_version + ynh_pin_repo --package="php7.0*" --pin="origin \"packages.sury.org\"" --priority=600 --name=extra_php_version --append + + # Advertise service in admin panel + yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log" +} + +# Remove the specific version of php used by the app. +# +# usage: ynh_install_php +ynh_remove_php () { + # Get the version of php used by this app + local phpversion=$(ynh_app_setting_get $app phpversion) + + if [ "$phpversion" == "7.0" ] || [ -z "$phpversion" ] + then + if [ "$phpversion" == "7.0" ] + then + ynh_print_err "Do not use ynh_remove_php to install php7.0" + fi + return 0 + fi + + # Remove the line for this app + sed --in-place "/$YNH_APP_INSTANCE_NAME:$phpversion/d" "/etc/php/ynh_app_version" + + # If no other app uses this version of php, remove it. + if ! grep --quiet "$phpversion" "/etc/php/ynh_app_version" + then + # Purge php dependences for this version. + ynh_package_autopurge "php$phpversion php${phpversion}-fpm php${phpversion}-common" + # Remove the service from the admin panel + yunohost service remove php${phpversion}-fpm + fi + + # If no other app uses alternate php versions, remove the extra repo for php + if [ ! -s "/etc/php/ynh_app_version" ] + then + ynh_secure_remove /etc/php/ynh_app_version + fi +} + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= +# Pin a repository. +# +# usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append] +# | arg: -p, --package - Packages concerned by the pin. Or all, *. +# | arg: -i, --pin - Filter for the pin. +# | arg: -p, --priority - Priority for the pin +# | arg: -n, --name - Name for the files for this repo, $app as default value. +# | arg: -a, --append - Do not overwrite existing files. +# +# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning. +# +ynh_pin_repo () { + # Declare an array to define the options of this helper. + local legacy_args=pirna + declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append ) + local package + local pin + local priority + local name + local append + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + package="${package:-*}" + priority=${priority:-50} + name="${name:-$app}" + append=${append:-0} + + if [ $append -eq 1 ] + then + append="tee -a" + else + append="tee" + fi + + mkdir -p "/etc/apt/preferences.d" + echo "Package: $package +Pin: $pin +Pin-Priority: $priority +" \ + | $append "/etc/apt/preferences.d/$name" +} + +# Add a repository. +# +# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append] +# | arg: -u, --uri - Uri of the repository. +# | arg: -s, --suite - Suite of the repository. +# | arg: -c, --component - Component of the repository. +# | arg: -n, --name - Name for the files for this repo, $app as default value. +# | arg: -a, --append - Do not overwrite existing files. +# +# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable +# uri suite component +# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable +# +ynh_add_repo () { + # Declare an array to define the options of this helper. + local legacy_args=uscna + declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append ) + local uri + local suite + local component + local name + local append + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + append=${append:-0} + + if [ $append -eq 1 ] + then + append="tee -a" + else + append="tee" + fi + + mkdir -p "/etc/apt/sources.list.d" + # Add the new repo in sources.list.d + echo "deb $uri $suite $component" \ + | $append "/etc/apt/sources.list.d/$name.list" +} + +# Add an extra repository correctly, pin it and get the key. +# +# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append] +# | arg: -r, --repo - Complete url of the extra repository. +# | arg: -k, --key - url to get the public key. +# | arg: -p, --priority - Priority for the pin +# | arg: -n, --name - Name for the files for this repo, $app as default value. +# | arg: -a, --append - Do not overwrite existing files. +ynh_install_extra_repo () { + # Declare an array to define the options of this helper. + local legacy_args=rkpna + declare -Ar args_array=( [r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append ) + local repo + local key + local priority + local name + local append + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + append=${append:-0} + key=${key:-0} + priority=${priority:-} + + if [ $append -eq 1 ] + then + append="--append" + wget_append="tee -a" + else + append="" + wget_append="tee" + fi + + # Split the repository into uri, suite and components. + # Remove "deb " at the beginning of the repo. + repo="${repo#deb }" + + # Get the uri + local uri="$(echo "$repo" | awk '{ print $1 }')" + + # Get the suite + local suite="$(echo "$repo" | awk '{ print $2 }')" + + # Get the components + local component="${repo##$uri $suite }" + + # Add the repository into sources.list.d + ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append + + # Pin the new repo with the default priority, so it won't be used for upgrades. + # Build $pin from the uri without http and any sub path + local pin="${uri#*://}" + pin="${pin%%/*}" + # Set a priority only if asked + if [ -n "$priority" ] + then + priority="--priority=$priority" + fi + ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append + + # Get the public key for the repo + if [ -n "$key" ] + then + mkdir -p "/etc/apt/trusted.gpg.d" + wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null + fi + + # Update the list of package with the new repo + ynh_package_update +} + +# Remove an extra repository and the assiociated configuration. +# +# usage: ynh_remove_extra_repo [--name=name] +# | arg: -n, --name - Name for the files for this repo, $app as default value. +ynh_remove_extra_repo () { + # Declare an array to define the options of this helper. + local legacy_args=n + declare -Ar args_array=( [n]=name= ) + local name + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + + ynh_secure_remove "/etc/apt/sources.list.d/$name.list" + ynh_secure_remove "/etc/apt/preferences.d/$name" + ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg" + ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc" + + # Update the list of package to exclude the old repo + ynh_package_update +} + +# Install packages from an extra repository properly. +# +# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name] +# | arg: -r, --repo - Complete url of the extra repository. +# | arg: -p, --package - The packages to install from this extra repository +# | arg: -k, --key - url to get the public key. +# | arg: -n, --name - Name for the files for this repo, $app as default value. +ynh_install_extra_app_dependencies () { + # Declare an array to define the options of this helper. + local legacy_args=rpkn + declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= ) + local repo + local package + local key + local name + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + name="${name:-$app}" + key=${key:-0} + + # Set a key only if asked + if [ -n "$key" ] + then + key="--key=$key" + fi + # Add an extra repository for those packages + ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name + + # Install requested dependencies from this extra repository. + ynh_add_app_dependencies --package="$package" + + # Remove this extra repository after packages are installed + ynh_remove_extra_repo --name=$app +} + +#================================================= + +# patched version of ynh_install_app_dependencies to be used with ynh_add_app_dependencies + +# Define and install dependencies with a equivs control file +# This helper can/should only be called once per app +# +# usage: ynh_install_app_dependencies dep [dep [...]] +# | arg: dep - the package name to install in dependence +# You can give a choice between some package with this syntax : "dep1|dep2" +# Example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5" +# This mean in the dependence tree : dep1 & dep2 & (dep3 | dep4 | dep5) +# +# Requires YunoHost version 2.6.4 or higher. +ynh_install_app_dependencies () { + local dependencies=$@ + dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')" + dependencies=${dependencies//|/ | } + local manifest_path="../manifest.json" + if [ ! -e "$manifest_path" ]; then + manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place + fi + + local version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file. + if [ ${#version} -eq 0 ]; then + version="1.0" + fi + local dep_app=${app//_/-} # Replace all '_' by '-' + + # Handle specific versions + if [[ "$dependencies" =~ [\<=\>] ]] + then + # Replace version specifications by relationships syntax + # https://www.debian.org/doc/debian-policy/ch-relationships.html + # Sed clarification + # [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice. + # [\<=\>] matches < = or > + # \+ matches one or more occurence of the previous characters, for >= or >>. + # [^,]\+ matches all characters except ',' + # Ex: package>=1.0 will be replaced by package (>= 1.0) + dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')" + fi + + cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build +Section: misc +Priority: optional +Package: ${dep_app}-ynh-deps +Version: ${version} +Depends: ${dependencies} +Architecture: all +Description: Fake package for $app (YunoHost app) dependencies + This meta-package is only responsible of installing its dependencies. +EOF + ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \ + || ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies + rm /tmp/${dep_app}-ynh-deps.control + ynh_app_setting_set --app=$app --key=apt_dependencies --value="$dependencies" +} + +ynh_add_app_dependencies () { + # Declare an array to define the options of this helper. + local legacy_args=pr + declare -Ar args_array=( [p]=package= [r]=replace) + local package + local replace + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + replace=${replace:-0} + + local current_dependencies="" + if [ $replace -eq 0 ] + then + local dep_app=${app//_/-} # Replace all '_' by '-' + if ynh_package_is_installed --package="${dep_app}-ynh-deps" + then + current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) " + fi + + current_dependencies=${current_dependencies// | /|} + fi + + ynh_install_app_dependencies "${current_dependencies}${package}" +} + diff --git a/scripts/_ynh_add_fpm_config b/scripts/_ynh_add_fpm_config new file mode 100644 index 0000000..69c3db4 --- /dev/null +++ b/scripts/_ynh_add_fpm_config @@ -0,0 +1,146 @@ +#!/bin/bash + +# Create a dedicated php-fpm config +# +# usage 1: ynh_add_fpm_config [--phpversion=7.X] [--use_template] +# | arg: -v, --phpversion - Version of php to use. +# | arg: -t, --use_template - Use this helper in template mode. +# +# ----------------------------------------------------------------------------- +# +# usage 2: ynh_add_fpm_config [--phpversion=7.X] --usage=usage --footprint=footprint +# | arg: -v, --phpversion - Version of php to use.# +# | arg: -f, --footprint - Memory footprint of the service (low/medium/high). +# low - Less than 20Mb of ram by pool. +# medium - Between 20Mb and 40Mb of ram by pool. +# high - More than 40Mb of ram by pool. +# Or specify exactly the footprint, the load of the service as Mb by pool instead of having a standard value. +# To have this value, use the following command and stress the service. +# watch -n0.5 ps -o user,cmd,%cpu,rss -u APP +# +# | arg: -u, --usage - Expected usage of the service (low/medium/high). +# low - Personal usage, behind the sso. +# medium - Low usage, few people or/and publicly accessible. +# high - High usage, frequently visited website. +# +# Requires YunoHost version 2.7.2 or higher. +ynh_add_fpm_config () { + # Declare an array to define the options of this helper. + local legacy_args=vtuf + declare -Ar args_array=( [v]=phpversion= [t]=use_template [u]=usage= [f]=footprint= ) + local phpversion + local use_template + local usage + local footprint + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + # The default behaviour is to use the template. + use_template="${use_template:-1}" + usage="${usage:-}" + footprint="${footprint:-}" + if [ -n "$usage" ] || [ -n "$footprint" ]; then + use_template=0 + fi + + # Configure PHP-FPM 7.0 by default + phpversion="${phpversion:-$YNH_PHP_VERSION}" + + local fpm_config_dir="/etc/php/$phpversion/fpm" + local fpm_service="php${phpversion}-fpm" + # Configure PHP-FPM 5 on Debian Jessie + if [ "$(ynh_get_debian_release)" == "jessie" ]; then + fpm_config_dir="/etc/php5/fpm" + fpm_service="php5-fpm" + fi + ynh_app_setting_set --app=$app --key=fpm_config_dir --value="$fpm_config_dir" + ynh_app_setting_set --app=$app --key=fpm_service --value="$fpm_service" + finalphpconf="$fpm_config_dir/pool.d/$app.conf" + ynh_backup_if_checksum_is_different --file="$finalphpconf" + + if [ $use_template -eq 1 ] + then + # Usage 1, use the template in ../conf/php-fpm.conf + sudo cp ../conf/php-fpm.conf "$finalphpconf" + ynh_replace_string --match_string="__NAMETOCHANGE__" --replace_string="$app" --target_file="$finalphpconf" + ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$finalphpconf" + ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="$finalphpconf" + ynh_replace_string --match_string="__PHPVERSION__" --replace_string="$phpversion" --target_file="$finalphpconf" + + else + # Usage 2, generate a php-fpm config file with ynh_get_scalable_phpfpm + ynh_get_scalable_phpfpm --usage=$usage --footprint=$footprint + + # Copy the default file + sudo cp "$fpm_config_dir/pool.d/www.conf" "$finalphpconf" + + # Replace standard variables into the default file + ynh_replace_string --match_string="^\[www\]" --replace_string="[$app]" --target_file="$finalphpconf" + ynh_replace_string --match_string=".*listen = .*" --replace_string="listen = /var/run/php/php$phpversion-fpm-$app.sock" --target_file="$finalphpconf" + ynh_replace_string --match_string="^user = .*" --replace_string="user = $app" --target_file="$finalphpconf" + ynh_replace_string --match_string="^group = .*" --replace_string="group = $app" --target_file="$finalphpconf" + ynh_replace_string --match_string=".*chdir = .*" --replace_string="chdir = $final_path" --target_file="$finalphpconf" + + # Configure fpm children + ynh_replace_string --match_string=".*pm = .*" --replace_string="pm = $php_pm" --target_file="$finalphpconf" + ynh_replace_string --match_string=".*pm.max_children = .*" --replace_string="pm.max_children = $php_max_children" --target_file="$finalphpconf" + ynh_replace_string --match_string=".*pm.max_requests = .*" --replace_string="pm.max_requests = 500" --target_file="$finalphpconf" + ynh_replace_string --match_string=".*request_terminate_timeout = .*" --replace_string="request_terminate_timeout = 1d" --target_file="$finalphpconf" + if [ "$php_pm" = "dynamic" ] + then + ynh_replace_string --match_string=".*pm.start_servers = .*" --replace_string="pm.start_servers = $php_start_servers" --target_file="$finalphpconf" + ynh_replace_string --match_string=".*pm.min_spare_servers = .*" --replace_string="pm.min_spare_servers = $php_min_spare_servers" --target_file="$finalphpconf" + ynh_replace_string --match_string=".*pm.max_spare_servers = .*" --replace_string="pm.max_spare_servers = $php_max_spare_servers" --target_file="$finalphpconf" + elif [ "$php_pm" = "ondemand" ] + then + ynh_replace_string --match_string=".*pm.process_idle_timeout = .*" --replace_string="pm.process_idle_timeout = 10s" --target_file="$finalphpconf" + fi + + # Comment unused parameters + if [ "$php_pm" != "dynamic" ] + then + ynh_replace_string --match_string=".*\(pm.start_servers = .*\)" --replace_string=";\1" --target_file="$finalphpconf" + ynh_replace_string --match_string=".*\(pm.min_spare_servers = .*\)" --replace_string=";\1" --target_file="$finalphpconf" + ynh_replace_string --match_string=".*\(pm.max_spare_servers = .*\)" --replace_string=";\1" --target_file="$finalphpconf" + fi + if [ "$php_pm" != "ondemand" ] + then + ynh_replace_string --match_string=".*\(pm.process_idle_timeout = .*\)" --replace_string=";\1" --target_file="$finalphpconf" + fi + + # Concatene the extra config. + if [ -e ../conf/extra_php-fpm.conf ]; then + cat ../conf/extra_php-fpm.conf >> "$finalphpconf" + fi + fi + sudo chown root: "$finalphpconf" + ynh_store_file_checksum --file="$finalphpconf" + + if [ -e "../conf/php-fpm.ini" ] + then + echo "Packagers ! Please do not use a separate php ini file, merge your directives in the pool file instead." >&2 + finalphpini="$fpm_config_dir/conf.d/20-$app.ini" + ynh_backup_if_checksum_is_different "$finalphpini" + sudo cp ../conf/php-fpm.ini "$finalphpini" + sudo chown root: "$finalphpini" + ynh_store_file_checksum "$finalphpini" + fi + ynh_systemd_action --service_name=$fpm_service --action=reload + + # Clean other php version config files for this app. Used for migration purpose. + if [ -e "/etc/php5/fpm/pool.d/$app.conf" ] + then + ynh_secure_remove --file="/etc/php5/fpm/pool.d/$app.conf" + ynh_systemd_action --service_name=php5-fpm --action=reload + fi + for i in `seq 0 4` + do + if [ "$phpversion" != "7.$i" ] + then + if [ -e "/etc/php/7.$i/fpm/pool.d/$app.conf" ] + then + ynh_secure_remove --file="/etc/php/7.$i/fpm/pool.d/$app.conf" + ynh_systemd_action --service_name=php7.$i-fpm --action=reload + fi + fi + done +} \ No newline at end of file diff --git a/scripts/backup b/scripts/backup index 63031a1..df35941 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,12 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Get the _common.sh file if it's not in the current directory - cp ../settings/scripts/_common.sh ./_common.sh - chmod a+rx _common.sh -fi -source _common.sh +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= @@ -24,40 +19,76 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get $app final_path) -domain=$(ynh_app_setting_get $app domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # STANDARD BACKUP STEPS #================================================= # BACKUP THE APP MAIN DIR #================================================= +ynh_script_progression --message="Backing up the main app directory..." -ynh_backup "$final_path" +ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Backing up nginx web server configuration..." -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Backing up php-fpm configuration..." -ynh_backup "/etc/php7.2/fpm/pool.d/$app.conf" -ynh_backup "/etc/php7.2/fpm/conf.d/20-$app.ini" +ynh_backup --src_path="/etc/php/$YNH_PHP_VERSION/fpm/pool.d/$app.conf" -# Backup directory location for the app from where the script is executed and -# which will be compressed afterward -backup_dir=$YNH_APP_BACKUP_DIR +#================================================= +# BACKUP THE MYSQL DATABASE +#================================================= +ynh_script_progression --message="Backing up the MySQL database..." --weight=2 -# Backup sources & data -ynh_backup "/var/www/$app" "sources" +ynh_mysql_dump_db --database="$db_name" > db.sql -# Copy Nginx conf -sudo mkdir -p ./conf -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "conf/nginx.conf" +#================================================= +# SPECIFIC BACKUP +#================================================= +# BACKUP LOGROTATE +#================================================= +ynh_script_progression --message="Backing up logrotate configuration..." + +ynh_backup "/etc/logrotate.d/$app" + +#================================================= +# BACKUP FAIL2BAN CONFIGURATION +#================================================= +ynh_script_progression --message="Backing up fail2ban configuration..." + +ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" +ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" + +#================================================= +# BACKUP THE CRON FILE +#================================================= + +ynh_backup --src_path="/etc/cron.d/$app" + +#================================================= +# BACKUP THE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Backing up data directory..." + +ynh_backup --src_path="/home/yunohost.app/${app}/data" --is_big + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last \ No newline at end of file diff --git a/scripts/config b/scripts/config new file mode 100644 index 0000000..50ae8b1 --- /dev/null +++ b/scripts/config @@ -0,0 +1,97 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers +source _ynh_add_fpm_config + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} + +#================================================= +# LOAD VALUES +#================================================= + +# Load the real value from the app config or elsewhere. +# Then get the value from the form. +# If the form has a value for a variable, take the value from the form, +# Otherwise, keep the value from the app config. + +# Footprint for php-fpm +old_fpm_footprint="$(ynh_app_setting_get --app=$app --key=fpm_footprint)" +fpm_footprint="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FOOTPRINT:-$old_fpm_footprint}" + +# Free footprint value for php-fpm +# Check if fpm_footprint is an integer +if [ "$fpm_footprint" -eq "$fpm_footprint" ] 2> /dev/null +then + # If fpm_footprint is an integer, that's a numeric value for the footprint + old_free_footprint=$fpm_footprint + fpm_footprint=specific +else + old_free_footprint=0 +fi +free_footprint="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT:-$old_free_footprint}" + +# Usage for php-fpm +old_fpm_usage="$(ynh_app_setting_get --app=$app --key=fpm_usage)" +fpm_usage="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE:-$old_fpm_usage}" + +#================================================= +# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND +#================================================= + +show_config() { + # here you are supposed to read some config file/database/other then print the values + # ynh_return "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value" + + ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FOOTPRINT=$fpm_footprint" + ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT=$free_footprint" + ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE=$fpm_usage" +} + +#================================================= +# MODIFY THE CONFIGURATION +#================================================= + +apply_config() { + + #================================================= + # RECONFIGURE PHP-FPM + #================================================= + + if [ "$fpm_usage" != "$old_fpm_usage" ] || [ "$fpm_footprint" != "$old_fpm_footprint" ] || [ "$free_footprint" != "$old_free_footprint" ] + then + # If fpm_footprint is set to 'specific', use $free_footprint value. + if [ "$fpm_footprint" = "specific" ] + then + fpm_footprint=$free_footprint + fi + + if [ "$fpm_footprint" != "0" ] + then + ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint + else + ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below." + fi + fi +} + +#================================================= +# GENERIC FINALIZATION +#================================================= +# SELECT THE ACTION FOLLOWING THE GIVEN ARGUMENT +#================================================= + +case $1 in + show) show_config;; + apply) apply_config;; +esac \ No newline at end of file diff --git a/scripts/install b/scripts/install index 379791b..392fe61 100644 --- a/scripts/install +++ b/scripts/install @@ -8,6 +8,7 @@ source _common.sh source /usr/share/yunohost/helpers +source _ynh_add_fpm_config #================================================= # MANAGE SCRIPT FAILURE @@ -30,6 +31,8 @@ app=$YNH_APP_INSTANCE_NAME # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +ynh_script_progression --message="Validating installation parameters..." + final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -52,13 +55,20 @@ ynh_app_setting_set $app is_public $is_public #================================================= # Install dependency to convert tracks to a readable format for the browser #================================================= +ynh_script_progression --message="Installing dependencies..." --weight=60 -if [ "$(lsb_release --codename --short)" != "jessie" ] -then - ynh_install_app_dependencies php7.2-sqlite3 -else - ynh_install_app_dependencies php5-sqlite -fi +ynh_install_app_dependencies $pkg_dependencies + +ynh_install_php --phpversion="$YNH_PHP_VERSION" --package="$extra_pkg_dependencies" + +#================================================= +# CREATE A MYSQL DATABASE +#================================================= +ynh_script_progression --message="Creating a MySQL database..." --weight=2 + +db_name=$(ynh_sanitize_dbid --db_name=$app) +ynh_app_setting_set --app=$app --key=db_name --value=$db_name +ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name #================================================= # CREATE DEDICATED USER @@ -87,18 +97,28 @@ sudo chmod 755 $final_path -R #================================================= # Create a dedicated nginx config -ynh_add_nginx_config +ynh_add_nginx_config YNH_PHP_VERSION #================================================= # PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Configuring php-fpm..." --weight=2 # Create a dedicated php-fpm config -ynh_add_fpm_config +ynh_add_fpm_config --usage=medium --footprint=high + +#================================================= +# STORE THE CHECKSUM OF THE CONFIG FILE +#================================================= + +# Calculate and store the config file checksum into the app settings +ynh_store_file_checksum --file="$final_path/config/config.php" #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Configuring SSOwat..." + if [ $is_public -eq 0 ] then # Remove the public access @@ -115,4 +135,12 @@ fi # RELOAD NGINX #================================================= -systemctl reload nginx +ynh_script_progression --message="Reloading nginx web server..." + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 537c7fc..386b677 100644 --- a/scripts/remove +++ b/scripts/remove @@ -13,15 +13,19 @@ source /usr/share/yunohost/helpers # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading installation settings..." --weight=2 + app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # REMOVE DEPENDENCIES #================================================= +ynh_script_progression --message="Removing logrotate configuration..." # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -51,6 +55,13 @@ ynh_remove_fpm_config #================================================= # REMOVE DEDICATED USER #================================================= +ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user ynh_system_user_delete $app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 68bdcf8..fdf3e9b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -13,6 +13,7 @@ if [ ! -e _common.sh ]; then fi source _common.sh source /usr/share/yunohost/helpers +source _ynh_add_fpm_config #================================================= # MANAGE SCRIPT FAILURE @@ -24,16 +25,19 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) final_path=$(ynh_app_setting_get $app final_path) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= +ynh_script_progression --message="Validating restoration parameters..." --weight=4 ynh_webpath_available $domain $path_url \ || ynh_die "Path not available: ${domain}${path_url}" @@ -51,22 +55,33 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= +ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file "$final_path" +#================================================= +# RESTORE THE MYSQL DATABASE +#================================================= +ynh_script_progression --message="Restoring the MySQL database..." --weight=9 + +db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) +ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd +ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql + #================================================= # RECREATE THE DEDICATED USER #================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --weight=3 # Create the dedicated user (if not existing) ynh_system_user_create $app #================================================= -# RESTORE USER RIGHTS +# RESTORE THE PHP-FPM CONFIGURATION #================================================= -# Restore permissions on app files -chown -R $app:$app $final_path +ynh_restore_file --origin_path="/etc/php/$YNH_PHP_VERSION/fpm/pool.d/$app.conf" + #================================================= # RESTORE THE PHP-FPM CONFIGURATION @@ -85,23 +100,54 @@ fi #================================================= # REINSTALL DEPENDENCIES #================================================= +ynh_script_progression --message="Reinstalling dependencies..." --weight=60 + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + +ynh_install_php --phpversion="$YNH_PHP_VERSION" --package="$extra_pkg_dependencies" + +#================================================= +# BACKUP THE LOGROTATE CONFIGURATION +#================================================= + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + + +#================================================= +# RESTORE THE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Restoring data directory..." --weight=2 + +datadir="/home/yunohost.app/$app/data" + +# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup. +ynh_restore_file --origin_path="$datadir" --not_mandatory + +mkdir -p "$datadir" + +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Fix app ownerships & permissions +chown -R $app: "$final_path" "$datadir" +chmod 640 "$final_path/config/config.php" +chmod 755 /home/yunohost.app -if [ "$(lsb_release --codename --short)" != "jessie" ] -then - ynh_install_app_dependencies php7.2-sqlite3 -else - ynh_install_app_dependencies php5-sqlite -fi #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -if [ "$(lsb_release --codename --short)" != "jessie" ] -then - systemctl reload php7.2-fpm -else - systemctl reload php5-fpm -fi -systemctl reload nginx +ynh_script_progression --message="Reloading nginx web server and php-fpm..." + +ynh_systemd_action --service_name=php${YNH_PHP_VERSION}-fpm --action=reload +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --last \ No newline at end of file From e6bdccd6fee6b3bdb01e90813c9615dd7bb2502b Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 17:52:58 +0200 Subject: [PATCH 004/207] try to debug --- scripts/_common.sh | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index fe27b7a..f392fb9 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,9 +1,4 @@ -#!/bin/bash - -# ============= FUTURE YUNOHOST HELPER ============= -# Delete a file checksum from the app settings -# -# $app should be defined when calling this helper +hould be defined when calling this helper # # usage: ynh_remove_file_checksum file # | arg: file - The file for which the checksum will be deleted @@ -16,6 +11,7 @@ #================================================= # COMMON VARIABLES #================================================= +ynh_install_php --phpversion=7.2 YNH_PHP_VERSION="7.2" extra_pkg_dependencies="php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-redis php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-sqlite3" @@ -28,15 +24,6 @@ ynh_remove_php () { # Get the version of php used by this app local phpversion=$(ynh_app_setting_get $app phpversion) - if [ "$phpversion" == "7.0" ] || [ -z "$phpversion" ] - then - if [ "$phpversion" == "7.0" ] - then - ynh_print_err "Do not use ynh_remove_php to install php7.0" - fi - return 0 - fi - # Remove the line for this app sed --in-place "/$YNH_APP_INSTANCE_NAME:$phpversion/d" "/etc/php/ynh_app_version" From 80845864a16ae964e4539b4932f1ceaecd8884b6 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 17:57:23 +0200 Subject: [PATCH 005/207] try to debug --- scripts/_common.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index f392fb9..ec86ecb 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,12 +1,3 @@ -hould be defined when calling this helper -# -# usage: ynh_remove_file_checksum file -# | arg: file - The file for which the checksum will be deleted -# Install another version of php. -# -# usage: ynh_install_php --phpversion=phpversion [--package=packages] -# | arg: -v, --phpversion - Version of php to install. -# | arg: -p, --package - Additionnal php packages to install #================================================= # COMMON VARIABLES From a60d06781f99417c443a6a3ec2997e33025ec9c3 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 18:05:04 +0200 Subject: [PATCH 006/207] try to debug --- scripts/_common.sh | 207 --------------------------------------------- 1 file changed, 207 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index ec86ecb..0165afc 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,213 +7,6 @@ ynh_install_php --phpversion=7.2 YNH_PHP_VERSION="7.2" extra_pkg_dependencies="php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-redis php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-sqlite3" - -# Remove the specific version of php used by the app. -# -# usage: ynh_install_php -ynh_remove_php () { - # Get the version of php used by this app - local phpversion=$(ynh_app_setting_get $app phpversion) - - # Remove the line for this app - sed --in-place "/$YNH_APP_INSTANCE_NAME:$phpversion/d" "/etc/php/ynh_app_version" - - # If no other app uses this version of php, remove it. - if ! grep --quiet "$phpversion" "/etc/php/ynh_app_version" - then - # Purge php dependences for this version. - ynh_package_autopurge "php$phpversion php${phpversion}-fpm php${phpversion}-common" - # Remove the service from the admin panel - yunohost service remove php${phpversion}-fpm - fi - - # If no other app uses alternate php versions, remove the extra repo for php - if [ ! -s "/etc/php/ynh_app_version" ] - then - ynh_secure_remove /etc/php/ynh_app_version - fi -} -ynh_delete_file_checksum () { - local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' - ynh_app_setting_delete $app $checksum_setting_name -} - - #================================================= - # CHANGE THE FAKE DEPENDENCIES PACKAGE - #================================================= - - # Check if a variable $pkg_dependencies exists - # If this variable doesn't exist, this part shall be managed in the upgrade script. - if [ -n "${pkg_dependencies:-}" ] - then - # Define the name of the package - local old_package_name="${old_app//_/-}-ynh-deps" - local new_package_name="${new_app//_/-}-ynh-deps" - - if ynh_package_is_installed "$old_package_name" - then - # Install a new fake package - app=$new_app - ynh_install_app_dependencies $pkg_dependencies - # Then remove the old one - app=$old_app - ynh_remove_app_dependencies - fi - fi - - # Define the values to configure php-fpm -# -# usage: ynh_get_scalable_phpfpm --usage=usage --footprint=footprint [--print] -# | arg: -f, --footprint - Memory footprint of the service (low/medium/high). -# low - Less than 20Mb of ram by pool. -# medium - Between 20Mb and 40Mb of ram by pool. -# high - More than 40Mb of ram by pool. -# Or specify exactly the footprint, the load of the service as Mb by pool instead of having a standard value. -# To have this value, use the following command and stress the service. -# watch -n0.5 ps -o user,cmd,%cpu,rss -u APP -# -# | arg: -u, --usage - Expected usage of the service (low/medium/high). -# low - Personal usage, behind the sso. -# medium - Low usage, few people or/and publicly accessible. -# high - High usage, frequently visited website. -# -# | arg: -p, --print - Print the result -# -# -# -# The footprint of the service will be used to defined the maximum footprint we can allow, which is half the maximum RAM. -# So it will be used to defined 'pm.max_children' -# A lower value for the footprint will allow more children for 'pm.max_children'. And so for -# 'pm.start_servers', 'pm.min_spare_servers' and 'pm.max_spare_servers' which are defined from the -# value of 'pm.max_children' -# NOTE: 'pm.max_children' can't exceed 4 times the number of processor's cores. -# -# The usage value will defined the way php will handle the children for the pool. -# A value set as 'low' will set the process manager to 'ondemand'. Children will start only if the -# service is used, otherwise no child will stay alive. This config gives the lower footprint when the -# service is idle. But will use more proc since it has to start a child as soon it's used. -# Set as 'medium', the process manager will be at dynamic. If the service is idle, a number of children -# equal to pm.min_spare_servers will stay alive. So the service can be quick to answer to any request. -# The number of children can grow if needed. The footprint can stay low if the service is idle, but -# not null. The impact on the proc is a little bit less than 'ondemand' as there's always a few -# children already available. -# Set as 'high', the process manager will be set at 'static'. There will be always as many children as -# 'pm.max_children', the footprint is important (but will be set as maximum a quarter of the maximum -# RAM) but the impact on the proc is lower. The service will be quick to answer as there's always many -# children ready to answer. -ynh_get_scalable_phpfpm () { - local legacy_args=ufp - # Declare an array to define the options of this helper. - declare -Ar args_array=( [u]=usage= [f]=footprint= [p]=print ) - local usage - local footprint - local print - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - # Set all characters as lowercase - footprint=${footprint,,} - usage=${usage,,} - print=${print:-0} - - if [ "$footprint" = "low" ] - then - footprint=20 - elif [ "$footprint" = "medium" ] - then - footprint=35 - elif [ "$footprint" = "high" ] - then - footprint=50 - fi - - # Define the way the process manager handle child processes. - if [ "$usage" = "low" ] - then - php_pm=ondemand - elif [ "$usage" = "medium" ] - then - php_pm=dynamic - elif [ "$usage" = "high" ] - then - php_pm=static - else - ynh_die --message="Does not recognize '$usage' as an usage value." - fi - - # Get the total of RAM available, except swap. - local max_ram=$(ynh_check_ram --no_swap) - - less0() { - # Do not allow value below 1 - if [ $1 -le 0 ] - then - echo 1 - else - echo $1 - fi - } - - # Define pm.max_children - # The value of pm.max_children is the total amount of ram divide by 2 and divide again by the footprint of a pool for this app. - # So if php-fpm start the maximum of children, it won't exceed half of the ram. - php_max_children=$(( $max_ram / 2 / $footprint )) - # If process manager is set as static, use half less children. - # Used as static, there's always as many children as the value of pm.max_children - if [ "$php_pm" = "static" ] - then - php_max_children=$(( $php_max_children / 2 )) - fi - php_max_children=$(less0 $php_max_children) - - # To not overload the proc, limit the number of children to 4 times the number of cores. - local core_number=$(nproc) - local max_proc=$(( $core_number * 4 )) - if [ $php_max_children -gt $max_proc ] - then - php_max_children=$max_proc - fi - - if [ "$php_pm" = "dynamic" ] - then - # Define pm.start_servers, pm.min_spare_servers and pm.max_spare_servers for a dynamic process manager - php_min_spare_servers=$(( $php_max_children / 8 )) - php_min_spare_servers=$(less0 $php_min_spare_servers) - - php_max_spare_servers=$(( $php_max_children / 2 )) - php_max_spare_servers=$(less0 $php_max_spare_servers) - - php_start_servers=$(( $php_min_spare_servers + ( $php_max_spare_servers - $php_min_spare_servers ) /2 )) - php_start_servers=$(less0 $php_start_servers) - else - php_min_spare_servers=0 - php_max_spare_servers=0 - php_start_servers=0 - fi - - if [ $print -eq 1 ] - then - ynh_debug --message="Footprint=${footprint}Mb by pool." - ynh_debug --message="Process manager=$php_pm" - ynh_debug --message="Max RAM=${max_ram}Mb" - if [ "$php_pm" != "static" ]; then - ynh_debug --message="\nMax estimated footprint=$(( $php_max_children * $footprint ))" - ynh_debug --message="Min estimated footprint=$(( $php_min_spare_servers * $footprint ))" - fi - if [ "$php_pm" = "dynamic" ]; then - ynh_debug --message="Estimated average footprint=$(( $php_max_spare_servers * $footprint ))" - elif [ "$php_pm" = "static" ]; then - ynh_debug --message="Estimated footprint=$(( $php_max_children * $footprint ))" - fi - ynh_debug --message="\nRaw php-fpm values:" - ynh_debug --message="pm.max_children = $php_max_children" - if [ "$php_pm" = "dynamic" ]; then - ynh_debug --message="pm.start_servers = $php_start_servers" - ynh_debug --message="pm.min_spare_servers = $php_min_spare_servers" - ynh_debug --message="pm.max_spare_servers = $php_max_spare_servers" - fi - fi -} - # Install another version of php. # # usage: ynh_install_php --phpversion=phpversion [--package=packages] From 65fb840a5fdeb0b97cf61fa7b3d3c9afdbf2bd38 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 18:11:57 +0200 Subject: [PATCH 007/207] try to debug --- scripts/_common.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 0165afc..6a75d6c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -2,8 +2,6 @@ #================================================= # COMMON VARIABLES #================================================= -ynh_install_php --phpversion=7.2 - YNH_PHP_VERSION="7.2" extra_pkg_dependencies="php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-redis php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-sqlite3" From d17daf939d3b39ee2ebda0bed6cd39b41c02d978 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 18:30:14 +0200 Subject: [PATCH 008/207] try to debug --- conf/nginx.conf | 2 +- scripts/_common.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 24b6b95..e75ca8c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -16,7 +16,7 @@ location __PATH__ { try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php5-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php__YNH_PHP_VERSION__-fpm-__NAME__.sock; # If you don't use a dedicated fpm config for your app, # use a general fpm pool. diff --git a/scripts/_common.sh b/scripts/_common.sh index 6a75d6c..c44f01c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -2,7 +2,7 @@ #================================================= # COMMON VARIABLES #================================================= -YNH_PHP_VERSION="7.2" +YNH_PHP_VERSION="7.3" extra_pkg_dependencies="php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-redis php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-sqlite3" # Install another version of php. From 966d2e4e574cb5e93b975be78b22caccdb2b8473 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 18:42:14 +0200 Subject: [PATCH 009/207] try to debug --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index c44f01c..4d4b314 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,7 +3,7 @@ # COMMON VARIABLES #================================================= YNH_PHP_VERSION="7.3" -extra_pkg_dependencies="php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-redis php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-sqlite3" +extra_pkg_dependencies="php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-redis php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-sqlite3" # Install another version of php. # From 9f714b579f379f54007f15465355991840cdf4f5 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 18:52:45 +0200 Subject: [PATCH 010/207] try to debug --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 4d4b314..2cce4a2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -2,7 +2,7 @@ #================================================= # COMMON VARIABLES #================================================= -YNH_PHP_VERSION="7.3" +YNH_PHP_VERSION="7.4" extra_pkg_dependencies="php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-redis php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-sqlite3" # Install another version of php. From ec486720b243016a2cff8a39ff38cbf36083c191 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 19:10:13 +0200 Subject: [PATCH 011/207] try to debug --- conf/php-fpm.conf | 92 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 73 insertions(+), 19 deletions(-) diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 9f3942f..3e6b5be 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -1,10 +1,11 @@ ; Start a new pool named 'www'. -; the variable $pool can we used in any directive and will be replaced by the +; the variable $pool can be used in any directive and will be replaced by the ; pool name ('www' here) [__NAMETOCHANGE__] ; Per pool prefix ; It only applies on the following directives: +; - 'access.log' ; - 'slowlog' ; - 'listen' (unixsocket) ; - 'chroot' @@ -24,17 +25,19 @@ group = __USER__ ; The address on which to accept FastCGI requests. ; Valid syntaxes are: -; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on +; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on ; a specific port; -; 'port' - to listen on a TCP socket to all addresses on a -; specific port; +; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on +; a specific port; +; 'port' - to listen on a TCP socket to all addresses +; (IPv6 and IPv4-mapped) on a specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. -listen = /var/run/php7.2-fpm-__NAMETOCHANGE__.sock +listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock -; Set listen(2) backlog. A value of '-1' means unlimited. -; Default Value: 128 (-1 on FreeBSD and OpenBSD) -;listen.backlog = 128 +; Set listen(2) backlog. +; Default Value: 511 (-1 on FreeBSD and OpenBSD) +;listen.backlog = 511 ; Set permissions for unix socket, if one is used. In Linux, read/write ; permissions must be set in order to allow connections from a web server. Many @@ -44,8 +47,13 @@ listen = /var/run/php7.2-fpm-__NAMETOCHANGE__.sock listen.owner = www-data listen.group = www-data ;listen.mode = 0660 +; When POSIX Access Control Lists are supported you can set them using +; these options, value is a comma separated list of user/group names. +; When set, listen.owner and listen.group are ignored +;listen.acl_users = +;listen.acl_groups = -; List of ipv4 addresses of FastCGI clients which are allowed to connect. +; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address ; must be separated by a comma. If this value is left blank, connections will be @@ -59,7 +67,13 @@ listen.group = www-data ; - The pool processes will inherit the master process priority ; unless it specified otherwise ; Default Value: no set -; priority = -19 +; process.priority = -19 + +; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user +; or group is differrent than the master process user. It allows to create process +; core dump and ptrace the process for the pool user. +; Default Value: no +; process.dumpable = yes ; Choose how the process manager will control the number of child processes. ; Possible Values: @@ -122,7 +136,7 @@ pm.max_spare_servers = 3 ; This can be useful to work around memory leaks in 3rd party libraries. For ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. ; Default Value: 0 -pm.max_requests = 500 +;pm.max_requests = 500 ; The URI to view the FPM status page. If this value is not set, no URI will be ; recognized as a status page. It shows the following informations: @@ -215,7 +229,7 @@ pm.max_requests = 500 ; last request memory: 0 ; ; Note: There is a real-time FPM status monitoring sample web page available -; It's available in: ${prefix}/share/fpm/status.html +; It's available in: /usr/share/php/__PHPVERSION__/fpm/status.html ; ; Note: The value must start with a leading slash (/). The value can be ; anything, but it may not be a good idea to use the .php extension or it @@ -275,7 +289,7 @@ pm.max_requests = 500 ; - %{megabytes}M ; - %{mega}M ; %n: pool name -; %o: ouput header +; %o: output header ; it must be associated with embraces to specify the name of the header: ; - %{Content-Type}o ; - %{X-Powered-By}o @@ -291,9 +305,13 @@ pm.max_requests = 500 ; %t: server time the request was received ; it can accept a strftime(3) format: ; %d/%b/%Y:%H:%M:%S %z (default) +; The strftime(3) format must be encapsuled in a %{}t tag +; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t ; %T: time the log has been written (the request has finished) ; it can accept a strftime(3) format: ; %d/%b/%Y:%H:%M:%S %z (default) +; The strftime(3) format must be encapsuled in a %{}t tag +; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t ; %u: remote user ; ; Default: "%R - %u %t \"%m %r\" %s" @@ -302,13 +320,13 @@ pm.max_requests = 500 ; The log file for slow requests ; Default Value: not set ; Note: slowlog is mandatory if request_slowlog_timeout is set -slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log +;slowlog = log/$pool.log.slow ; The timeout for serving a single request after which a PHP backtrace will be ; dumped to the 'slowlog' file. A value of '0s' means 'off'. ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) ; Default Value: 0 -request_slowlog_timeout = 5s +;request_slowlog_timeout = 0 ; The timeout for serving a single request after which the worker process will ; be killed. This option should be used when the 'max_execution_time' ini option @@ -347,15 +365,24 @@ chdir = __FINALPATH__ ; Note: on highloaded environement, this can cause some delay in the page ; process time (several ms). ; Default Value: no -catch_workers_output = yes +;catch_workers_output = yes + +; Clear environment in FPM workers +; Prevents arbitrary environment variables from reaching FPM worker processes +; by clearing the environment in workers before env vars specified in this +; pool configuration are added. +; Setting to "no" will make all environment variables available to PHP code +; via getenv(), $_ENV and $_SERVER. +; Default Value: yes +;clear_env = no ; Limits the extensions of the main script FPM will allow to parse. This can ; prevent configuration mistakes on the web server side. You should only limit ; FPM to .php extensions to prevent malicious users to use other extensions to -; exectute php code. +; execute php code. ; Note: set an empty value to allow all extensions. ; Default Value: .php -;security.limit_extensions = .php .php3 .php4 .php5 +;security.limit_extensions = .php .php3 .php4 .php5 .php7 ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from ; the current environment. @@ -365,7 +392,7 @@ catch_workers_output = yes ;env[TMP] = /tmp ;env[TMPDIR] = /tmp ;env[TEMP] = /tmp - +env[PATH] = $PATH ; Additional php.ini defines, specific to this pool of workers. These settings ; overwrite the values previously defined in the php.ini. The directives are the ; same as the PHP SAPI: @@ -390,3 +417,30 @@ catch_workers_output = yes ;php_admin_value[error_log] = /var/log/fpm-php.www.log ;php_admin_flag[log_errors] = on ;php_admin_value[memory_limit] = 32M + +; Common values to change to increase file upload limit +; php_admin_value[upload_max_filesize] = 50M +; php_admin_value[post_max_size] = 50M +; php_admin_flag[mail.add_x_header] = Off + +; Other common parameters +; php_admin_value[max_execution_time] = 600 +; php_admin_value[max_input_time] = 300 +; php_admin_value[memory_limit] = 256M +; php_admin_flag[short_open_tag] = On + +; Additional php.ini defines, specific to this pool of workers. +php_admin_value[memory_limit] = 512M +php_value[upload_max_filesize] = 10G +php_value[post_max_size] = 10G +php_value[default_charset] = UTF-8 +; OPcache is already activated by default +; php_value[opcache.enable]=1 +; The following parameters are nevertheless recommended for Nextcloud +; see here: https://docs.nextcloud.com/server/15/admin_manual/installation/server_tuning.html#enable-php-opcache +php_value[opcache.enable_cli]=1 +php_value[opcache.interned_strings_buffer]=8 +php_value[opcache.max_accelerated_files]=10000 +php_value[opcache.memory_consumption]=128 +php_value[opcache.save_comments]=1 +php_value[opcache.revalidate_freq]=1 \ No newline at end of file From aa8e436ec6ada88ed81b1af5567e92792a2a8a11 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 19:41:17 +0200 Subject: [PATCH 012/207] try to debug --- scripts/_common.sh | 75 +--------------------------------------------- 1 file changed, 1 insertion(+), 74 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 2cce4a2..262aecc 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -2,7 +2,7 @@ #================================================= # COMMON VARIABLES #================================================= -YNH_PHP_VERSION="7.4" +YNH_PHP_VERSION="7.2" extra_pkg_dependencies="php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-redis php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-sqlite3" # Install another version of php. @@ -10,80 +10,7 @@ extra_pkg_dependencies="php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php # usage: ynh_install_php --phpversion=phpversion [--package=packages] # | arg: -v, --phpversion - Version of php to install. # | arg: -p, --package - Additionnal php packages to install -ynh_install_php () { - # Declare an array to define the options of this helper. - local legacy_args=vp - declare -Ar args_array=( [v]=phpversion= [p]=package= ) - local phpversion - local package - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - package=${package:-} - # Store phpversion into the config of this app - ynh_app_setting_set $app phpversion $phpversion - - if [ "$phpversion" == "7.0" ] - then - ynh_die "Do not use ynh_install_php to install php7.0" - fi - - # Store the ID of this app and the version of php requested for it - echo "$YNH_APP_INSTANCE_NAME:$phpversion" | tee --append "/etc/php/ynh_app_version" - - # Add an extra repository for those packages - ynh_install_extra_repo --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --priority=995 --name=extra_php_version - - # Install requested dependencies from this extra repository. - # Install php-fpm first, otherwise php will install apache as a dependency. - ynh_add_app_dependencies --package="php${phpversion}-fpm" - ynh_add_app_dependencies --package="php$phpversion php${phpversion}-common $package" - - # Set php7.0 back as the default version for php-cli. - update-alternatives --set php /usr/bin/php7.0 - - # Pin this extra repository after packages are installed to prevent sury of doing shit - ynh_pin_repo --package="*" --pin="origin \"packages.sury.org\"" --priority=200 --name=extra_php_version - ynh_pin_repo --package="php7.0*" --pin="origin \"packages.sury.org\"" --priority=600 --name=extra_php_version --append - - # Advertise service in admin panel - yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log" -} - -# Remove the specific version of php used by the app. -# -# usage: ynh_install_php -ynh_remove_php () { - # Get the version of php used by this app - local phpversion=$(ynh_app_setting_get $app phpversion) - - if [ "$phpversion" == "7.0" ] || [ -z "$phpversion" ] - then - if [ "$phpversion" == "7.0" ] - then - ynh_print_err "Do not use ynh_remove_php to install php7.0" - fi - return 0 - fi - - # Remove the line for this app - sed --in-place "/$YNH_APP_INSTANCE_NAME:$phpversion/d" "/etc/php/ynh_app_version" - - # If no other app uses this version of php, remove it. - if ! grep --quiet "$phpversion" "/etc/php/ynh_app_version" - then - # Purge php dependences for this version. - ynh_package_autopurge "php$phpversion php${phpversion}-fpm php${phpversion}-common" - # Remove the service from the admin panel - yunohost service remove php${phpversion}-fpm - fi - - # If no other app uses alternate php versions, remove the extra repo for php - if [ ! -s "/etc/php/ynh_app_version" ] - then - ynh_secure_remove /etc/php/ynh_app_version - fi -} #================================================= # FUTURE OFFICIAL HELPERS From e3d0a9deb43b8c46b8b7b64c661a7fea2d26a7a4 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 19:54:47 +0200 Subject: [PATCH 013/207] try to debug --- scripts/install | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 392fe61..fb8f3a6 100644 --- a/scripts/install +++ b/scripts/install @@ -57,9 +57,10 @@ ynh_app_setting_set $app is_public $is_public #================================================= ynh_script_progression --message="Installing dependencies..." --weight=60 +ynh_install_php --phpversion="$YNH_PHP_VERSION" --package="$extra_pkg_dependencies" + ynh_install_app_dependencies $pkg_dependencies -ynh_install_php --phpversion="$YNH_PHP_VERSION" --package="$extra_pkg_dependencies" #================================================= # CREATE A MYSQL DATABASE From 2ef3491f37533dd04cf5cb011c4a8c12bafdc21d Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 20:30:11 +0200 Subject: [PATCH 014/207] try to debug --- scripts/_common.sh | 686 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 684 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 262aecc..b2fe000 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -2,15 +2,698 @@ #================================================= # COMMON VARIABLES #================================================= + +pkg_dependencies="acl tar at" + YNH_PHP_VERSION="7.2" -extra_pkg_dependencies="php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-redis php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-sqlite3" +extra_pkg_dependencies="php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-redis php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-sqlite3" + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +# Execute a command as another user +# usage: exec_as USER COMMAND [ARG ...] +exec_as() { + local USER=$1 + shift 1 + + if [[ $USER = $(whoami) ]]; then + eval "$@" + else + sudo -u "$USER" "$@" + fi +} + +#================================================= + +# Check if an URL is already handled +# usage: is_url_handled --domain=DOMAIN --path=PATH_URI +is_url_handled() { + # Declare an array to define the options of this helper. + local legacy_args=dp + declare -Ar args_array=( [d]=domain= [p]=path= ) + local domain + local path + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + # Try to get the url with curl, and keep the http code and an eventual redirection url. + local curl_output="$(curl --insecure --silent --output /dev/null \ + --write-out '%{http_code};%{redirect_url}' https://127.0.0.1$path --header "Host: $domain" --resolve $domain:443:127.0.0.1)" + + # Cut the output and keep only the first part to keep the http code + local http_code="${curl_output%%;*}" + # Do the same thing but keep the second part, the redirection url + local redirection="${curl_output#*;}" + + # Return 1 if the url isn't handled. + # Which means either curl got a 404 (or the admin) or the sso. + # A handled url should redirect to a publicly accessible url. + # Return 1 if the url has returned 404 + if [ "$http_code" = "404" ] || [[ $redirection =~ "/yunohost/admin" ]]; then + return 1 + # Return 1 if the url is redirected to the SSO + elif [[ $redirection =~ "/yunohost/sso" ]]; then + return 1 + fi +} + +#================================================= + +# Make the main steps to migrate an app to its fork. +# +# This helper has to be used for an app which needs to migrate to a new name or a new fork +# (like owncloud to nextcloud or zerobin to privatebin). +# +# This helper will move the files of an app to its new name +# or recreate the things it can't move. +# +# To specify which files it has to move, you have to create a "migration file", stored in ../conf +# This file is a simple list of each file it has to move, +# except that file names must reference the $app variable instead of the real name of the app, +# and every instance-specific variables (like $domain). +# $app is especially important because it's this variable which will be used to identify the old place and the new one for each file. +# +# If a database exists for this app, it will be dumped and then imported in a newly created database, with a new name and new user. +# Don't forget you have to then apply these changes to application-specific settings (depends on the packaged application) +# +# Same things for an existing user, a new one will be created. +# But the old one can't be removed unless it's not used. See below. +# +# If you have some dependencies for your app, it's possible to change the fake debian package which manages them. +# You have to fill the $pkg_dependencies variable, and then a new fake package will be created and installed, +# and the old one will be removed. +# If you don't have a $pkg_dependencies variable, the helper can't know what the app dependencies are. +# +# The app settings.yml will be modified as follows: +# - finalpath will be changed according to the new name (but only if the existing $final_path contains the old app name) +# - The checksums of php-fpm and nginx config files will be updated too. +# - If there is a $db_name value, it will be changed. +# - And, of course, the ID will be changed to the new name too. +# +# Finally, the $app variable will take the value of the new name. +# The helper will set the $migration_process variable to 1 if a migration has been successfully handled. +# +# You have to handle by yourself all the migrations not done by this helper, like configuration or special values in settings.yml +# Also, at the end of the upgrade script, you have to add a post_migration script to handle all the things the helper can't do during YunoHost upgrade (mostly for permission reasons), +# especially remove the old user, move some hooks and remove the old configuration directory +# To launch this script, you have to move it elsewhere and start it after the upgrade script. +# `cp ../conf/$script_post_migration /tmp` +# `(cd /tmp; echo "/tmp/$script_post_migration" | at now + 2 minutes)` +# +# usage: ynh_handle_app_migration migration_id migration_list +# | arg: migration_id - ID from which to migrate +# | arg: migration_list - File specifying every file to move (one file per line) +ynh_handle_app_migration () { + #================================================= + # LOAD SETTINGS + #================================================= + + old_app=$YNH_APP_INSTANCE_NAME + local old_app_id=$YNH_APP_ID + local old_app_number=$YNH_APP_INSTANCE_NUMBER + + # Get the id from which to migrate + local migration_id="$1" + # And the file with the paths to move + local migration_list="$2" + + # Get the new app id in the manifest + local new_app_id=$(grep \"id\": ../manifest.json | cut -d\" -f4) + if [ $old_app_number -eq 1 ]; then + local new_app=$new_app_id + else + local new_app=${new_app_id}__${old_app_number} + fi + + #================================================= + # CHECK IF IT HAS TO MIGRATE + #================================================= + + migration_process=0 + + if [ "$old_app_id" == "$new_app_id" ] + then + # If the 2 id are the same + # No migration to do. + echo 0 + return 0 + else + if [ "$old_app_id" != "$migration_id" ] + then + # If the new app is not the authorized id, fail. + ynh_die "Incompatible application for migration from $old_app_id to $new_app_id" + fi + + echo "Migrate from $old_app_id to $new_app_id" >&2 + + #================================================= + # CHECK IF THE MIGRATION CAN BE DONE + #================================================= + + # TODO Handle multi instance apps... + # Check that there is not already an app installed for this id. + (yunohost app list --installed -f "$new_app" | grep -q id) \ + && ynh_die "$new_app is already installed" + + #================================================= + # CHECK THE LIST OF FILES TO MOVE + #================================================= + + local temp_migration_list="$(tempfile)" + + # Build the list by removing blank lines and comment lines + sed '/^#.*\|^$/d' "../conf/$migration_list" > "$temp_migration_list" + + # Check if there is no file in the destination + local file_to_move="" + while read file_to_move + do + # Replace all occurences of $app by $new_app in each file to move. + local move_to_destination="${file_to_move//\$app/$new_app}" + test -e "$move_to_destination" && ynh_die "A file named $move_to_destination already exists." + done < "$temp_migration_list" + + #================================================= + # COPY YUNOHOST SETTINGS FOR THIS APP + #================================================= + + local settings_dir="/etc/yunohost/apps" + cp -a "$settings_dir/$old_app" "$settings_dir/$new_app" + + # Replace the old id by the new one + ynh_replace_string "\(^id: .*\)$old_app" "\1$new_app" "$settings_dir/$new_app/settings.yml" + # INFO: There a special behavior with yunohost app setting: + # if the id given in argument does not match with the id + # stored in the config file, the config file will be purged. + # That's why we use sed instead of app setting here. + # https://github.com/YunoHost/yunohost/blob/c6b5284be8da39cf2da4e1036a730eb5e0515096/src/yunohost/app.py#L1316-L1321 + + # Change the label if it's simply the name of the app + old_label=$(ynh_app_setting_get $new_app label) + if [ "${old_label,,}" == "$old_app_id" ] + then + # Build the new label from the id of the app. With the first character as upper case + new_label=$(echo $new_app_id | cut -c1 | tr [:lower:] [:upper:])$(echo $new_app_id | cut -c2-) + ynh_app_setting_set $new_app label $new_label + fi + + #================================================= + # MOVE FILES TO THE NEW DESTINATION + #================================================= + + while read file_to_move + do + # Replace all occurence of $app by $new_app in each file to move. + move_to_destination="$(eval echo "${file_to_move//\$app/$new_app}")" + local real_file_to_move="$(eval echo "${file_to_move//\$app/$old_app}")" + echo "Move file $real_file_to_move to $move_to_destination" >&2 + mv "$real_file_to_move" "$move_to_destination" + done < "$temp_migration_list" + + #================================================= + # UPDATE SETTINGS KNOWN ENTRIES + #================================================= + + # Replace nginx checksum + ynh_replace_string "\(^checksum__etc_nginx.*\)_$old_app" "\1_$new_app/" "$settings_dir/$new_app/settings.yml" + + # Replace php5-fpm checksums + ynh_replace_string "\(^checksum__etc_php5.*[-_]\)$old_app" "\1$new_app/" "$settings_dir/$new_app/settings.yml" + + # Replace final_path + ynh_replace_string "\(^final_path: .*\)$old_app" "\1$new_app" "$settings_dir/$new_app/settings.yml" + + #================================================= + # MOVE THE DATABASE + #================================================= + + db_pwd=$(ynh_app_setting_get $old_app mysqlpwd) + db_name=$(ynh_app_setting_get $old_app db_name) + + # Check if a database exists before trying to move it + local mysql_root_password=$(cat $MYSQL_ROOT_PWD_FILE) + if [ -n "$db_name" ] && mysqlshow -u root -p$mysql_root_password | grep -q "^| $db_name" + then + new_db_name=$(ynh_sanitize_dbid $new_app) + echo "Rename the database $db_name to $new_db_name" >&2 + + local sql_dump="/tmp/${db_name}-$(date '+%s').sql" + + # Dump the old database + ynh_mysql_dump_db "$db_name" > "$sql_dump" + + # Create a new database + ynh_mysql_setup_db $new_db_name $new_db_name $db_pwd + # Then restore the old one into the new one + ynh_mysql_connect_as $new_db_name $db_pwd $new_db_name < "$sql_dump" + + # Remove the old database + ynh_mysql_remove_db $db_name $db_name + # And the dump + ynh_secure_remove "$sql_dump" + + # Update the value of $db_name + db_name=$new_db_name + ynh_app_setting_set $new_app db_name $db_name + fi + + #================================================= + # CREATE A NEW USER + #================================================= + + # Check if the user exists on the system + if ynh_system_user_exists "$old_app" + then + echo "Create a new user $new_app to replace $old_app" >&2 + ynh_system_user_create $new_app + fi + + #================================================= + # CHANGE THE FAKE DEPENDENCIES PACKAGE + #================================================= + + # Check if a variable $pkg_dependencies exists + # If this variable doesn't exist, this part shall be managed in the upgrade script. + if [ -n "${pkg_dependencies:-}" ] + then + # Define the name of the package + local old_package_name="${old_app//_/-}-ynh-deps" + local new_package_name="${new_app//_/-}-ynh-deps" + + if ynh_package_is_installed "$old_package_name" + then + # Install a new fake package + app=$new_app + ynh_install_app_dependencies $pkg_dependencies + # Then remove the old one + app=$old_app + ynh_remove_app_dependencies + fi + fi + + #================================================= + # UPDATE THE ID OF THE APP + #================================================= + + app=$new_app + + + # Set migration_process to 1 to inform that an upgrade has been made + migration_process=1 + fi +} + +#================================================= + +# Check available space before creating a temp directory. +# +# usage: ynh_smart_mktemp --min_size="Min size" +# +# | arg: -s, --min_size= - Minimal size needed for the temporary directory, in Mb +ynh_smart_mktemp () { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [s]=min_size= ) + local min_size + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + min_size="${min_size:-300}" + # Transform the minimum size from megabytes to kilobytes + min_size=$(( $min_size * 1024 )) + + # Check if there's enough free space in a directory + is_there_enough_space () { + local free_space=$(df --output=avail "$1" | sed 1d) + test $free_space -ge $min_size + } + + if is_there_enough_space /tmp; then + local tmpdir=/tmp + elif is_there_enough_space /var; then + local tmpdir=/var + elif is_there_enough_space /; then + local tmpdir=/ + elif is_there_enough_space /home; then + local tmpdir=/home + else + ynh_die "Insufficient free space to continue..." + fi + + echo "$(sudo mktemp --directory --tmpdir="$tmpdir")" +} + +#================================================= + +# Check the amount of available RAM +# +# usage: ynh_check_ram [--required=RAM required in Mb] [--no_swap|--only_swap] [--free_ram] +# | arg: -r, --required= - Amount of RAM required in Mb. The helper will return 0 is there's enough RAM, or 1 otherwise. +# If --required isn't set, the helper will print the amount of RAM, in Mb. +# | arg: -s, --no_swap - Ignore swap +# | arg: -o, --only_swap - Ignore real RAM, consider only swap. +# | arg: -f, --free_ram - Count only free RAM, not the total amount of RAM available. +ynh_check_ram () { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [r]=required= [s]=no_swap [o]=only_swap [f]=free_ram ) + local required + local no_swap + local only_swap + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + required=${required:-} + no_swap=${no_swap:-0} + only_swap=${only_swap:-0} + + local total_ram=$(vmstat --stats --unit M | grep "total memory" | awk '{print $1}') + local total_swap=$(vmstat --stats --unit M | grep "total swap" | awk '{print $1}') + local total_ram_swap=$(( total_ram + total_swap )) + + local free_ram=$(vmstat --stats --unit M | grep "free memory" | awk '{print $1}') + local free_swap=$(vmstat --stats --unit M | grep "free swap" | awk '{print $1}') + local free_ram_swap=$(( free_ram + free_swap )) + + # Use the total amount of ram + local ram=$total_ram_swap + if [ $free_ram -eq 1 ] + then + # Use the total amount of free ram + ram=$free_ram_swap + if [ $no_swap -eq 1 ] + then + # Use only the amount of free ram + ram=$free_ram + elif [ $only_swap -eq 1 ] + then + # Use only the amount of free swap + ram=$free_swap + fi + else + if [ $no_swap -eq 1 ] + then + # Use only the amount of free ram + ram=$total_ram + elif [ $only_swap -eq 1 ] + then + # Use only the amount of free swap + ram=$total_swap + fi + fi + + if [ -n "$required" ] + then + # Return 1 if the amount of ram isn't enough. + if [ $ram -lt $required ] + then + return 1 + else + return 0 + fi + + # If no RAM is required, return the amount of available ram. + else + echo $ram + fi +} + +#================================================= + +# Define the values to configure php-fpm +# +# usage: ynh_get_scalable_phpfpm --usage=usage --footprint=footprint [--print] +# | arg: -f, --footprint - Memory footprint of the service (low/medium/high). +# low - Less than 20Mb of ram by pool. +# medium - Between 20Mb and 40Mb of ram by pool. +# high - More than 40Mb of ram by pool. +# Or specify exactly the footprint, the load of the service as Mb by pool instead of having a standard value. +# To have this value, use the following command and stress the service. +# watch -n0.5 ps -o user,cmd,%cpu,rss -u APP +# +# | arg: -u, --usage - Expected usage of the service (low/medium/high). +# low - Personal usage, behind the sso. +# medium - Low usage, few people or/and publicly accessible. +# high - High usage, frequently visited website. +# +# | arg: -p, --print - Print the result +# +# +# +# The footprint of the service will be used to defined the maximum footprint we can allow, which is half the maximum RAM. +# So it will be used to defined 'pm.max_children' +# A lower value for the footprint will allow more children for 'pm.max_children'. And so for +# 'pm.start_servers', 'pm.min_spare_servers' and 'pm.max_spare_servers' which are defined from the +# value of 'pm.max_children' +# NOTE: 'pm.max_children' can't exceed 4 times the number of processor's cores. +# +# The usage value will defined the way php will handle the children for the pool. +# A value set as 'low' will set the process manager to 'ondemand'. Children will start only if the +# service is used, otherwise no child will stay alive. This config gives the lower footprint when the +# service is idle. But will use more proc since it has to start a child as soon it's used. +# Set as 'medium', the process manager will be at dynamic. If the service is idle, a number of children +# equal to pm.min_spare_servers will stay alive. So the service can be quick to answer to any request. +# The number of children can grow if needed. The footprint can stay low if the service is idle, but +# not null. The impact on the proc is a little bit less than 'ondemand' as there's always a few +# children already available. +# Set as 'high', the process manager will be set at 'static'. There will be always as many children as +# 'pm.max_children', the footprint is important (but will be set as maximum a quarter of the maximum +# RAM) but the impact on the proc is lower. The service will be quick to answer as there's always many +# children ready to answer. +ynh_get_scalable_phpfpm () { + local legacy_args=ufp + # Declare an array to define the options of this helper. + declare -Ar args_array=( [u]=usage= [f]=footprint= [p]=print ) + local usage + local footprint + local print + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + # Set all characters as lowercase + footprint=${footprint,,} + usage=${usage,,} + print=${print:-0} + + if [ "$footprint" = "low" ] + then + footprint=20 + elif [ "$footprint" = "medium" ] + then + footprint=35 + elif [ "$footprint" = "high" ] + then + footprint=50 + fi + + # Define the way the process manager handle child processes. + if [ "$usage" = "low" ] + then + php_pm=ondemand + elif [ "$usage" = "medium" ] + then + php_pm=dynamic + elif [ "$usage" = "high" ] + then + php_pm=static + else + ynh_die --message="Does not recognize '$usage' as an usage value." + fi + + # Get the total of RAM available, except swap. + local max_ram=$(ynh_check_ram --no_swap) + + less0() { + # Do not allow value below 1 + if [ $1 -le 0 ] + then + echo 1 + else + echo $1 + fi + } + + # Define pm.max_children + # The value of pm.max_children is the total amount of ram divide by 2 and divide again by the footprint of a pool for this app. + # So if php-fpm start the maximum of children, it won't exceed half of the ram. + php_max_children=$(( $max_ram / 2 / $footprint )) + # If process manager is set as static, use half less children. + # Used as static, there's always as many children as the value of pm.max_children + if [ "$php_pm" = "static" ] + then + php_max_children=$(( $php_max_children / 2 )) + fi + php_max_children=$(less0 $php_max_children) + + # To not overload the proc, limit the number of children to 4 times the number of cores. + local core_number=$(nproc) + local max_proc=$(( $core_number * 4 )) + if [ $php_max_children -gt $max_proc ] + then + php_max_children=$max_proc + fi + + if [ "$php_pm" = "dynamic" ] + then + # Define pm.start_servers, pm.min_spare_servers and pm.max_spare_servers for a dynamic process manager + php_min_spare_servers=$(( $php_max_children / 8 )) + php_min_spare_servers=$(less0 $php_min_spare_servers) + + php_max_spare_servers=$(( $php_max_children / 2 )) + php_max_spare_servers=$(less0 $php_max_spare_servers) + + php_start_servers=$(( $php_min_spare_servers + ( $php_max_spare_servers - $php_min_spare_servers ) /2 )) + php_start_servers=$(less0 $php_start_servers) + else + php_min_spare_servers=0 + php_max_spare_servers=0 + php_start_servers=0 + fi + + if [ $print -eq 1 ] + then + ynh_debug --message="Footprint=${footprint}Mb by pool." + ynh_debug --message="Process manager=$php_pm" + ynh_debug --message="Max RAM=${max_ram}Mb" + if [ "$php_pm" != "static" ]; then + ynh_debug --message="\nMax estimated footprint=$(( $php_max_children * $footprint ))" + ynh_debug --message="Min estimated footprint=$(( $php_min_spare_servers * $footprint ))" + fi + if [ "$php_pm" = "dynamic" ]; then + ynh_debug --message="Estimated average footprint=$(( $php_max_spare_servers * $footprint ))" + elif [ "$php_pm" = "static" ]; then + ynh_debug --message="Estimated footprint=$(( $php_max_children * $footprint ))" + fi + ynh_debug --message="\nRaw php-fpm values:" + ynh_debug --message="pm.max_children = $php_max_children" + if [ "$php_pm" = "dynamic" ]; then + ynh_debug --message="pm.start_servers = $php_start_servers" + ynh_debug --message="pm.min_spare_servers = $php_min_spare_servers" + ynh_debug --message="pm.max_spare_servers = $php_max_spare_servers" + fi + fi +} + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= + +#================================================= +# YUNOHOST MULTIMEDIA INTEGRATION +#================================================= + +# Install or update the main directory yunohost.multimedia +# +# usage: ynh_multimedia_build_main_dir +ynh_multimedia_build_main_dir () { + local ynh_media_release="v1.2" + local checksum="806a827ba1902d6911095602a9221181" + + # Download yunohost.multimedia scripts + wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz + + # Check the control sum + echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \ + || ynh_die "Corrupt source" + + # Check if the package acl is installed. Or install it. + ynh_package_is_installed 'acl' \ + || ynh_package_install acl + + # Extract + mkdir yunohost.multimedia-master + tar -xf ${ynh_media_release}.tar.gz -C yunohost.multimedia-master --strip-components 1 + ./yunohost.multimedia-master/script/ynh_media_build.sh +} + +# Grant write access to multimedia directories to a specified user +# +# usage: ynh_multimedia_addaccess user_name +# +# | arg: user_name - User to be granted write access +ynh_multimedia_addaccess () { + local user_name=$1 + groupadd -f multimedia + usermod -a -G multimedia $user_name +} # Install another version of php. # # usage: ynh_install_php --phpversion=phpversion [--package=packages] # | arg: -v, --phpversion - Version of php to install. # | arg: -p, --package - Additionnal php packages to install +ynh_install_php () { + # Declare an array to define the options of this helper. + local legacy_args=vp + declare -Ar args_array=( [v]=phpversion= [p]=package= ) + local phpversion + local package + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + package=${package:-} + # Store phpversion into the config of this app + ynh_app_setting_set $app phpversion $phpversion + + if [ "$phpversion" == "7.0" ] + then + ynh_die "Do not use ynh_install_php to install php7.0" + fi + + # Store the ID of this app and the version of php requested for it + echo "$YNH_APP_INSTANCE_NAME:$phpversion" | tee --append "/etc/php/ynh_app_version" + + # Add an extra repository for those packages + ynh_install_extra_repo --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --priority=995 --name=extra_php_version + + # Install requested dependencies from this extra repository. + # Install php-fpm first, otherwise php will install apache as a dependency. + ynh_add_app_dependencies --package="php${phpversion}-fpm" + ynh_add_app_dependencies --package="php$phpversion php${phpversion}-common $package" + + # Set php7.0 back as the default version for php-cli. + update-alternatives --set php /usr/bin/php7.0 + + # Pin this extra repository after packages are installed to prevent sury of doing shit + ynh_pin_repo --package="*" --pin="origin \"packages.sury.org\"" --priority=200 --name=extra_php_version + ynh_pin_repo --package="php7.0*" --pin="origin \"packages.sury.org\"" --priority=600 --name=extra_php_version --append + + # Advertise service in admin panel + yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log" +} + +# Remove the specific version of php used by the app. +# +# usage: ynh_install_php +ynh_remove_php () { + # Get the version of php used by this app + local phpversion=$(ynh_app_setting_get $app phpversion) + + if [ "$phpversion" == "7.0" ] || [ -z "$phpversion" ] + then + if [ "$phpversion" == "7.0" ] + then + ynh_print_err "Do not use ynh_remove_php to install php7.0" + fi + return 0 + fi + + # Remove the line for this app + sed --in-place "/$YNH_APP_INSTANCE_NAME:$phpversion/d" "/etc/php/ynh_app_version" + + # If no other app uses this version of php, remove it. + if ! grep --quiet "$phpversion" "/etc/php/ynh_app_version" + then + # Purge php dependences for this version. + ynh_package_autopurge "php$phpversion php${phpversion}-fpm php${phpversion}-common" + # Remove the service from the admin panel + yunohost service remove php${phpversion}-fpm + fi + + # If no other app uses alternate php versions, remove the extra repo for php + if [ ! -s "/etc/php/ynh_app_version" ] + then + ynh_secure_remove /etc/php/ynh_app_version + fi +} #================================================= # FUTURE OFFICIAL HELPERS @@ -308,4 +991,3 @@ ynh_add_app_dependencies () { ynh_install_app_dependencies "${current_dependencies}${package}" } - From 6400ee0cb5ee829529b8a7fdf288e40e7fca66dd Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 20:44:37 +0200 Subject: [PATCH 015/207] try to debug --- conf/php-fpm.ini | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 conf/php-fpm.ini diff --git a/conf/php-fpm.ini b/conf/php-fpm.ini deleted file mode 100644 index 5c27d59..0000000 --- a/conf/php-fpm.ini +++ /dev/null @@ -1,10 +0,0 @@ -; Common values to change to increase file upload limit -; upload_max_filesize = 50M -; post_max_size = 50M -; mail.add_x_header = Off - -; Other common parameters -; max_execution_time = 600 -; max_input_time = 300 -; memory_limit = 256M -; short_open_tag = On From dafe4f0f3f60c743615114129c1afe8238aa5092 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 20:50:30 +0200 Subject: [PATCH 016/207] try to debug --- scripts/remove | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/scripts/remove b/scripts/remove index 386b677..06899f5 100644 --- a/scripts/remove +++ b/scripts/remove @@ -29,6 +29,14 @@ ynh_script_progression --message="Removing logrotate configuration..." # Remove metapackage and its dependencies ynh_remove_app_dependencies +#================================================= +# REMOVE THE MYSQL DATABASE +#================================================= +ynh_script_progression --message="Removing the MySQL database..." --weight=5 + +# Remove a database if it exists, along with the associated user +ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name + #================================================= # REMOVE APP MAIN DIR #================================================= @@ -50,6 +58,24 @@ ynh_remove_nginx_config # Remove the dedicated php-fpm config ynh_remove_fpm_config +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_script_progression --message="Removing logrotate configuration..." + +# Remove the app-specific logrotate config +ynh_remove_logrotate + +#================================================= +# CLEAN ACL IN HOME DIRECTORIES +#================================================= + +for i in $(ls /home); do + # Clean ACL in every directories in /home, except those which start with 'yunohost.' + [[ ! $i == yunohost.* ]] \ + && setfacl --remove g:$app:rwx 2>&1 +done + #================================================= # GENERIC FINALIZATION #================================================= From 56a1411284825870b92133c6f05df89c2aaecfa4 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 21:38:07 +0200 Subject: [PATCH 017/207] try to debug --- conf/php-fpm.conf | 94 ++++++++++------------------------------------- 1 file changed, 20 insertions(+), 74 deletions(-) diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 3e6b5be..9095c07 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -1,11 +1,10 @@ ; Start a new pool named 'www'. -; the variable $pool can be used in any directive and will be replaced by the +; the variable $pool can we used in any directive and will be replaced by the ; pool name ('www' here) [__NAMETOCHANGE__] ; Per pool prefix ; It only applies on the following directives: -; - 'access.log' ; - 'slowlog' ; - 'listen' (unixsocket) ; - 'chroot' @@ -25,19 +24,17 @@ group = __USER__ ; The address on which to accept FastCGI requests. ; Valid syntaxes are: -; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on +; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on ; a specific port; -; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on -; a specific port; -; 'port' - to listen on a TCP socket to all addresses -; (IPv6 and IPv4-mapped) on a specific port; +; 'port' - to listen on a TCP socket to all addresses on a +; specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. -listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock +listen = /var/run/php5-fpm-__NAMETOCHANGE__.sock -; Set listen(2) backlog. -; Default Value: 511 (-1 on FreeBSD and OpenBSD) -;listen.backlog = 511 +; Set listen(2) backlog. A value of '-1' means unlimited. +; Default Value: 128 (-1 on FreeBSD and OpenBSD) +;listen.backlog = 128 ; Set permissions for unix socket, if one is used. In Linux, read/write ; permissions must be set in order to allow connections from a web server. Many @@ -47,13 +44,8 @@ listen = /var/run/php/php__PHPVERSION__-fpm-__NAMETOCHANGE__.sock listen.owner = www-data listen.group = www-data ;listen.mode = 0660 -; When POSIX Access Control Lists are supported you can set them using -; these options, value is a comma separated list of user/group names. -; When set, listen.owner and listen.group are ignored -;listen.acl_users = -;listen.acl_groups = -; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. +; List of ipv4 addresses of FastCGI clients which are allowed to connect. ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address ; must be separated by a comma. If this value is left blank, connections will be @@ -67,13 +59,7 @@ listen.group = www-data ; - The pool processes will inherit the master process priority ; unless it specified otherwise ; Default Value: no set -; process.priority = -19 - -; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user -; or group is differrent than the master process user. It allows to create process -; core dump and ptrace the process for the pool user. -; Default Value: no -; process.dumpable = yes +; priority = -19 ; Choose how the process manager will control the number of child processes. ; Possible Values: @@ -136,7 +122,7 @@ pm.max_spare_servers = 3 ; This can be useful to work around memory leaks in 3rd party libraries. For ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. ; Default Value: 0 -;pm.max_requests = 500 +pm.max_requests = 500 ; The URI to view the FPM status page. If this value is not set, no URI will be ; recognized as a status page. It shows the following informations: @@ -229,7 +215,7 @@ pm.max_spare_servers = 3 ; last request memory: 0 ; ; Note: There is a real-time FPM status monitoring sample web page available -; It's available in: /usr/share/php/__PHPVERSION__/fpm/status.html +; It's available in: ${prefix}/share/fpm/status.html ; ; Note: The value must start with a leading slash (/). The value can be ; anything, but it may not be a good idea to use the .php extension or it @@ -289,7 +275,7 @@ pm.max_spare_servers = 3 ; - %{megabytes}M ; - %{mega}M ; %n: pool name -; %o: output header +; %o: ouput header ; it must be associated with embraces to specify the name of the header: ; - %{Content-Type}o ; - %{X-Powered-By}o @@ -305,13 +291,9 @@ pm.max_spare_servers = 3 ; %t: server time the request was received ; it can accept a strftime(3) format: ; %d/%b/%Y:%H:%M:%S %z (default) -; The strftime(3) format must be encapsuled in a %{}t tag -; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t ; %T: time the log has been written (the request has finished) ; it can accept a strftime(3) format: ; %d/%b/%Y:%H:%M:%S %z (default) -; The strftime(3) format must be encapsuled in a %{}t tag -; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t ; %u: remote user ; ; Default: "%R - %u %t \"%m %r\" %s" @@ -320,13 +302,13 @@ pm.max_spare_servers = 3 ; The log file for slow requests ; Default Value: not set ; Note: slowlog is mandatory if request_slowlog_timeout is set -;slowlog = log/$pool.log.slow +slowlog = /var/log/nginx/__NAMETOCHANGE__.slow.log ; The timeout for serving a single request after which a PHP backtrace will be ; dumped to the 'slowlog' file. A value of '0s' means 'off'. ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) ; Default Value: 0 -;request_slowlog_timeout = 0 +request_slowlog_timeout = 5s ; The timeout for serving a single request after which the worker process will ; be killed. This option should be used when the 'max_execution_time' ini option @@ -365,24 +347,15 @@ chdir = __FINALPATH__ ; Note: on highloaded environement, this can cause some delay in the page ; process time (several ms). ; Default Value: no -;catch_workers_output = yes - -; Clear environment in FPM workers -; Prevents arbitrary environment variables from reaching FPM worker processes -; by clearing the environment in workers before env vars specified in this -; pool configuration are added. -; Setting to "no" will make all environment variables available to PHP code -; via getenv(), $_ENV and $_SERVER. -; Default Value: yes -;clear_env = no +catch_workers_output = yes ; Limits the extensions of the main script FPM will allow to parse. This can ; prevent configuration mistakes on the web server side. You should only limit ; FPM to .php extensions to prevent malicious users to use other extensions to -; execute php code. +; exectute php code. ; Note: set an empty value to allow all extensions. ; Default Value: .php -;security.limit_extensions = .php .php3 .php4 .php5 .php7 +;security.limit_extensions = .php .php3 .php4 .php5 ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from ; the current environment. @@ -392,7 +365,7 @@ chdir = __FINALPATH__ ;env[TMP] = /tmp ;env[TMPDIR] = /tmp ;env[TEMP] = /tmp -env[PATH] = $PATH + ; Additional php.ini defines, specific to this pool of workers. These settings ; overwrite the values previously defined in the php.ini. The directives are the ; same as the PHP SAPI: @@ -416,31 +389,4 @@ env[PATH] = $PATH ;php_flag[display_errors] = off ;php_admin_value[error_log] = /var/log/fpm-php.www.log ;php_admin_flag[log_errors] = on -;php_admin_value[memory_limit] = 32M - -; Common values to change to increase file upload limit -; php_admin_value[upload_max_filesize] = 50M -; php_admin_value[post_max_size] = 50M -; php_admin_flag[mail.add_x_header] = Off - -; Other common parameters -; php_admin_value[max_execution_time] = 600 -; php_admin_value[max_input_time] = 300 -; php_admin_value[memory_limit] = 256M -; php_admin_flag[short_open_tag] = On - -; Additional php.ini defines, specific to this pool of workers. -php_admin_value[memory_limit] = 512M -php_value[upload_max_filesize] = 10G -php_value[post_max_size] = 10G -php_value[default_charset] = UTF-8 -; OPcache is already activated by default -; php_value[opcache.enable]=1 -; The following parameters are nevertheless recommended for Nextcloud -; see here: https://docs.nextcloud.com/server/15/admin_manual/installation/server_tuning.html#enable-php-opcache -php_value[opcache.enable_cli]=1 -php_value[opcache.interned_strings_buffer]=8 -php_value[opcache.max_accelerated_files]=10000 -php_value[opcache.memory_consumption]=128 -php_value[opcache.save_comments]=1 -php_value[opcache.revalidate_freq]=1 \ No newline at end of file +;php_admin_value[memory_limit] = 32M \ No newline at end of file From df26f73ebc099ca89fdd06ad39aa17cf5103dbce Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 21:49:30 +0200 Subject: [PATCH 018/207] try to debug --- conf/php-fpm.ini | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 conf/php-fpm.ini diff --git a/conf/php-fpm.ini b/conf/php-fpm.ini new file mode 100644 index 0000000..0dab855 --- /dev/null +++ b/conf/php-fpm.ini @@ -0,0 +1,10 @@ +; Common values to change to increase file upload limit +; upload_max_filesize = 50M +; post_max_size = 50M +; mail.add_x_header = Off + +; Other common parameters +; max_execution_time = 600 +; max_input_time = 300 +; memory_limit = 256M +; short_open_tag = On \ No newline at end of file From e1080c5076076a0f500611bac7ef26ad7d18a82a Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 21:52:58 +0200 Subject: [PATCH 019/207] try to debug --- conf/php-fpm.ini | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 conf/php-fpm.ini diff --git a/conf/php-fpm.ini b/conf/php-fpm.ini deleted file mode 100644 index 0dab855..0000000 --- a/conf/php-fpm.ini +++ /dev/null @@ -1,10 +0,0 @@ -; Common values to change to increase file upload limit -; upload_max_filesize = 50M -; post_max_size = 50M -; mail.add_x_header = Off - -; Other common parameters -; max_execution_time = 600 -; max_input_time = 300 -; memory_limit = 256M -; short_open_tag = On \ No newline at end of file From a8132d23b53a9cfc6086c59a5794e52e889fb938 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 22:21:22 +0200 Subject: [PATCH 020/207] try to debug --- conf/extra_fpm-fpm.conf | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 conf/extra_fpm-fpm.conf diff --git a/conf/extra_fpm-fpm.conf b/conf/extra_fpm-fpm.conf new file mode 100644 index 0000000..969e0b6 --- /dev/null +++ b/conf/extra_fpm-fpm.conf @@ -0,0 +1,11 @@ +env[PATH] = $PATH +; Common values to change to increase file upload limit +; upload_max_filesize = 50M +; post_max_size = 50M +; mail.add_x_header = Off + +; Other common parameters +; max_execution_time = 600 +; max_input_time = 300 +; memory_limit = 256M +; short_open_tag = On \ No newline at end of file From 89b03e935ac3495175062e1d92f70cdc6aa70274 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 31 Mar 2020 22:23:26 +0200 Subject: [PATCH 021/207] try to debug --- manifest.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 9912a59..3c560c5 100644 --- a/manifest.json +++ b/manifest.json @@ -19,7 +19,8 @@ "multi_instance": true, "services": [ "nginx", - "php7.2-fpm" + "php7.2-fpm", + "mysql" ], "arguments": { "install" : [ From 355a726acb9a483696432c67a9cb2c01bf6f6fb1 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 2 Apr 2020 15:39:53 +0200 Subject: [PATCH 022/207] try update garradin --- manifest.json | 3 +- scripts/_common.sh | 203 --------------------------------------------- 2 files changed, 1 insertion(+), 205 deletions(-) diff --git a/manifest.json b/manifest.json index 3c560c5..9912a59 100644 --- a/manifest.json +++ b/manifest.json @@ -19,8 +19,7 @@ "multi_instance": true, "services": [ "nginx", - "php7.2-fpm", - "mysql" + "php7.2-fpm" ], "arguments": { "install" : [ diff --git a/scripts/_common.sh b/scripts/_common.sh index b2fe000..8c13248 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -12,54 +12,7 @@ extra_pkg_dependencies="php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php # EXPERIMENTAL HELPERS #================================================= -# Execute a command as another user -# usage: exec_as USER COMMAND [ARG ...] -exec_as() { - local USER=$1 - shift 1 - if [[ $USER = $(whoami) ]]; then - eval "$@" - else - sudo -u "$USER" "$@" - fi -} - -#================================================= - -# Check if an URL is already handled -# usage: is_url_handled --domain=DOMAIN --path=PATH_URI -is_url_handled() { - # Declare an array to define the options of this helper. - local legacy_args=dp - declare -Ar args_array=( [d]=domain= [p]=path= ) - local domain - local path - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - # Try to get the url with curl, and keep the http code and an eventual redirection url. - local curl_output="$(curl --insecure --silent --output /dev/null \ - --write-out '%{http_code};%{redirect_url}' https://127.0.0.1$path --header "Host: $domain" --resolve $domain:443:127.0.0.1)" - - # Cut the output and keep only the first part to keep the http code - local http_code="${curl_output%%;*}" - # Do the same thing but keep the second part, the redirection url - local redirection="${curl_output#*;}" - - # Return 1 if the url isn't handled. - # Which means either curl got a 404 (or the admin) or the sso. - # A handled url should redirect to a publicly accessible url. - # Return 1 if the url has returned 404 - if [ "$http_code" = "404" ] || [[ $redirection =~ "/yunohost/admin" ]]; then - return 1 - # Return 1 if the url is redirected to the SSO - elif [[ $redirection =~ "/yunohost/sso" ]]; then - return 1 - fi -} - -#================================================= # Make the main steps to migrate an app to its fork. # @@ -225,51 +178,6 @@ ynh_handle_app_migration () { # Replace final_path ynh_replace_string "\(^final_path: .*\)$old_app" "\1$new_app" "$settings_dir/$new_app/settings.yml" - #================================================= - # MOVE THE DATABASE - #================================================= - - db_pwd=$(ynh_app_setting_get $old_app mysqlpwd) - db_name=$(ynh_app_setting_get $old_app db_name) - - # Check if a database exists before trying to move it - local mysql_root_password=$(cat $MYSQL_ROOT_PWD_FILE) - if [ -n "$db_name" ] && mysqlshow -u root -p$mysql_root_password | grep -q "^| $db_name" - then - new_db_name=$(ynh_sanitize_dbid $new_app) - echo "Rename the database $db_name to $new_db_name" >&2 - - local sql_dump="/tmp/${db_name}-$(date '+%s').sql" - - # Dump the old database - ynh_mysql_dump_db "$db_name" > "$sql_dump" - - # Create a new database - ynh_mysql_setup_db $new_db_name $new_db_name $db_pwd - # Then restore the old one into the new one - ynh_mysql_connect_as $new_db_name $db_pwd $new_db_name < "$sql_dump" - - # Remove the old database - ynh_mysql_remove_db $db_name $db_name - # And the dump - ynh_secure_remove "$sql_dump" - - # Update the value of $db_name - db_name=$new_db_name - ynh_app_setting_set $new_app db_name $db_name - fi - - #================================================= - # CREATE A NEW USER - #================================================= - - # Check if the user exists on the system - if ynh_system_user_exists "$old_app" - then - echo "Create a new user $new_app to replace $old_app" >&2 - ynh_system_user_create $new_app - fi - #================================================= # CHANGE THE FAKE DEPENDENCIES PACKAGE #================================================= @@ -346,79 +254,6 @@ ynh_smart_mktemp () { #================================================= -# Check the amount of available RAM -# -# usage: ynh_check_ram [--required=RAM required in Mb] [--no_swap|--only_swap] [--free_ram] -# | arg: -r, --required= - Amount of RAM required in Mb. The helper will return 0 is there's enough RAM, or 1 otherwise. -# If --required isn't set, the helper will print the amount of RAM, in Mb. -# | arg: -s, --no_swap - Ignore swap -# | arg: -o, --only_swap - Ignore real RAM, consider only swap. -# | arg: -f, --free_ram - Count only free RAM, not the total amount of RAM available. -ynh_check_ram () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [r]=required= [s]=no_swap [o]=only_swap [f]=free_ram ) - local required - local no_swap - local only_swap - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - required=${required:-} - no_swap=${no_swap:-0} - only_swap=${only_swap:-0} - - local total_ram=$(vmstat --stats --unit M | grep "total memory" | awk '{print $1}') - local total_swap=$(vmstat --stats --unit M | grep "total swap" | awk '{print $1}') - local total_ram_swap=$(( total_ram + total_swap )) - - local free_ram=$(vmstat --stats --unit M | grep "free memory" | awk '{print $1}') - local free_swap=$(vmstat --stats --unit M | grep "free swap" | awk '{print $1}') - local free_ram_swap=$(( free_ram + free_swap )) - - # Use the total amount of ram - local ram=$total_ram_swap - if [ $free_ram -eq 1 ] - then - # Use the total amount of free ram - ram=$free_ram_swap - if [ $no_swap -eq 1 ] - then - # Use only the amount of free ram - ram=$free_ram - elif [ $only_swap -eq 1 ] - then - # Use only the amount of free swap - ram=$free_swap - fi - else - if [ $no_swap -eq 1 ] - then - # Use only the amount of free ram - ram=$total_ram - elif [ $only_swap -eq 1 ] - then - # Use only the amount of free swap - ram=$total_swap - fi - fi - - if [ -n "$required" ] - then - # Return 1 if the amount of ram isn't enough. - if [ $ram -lt $required ] - then - return 1 - else - return 0 - fi - - # If no RAM is required, return the amount of available ram. - else - echo $ram - fi -} - -#================================================= - # Define the values to configure php-fpm # # usage: ynh_get_scalable_phpfpm --usage=usage --footprint=footprint [--print] @@ -576,44 +411,6 @@ ynh_get_scalable_phpfpm () { # FUTURE OFFICIAL HELPERS #================================================= -#================================================= -# YUNOHOST MULTIMEDIA INTEGRATION -#================================================= - -# Install or update the main directory yunohost.multimedia -# -# usage: ynh_multimedia_build_main_dir -ynh_multimedia_build_main_dir () { - local ynh_media_release="v1.2" - local checksum="806a827ba1902d6911095602a9221181" - - # Download yunohost.multimedia scripts - wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz - - # Check the control sum - echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \ - || ynh_die "Corrupt source" - - # Check if the package acl is installed. Or install it. - ynh_package_is_installed 'acl' \ - || ynh_package_install acl - - # Extract - mkdir yunohost.multimedia-master - tar -xf ${ynh_media_release}.tar.gz -C yunohost.multimedia-master --strip-components 1 - ./yunohost.multimedia-master/script/ynh_media_build.sh -} - -# Grant write access to multimedia directories to a specified user -# -# usage: ynh_multimedia_addaccess user_name -# -# | arg: user_name - User to be granted write access -ynh_multimedia_addaccess () { - local user_name=$1 - groupadd -f multimedia - usermod -a -G multimedia $user_name -} # Install another version of php. # From fc35aa2e296fa450cb3af366fecf0bd5d3eca930 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 2 Apr 2020 16:34:46 +0200 Subject: [PATCH 023/207] try the upgrade without php7.2 --- conf/extra_fpm-fpm.conf | 11 - conf/nginx.conf | 2 +- manifest.json | 2 +- scripts/_common.sh | 797 +----------------------------------- scripts/_ynh_add_fpm_config | 146 ------- scripts/backup | 71 +--- scripts/config | 97 ----- scripts/install | 55 +-- scripts/remove | 131 +++--- scripts/restore | 173 ++++---- scripts/upgrade | 114 +++--- 11 files changed, 243 insertions(+), 1356 deletions(-) delete mode 100644 conf/extra_fpm-fpm.conf delete mode 100644 scripts/_ynh_add_fpm_config delete mode 100644 scripts/config diff --git a/conf/extra_fpm-fpm.conf b/conf/extra_fpm-fpm.conf deleted file mode 100644 index 969e0b6..0000000 --- a/conf/extra_fpm-fpm.conf +++ /dev/null @@ -1,11 +0,0 @@ -env[PATH] = $PATH -; Common values to change to increase file upload limit -; upload_max_filesize = 50M -; post_max_size = 50M -; mail.add_x_header = Off - -; Other common parameters -; max_execution_time = 600 -; max_input_time = 300 -; memory_limit = 256M -; short_open_tag = On \ No newline at end of file diff --git a/conf/nginx.conf b/conf/nginx.conf index e75ca8c..2ca2992 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -16,7 +16,7 @@ location __PATH__ { try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php__YNH_PHP_VERSION__-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php7.0-fpm-__NAME__.sock; # If you don't use a dedicated fpm config for your app, # use a general fpm pool. diff --git a/manifest.json b/manifest.json index 9912a59..c4b3781 100644 --- a/manifest.json +++ b/manifest.json @@ -19,7 +19,7 @@ "multi_instance": true, "services": [ "nginx", - "php7.2-fpm" + "php7.0-fpm" ], "arguments": { "install" : [ diff --git a/scripts/_common.sh b/scripts/_common.sh index 8c13248..de37a9a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,790 +1,13 @@ +#!/bin/bash -#================================================= -# COMMON VARIABLES -#================================================= - -pkg_dependencies="acl tar at" - -YNH_PHP_VERSION="7.2" -extra_pkg_dependencies="php${YNH_PHP_VERSION}-bz2 php${YNH_PHP_VERSION}-imap php${YNH_PHP_VERSION}-gmp php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-intl php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-apcu php${YNH_PHP_VERSION}-redis php${YNH_PHP_VERSION}-ldap php${YNH_PHP_VERSION}-imagick php${YNH_PHP_VERSION}-zip php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-xml php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-sqlite3" - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - - - -# Make the main steps to migrate an app to its fork. +# ============= FUTURE YUNOHOST HELPER ============= +# Delete a file checksum from the app settings # -# This helper has to be used for an app which needs to migrate to a new name or a new fork -# (like owncloud to nextcloud or zerobin to privatebin). +# $app should be defined when calling this helper # -# This helper will move the files of an app to its new name -# or recreate the things it can't move. -# -# To specify which files it has to move, you have to create a "migration file", stored in ../conf -# This file is a simple list of each file it has to move, -# except that file names must reference the $app variable instead of the real name of the app, -# and every instance-specific variables (like $domain). -# $app is especially important because it's this variable which will be used to identify the old place and the new one for each file. -# -# If a database exists for this app, it will be dumped and then imported in a newly created database, with a new name and new user. -# Don't forget you have to then apply these changes to application-specific settings (depends on the packaged application) -# -# Same things for an existing user, a new one will be created. -# But the old one can't be removed unless it's not used. See below. -# -# If you have some dependencies for your app, it's possible to change the fake debian package which manages them. -# You have to fill the $pkg_dependencies variable, and then a new fake package will be created and installed, -# and the old one will be removed. -# If you don't have a $pkg_dependencies variable, the helper can't know what the app dependencies are. -# -# The app settings.yml will be modified as follows: -# - finalpath will be changed according to the new name (but only if the existing $final_path contains the old app name) -# - The checksums of php-fpm and nginx config files will be updated too. -# - If there is a $db_name value, it will be changed. -# - And, of course, the ID will be changed to the new name too. -# -# Finally, the $app variable will take the value of the new name. -# The helper will set the $migration_process variable to 1 if a migration has been successfully handled. -# -# You have to handle by yourself all the migrations not done by this helper, like configuration or special values in settings.yml -# Also, at the end of the upgrade script, you have to add a post_migration script to handle all the things the helper can't do during YunoHost upgrade (mostly for permission reasons), -# especially remove the old user, move some hooks and remove the old configuration directory -# To launch this script, you have to move it elsewhere and start it after the upgrade script. -# `cp ../conf/$script_post_migration /tmp` -# `(cd /tmp; echo "/tmp/$script_post_migration" | at now + 2 minutes)` -# -# usage: ynh_handle_app_migration migration_id migration_list -# | arg: migration_id - ID from which to migrate -# | arg: migration_list - File specifying every file to move (one file per line) -ynh_handle_app_migration () { - #================================================= - # LOAD SETTINGS - #================================================= - - old_app=$YNH_APP_INSTANCE_NAME - local old_app_id=$YNH_APP_ID - local old_app_number=$YNH_APP_INSTANCE_NUMBER - - # Get the id from which to migrate - local migration_id="$1" - # And the file with the paths to move - local migration_list="$2" - - # Get the new app id in the manifest - local new_app_id=$(grep \"id\": ../manifest.json | cut -d\" -f4) - if [ $old_app_number -eq 1 ]; then - local new_app=$new_app_id - else - local new_app=${new_app_id}__${old_app_number} - fi - - #================================================= - # CHECK IF IT HAS TO MIGRATE - #================================================= - - migration_process=0 - - if [ "$old_app_id" == "$new_app_id" ] - then - # If the 2 id are the same - # No migration to do. - echo 0 - return 0 - else - if [ "$old_app_id" != "$migration_id" ] - then - # If the new app is not the authorized id, fail. - ynh_die "Incompatible application for migration from $old_app_id to $new_app_id" - fi - - echo "Migrate from $old_app_id to $new_app_id" >&2 - - #================================================= - # CHECK IF THE MIGRATION CAN BE DONE - #================================================= - - # TODO Handle multi instance apps... - # Check that there is not already an app installed for this id. - (yunohost app list --installed -f "$new_app" | grep -q id) \ - && ynh_die "$new_app is already installed" - - #================================================= - # CHECK THE LIST OF FILES TO MOVE - #================================================= - - local temp_migration_list="$(tempfile)" - - # Build the list by removing blank lines and comment lines - sed '/^#.*\|^$/d' "../conf/$migration_list" > "$temp_migration_list" - - # Check if there is no file in the destination - local file_to_move="" - while read file_to_move - do - # Replace all occurences of $app by $new_app in each file to move. - local move_to_destination="${file_to_move//\$app/$new_app}" - test -e "$move_to_destination" && ynh_die "A file named $move_to_destination already exists." - done < "$temp_migration_list" - - #================================================= - # COPY YUNOHOST SETTINGS FOR THIS APP - #================================================= - - local settings_dir="/etc/yunohost/apps" - cp -a "$settings_dir/$old_app" "$settings_dir/$new_app" - - # Replace the old id by the new one - ynh_replace_string "\(^id: .*\)$old_app" "\1$new_app" "$settings_dir/$new_app/settings.yml" - # INFO: There a special behavior with yunohost app setting: - # if the id given in argument does not match with the id - # stored in the config file, the config file will be purged. - # That's why we use sed instead of app setting here. - # https://github.com/YunoHost/yunohost/blob/c6b5284be8da39cf2da4e1036a730eb5e0515096/src/yunohost/app.py#L1316-L1321 - - # Change the label if it's simply the name of the app - old_label=$(ynh_app_setting_get $new_app label) - if [ "${old_label,,}" == "$old_app_id" ] - then - # Build the new label from the id of the app. With the first character as upper case - new_label=$(echo $new_app_id | cut -c1 | tr [:lower:] [:upper:])$(echo $new_app_id | cut -c2-) - ynh_app_setting_set $new_app label $new_label - fi - - #================================================= - # MOVE FILES TO THE NEW DESTINATION - #================================================= - - while read file_to_move - do - # Replace all occurence of $app by $new_app in each file to move. - move_to_destination="$(eval echo "${file_to_move//\$app/$new_app}")" - local real_file_to_move="$(eval echo "${file_to_move//\$app/$old_app}")" - echo "Move file $real_file_to_move to $move_to_destination" >&2 - mv "$real_file_to_move" "$move_to_destination" - done < "$temp_migration_list" - - #================================================= - # UPDATE SETTINGS KNOWN ENTRIES - #================================================= - - # Replace nginx checksum - ynh_replace_string "\(^checksum__etc_nginx.*\)_$old_app" "\1_$new_app/" "$settings_dir/$new_app/settings.yml" - - # Replace php5-fpm checksums - ynh_replace_string "\(^checksum__etc_php5.*[-_]\)$old_app" "\1$new_app/" "$settings_dir/$new_app/settings.yml" - - # Replace final_path - ynh_replace_string "\(^final_path: .*\)$old_app" "\1$new_app" "$settings_dir/$new_app/settings.yml" - - #================================================= - # CHANGE THE FAKE DEPENDENCIES PACKAGE - #================================================= - - # Check if a variable $pkg_dependencies exists - # If this variable doesn't exist, this part shall be managed in the upgrade script. - if [ -n "${pkg_dependencies:-}" ] - then - # Define the name of the package - local old_package_name="${old_app//_/-}-ynh-deps" - local new_package_name="${new_app//_/-}-ynh-deps" - - if ynh_package_is_installed "$old_package_name" - then - # Install a new fake package - app=$new_app - ynh_install_app_dependencies $pkg_dependencies - # Then remove the old one - app=$old_app - ynh_remove_app_dependencies - fi - fi - - #================================================= - # UPDATE THE ID OF THE APP - #================================================= - - app=$new_app - - - # Set migration_process to 1 to inform that an upgrade has been made - migration_process=1 - fi -} - -#================================================= - -# Check available space before creating a temp directory. -# -# usage: ynh_smart_mktemp --min_size="Min size" -# -# | arg: -s, --min_size= - Minimal size needed for the temporary directory, in Mb -ynh_smart_mktemp () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [s]=min_size= ) - local min_size - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - min_size="${min_size:-300}" - # Transform the minimum size from megabytes to kilobytes - min_size=$(( $min_size * 1024 )) - - # Check if there's enough free space in a directory - is_there_enough_space () { - local free_space=$(df --output=avail "$1" | sed 1d) - test $free_space -ge $min_size - } - - if is_there_enough_space /tmp; then - local tmpdir=/tmp - elif is_there_enough_space /var; then - local tmpdir=/var - elif is_there_enough_space /; then - local tmpdir=/ - elif is_there_enough_space /home; then - local tmpdir=/home - else - ynh_die "Insufficient free space to continue..." - fi - - echo "$(sudo mktemp --directory --tmpdir="$tmpdir")" -} - -#================================================= - -# Define the values to configure php-fpm -# -# usage: ynh_get_scalable_phpfpm --usage=usage --footprint=footprint [--print] -# | arg: -f, --footprint - Memory footprint of the service (low/medium/high). -# low - Less than 20Mb of ram by pool. -# medium - Between 20Mb and 40Mb of ram by pool. -# high - More than 40Mb of ram by pool. -# Or specify exactly the footprint, the load of the service as Mb by pool instead of having a standard value. -# To have this value, use the following command and stress the service. -# watch -n0.5 ps -o user,cmd,%cpu,rss -u APP -# -# | arg: -u, --usage - Expected usage of the service (low/medium/high). -# low - Personal usage, behind the sso. -# medium - Low usage, few people or/and publicly accessible. -# high - High usage, frequently visited website. -# -# | arg: -p, --print - Print the result -# -# -# -# The footprint of the service will be used to defined the maximum footprint we can allow, which is half the maximum RAM. -# So it will be used to defined 'pm.max_children' -# A lower value for the footprint will allow more children for 'pm.max_children'. And so for -# 'pm.start_servers', 'pm.min_spare_servers' and 'pm.max_spare_servers' which are defined from the -# value of 'pm.max_children' -# NOTE: 'pm.max_children' can't exceed 4 times the number of processor's cores. -# -# The usage value will defined the way php will handle the children for the pool. -# A value set as 'low' will set the process manager to 'ondemand'. Children will start only if the -# service is used, otherwise no child will stay alive. This config gives the lower footprint when the -# service is idle. But will use more proc since it has to start a child as soon it's used. -# Set as 'medium', the process manager will be at dynamic. If the service is idle, a number of children -# equal to pm.min_spare_servers will stay alive. So the service can be quick to answer to any request. -# The number of children can grow if needed. The footprint can stay low if the service is idle, but -# not null. The impact on the proc is a little bit less than 'ondemand' as there's always a few -# children already available. -# Set as 'high', the process manager will be set at 'static'. There will be always as many children as -# 'pm.max_children', the footprint is important (but will be set as maximum a quarter of the maximum -# RAM) but the impact on the proc is lower. The service will be quick to answer as there's always many -# children ready to answer. -ynh_get_scalable_phpfpm () { - local legacy_args=ufp - # Declare an array to define the options of this helper. - declare -Ar args_array=( [u]=usage= [f]=footprint= [p]=print ) - local usage - local footprint - local print - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - # Set all characters as lowercase - footprint=${footprint,,} - usage=${usage,,} - print=${print:-0} - - if [ "$footprint" = "low" ] - then - footprint=20 - elif [ "$footprint" = "medium" ] - then - footprint=35 - elif [ "$footprint" = "high" ] - then - footprint=50 - fi - - # Define the way the process manager handle child processes. - if [ "$usage" = "low" ] - then - php_pm=ondemand - elif [ "$usage" = "medium" ] - then - php_pm=dynamic - elif [ "$usage" = "high" ] - then - php_pm=static - else - ynh_die --message="Does not recognize '$usage' as an usage value." - fi - - # Get the total of RAM available, except swap. - local max_ram=$(ynh_check_ram --no_swap) - - less0() { - # Do not allow value below 1 - if [ $1 -le 0 ] - then - echo 1 - else - echo $1 - fi - } - - # Define pm.max_children - # The value of pm.max_children is the total amount of ram divide by 2 and divide again by the footprint of a pool for this app. - # So if php-fpm start the maximum of children, it won't exceed half of the ram. - php_max_children=$(( $max_ram / 2 / $footprint )) - # If process manager is set as static, use half less children. - # Used as static, there's always as many children as the value of pm.max_children - if [ "$php_pm" = "static" ] - then - php_max_children=$(( $php_max_children / 2 )) - fi - php_max_children=$(less0 $php_max_children) - - # To not overload the proc, limit the number of children to 4 times the number of cores. - local core_number=$(nproc) - local max_proc=$(( $core_number * 4 )) - if [ $php_max_children -gt $max_proc ] - then - php_max_children=$max_proc - fi - - if [ "$php_pm" = "dynamic" ] - then - # Define pm.start_servers, pm.min_spare_servers and pm.max_spare_servers for a dynamic process manager - php_min_spare_servers=$(( $php_max_children / 8 )) - php_min_spare_servers=$(less0 $php_min_spare_servers) - - php_max_spare_servers=$(( $php_max_children / 2 )) - php_max_spare_servers=$(less0 $php_max_spare_servers) - - php_start_servers=$(( $php_min_spare_servers + ( $php_max_spare_servers - $php_min_spare_servers ) /2 )) - php_start_servers=$(less0 $php_start_servers) - else - php_min_spare_servers=0 - php_max_spare_servers=0 - php_start_servers=0 - fi - - if [ $print -eq 1 ] - then - ynh_debug --message="Footprint=${footprint}Mb by pool." - ynh_debug --message="Process manager=$php_pm" - ynh_debug --message="Max RAM=${max_ram}Mb" - if [ "$php_pm" != "static" ]; then - ynh_debug --message="\nMax estimated footprint=$(( $php_max_children * $footprint ))" - ynh_debug --message="Min estimated footprint=$(( $php_min_spare_servers * $footprint ))" - fi - if [ "$php_pm" = "dynamic" ]; then - ynh_debug --message="Estimated average footprint=$(( $php_max_spare_servers * $footprint ))" - elif [ "$php_pm" = "static" ]; then - ynh_debug --message="Estimated footprint=$(( $php_max_children * $footprint ))" - fi - ynh_debug --message="\nRaw php-fpm values:" - ynh_debug --message="pm.max_children = $php_max_children" - if [ "$php_pm" = "dynamic" ]; then - ynh_debug --message="pm.start_servers = $php_start_servers" - ynh_debug --message="pm.min_spare_servers = $php_min_spare_servers" - ynh_debug --message="pm.max_spare_servers = $php_max_spare_servers" - fi - fi -} - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= - - -# Install another version of php. -# -# usage: ynh_install_php --phpversion=phpversion [--package=packages] -# | arg: -v, --phpversion - Version of php to install. -# | arg: -p, --package - Additionnal php packages to install -ynh_install_php () { - # Declare an array to define the options of this helper. - local legacy_args=vp - declare -Ar args_array=( [v]=phpversion= [p]=package= ) - local phpversion - local package - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - package=${package:-} - - # Store phpversion into the config of this app - ynh_app_setting_set $app phpversion $phpversion - - if [ "$phpversion" == "7.0" ] - then - ynh_die "Do not use ynh_install_php to install php7.0" - fi - - # Store the ID of this app and the version of php requested for it - echo "$YNH_APP_INSTANCE_NAME:$phpversion" | tee --append "/etc/php/ynh_app_version" - - # Add an extra repository for those packages - ynh_install_extra_repo --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --priority=995 --name=extra_php_version - - # Install requested dependencies from this extra repository. - # Install php-fpm first, otherwise php will install apache as a dependency. - ynh_add_app_dependencies --package="php${phpversion}-fpm" - ynh_add_app_dependencies --package="php$phpversion php${phpversion}-common $package" - - # Set php7.0 back as the default version for php-cli. - update-alternatives --set php /usr/bin/php7.0 - - # Pin this extra repository after packages are installed to prevent sury of doing shit - ynh_pin_repo --package="*" --pin="origin \"packages.sury.org\"" --priority=200 --name=extra_php_version - ynh_pin_repo --package="php7.0*" --pin="origin \"packages.sury.org\"" --priority=600 --name=extra_php_version --append - - # Advertise service in admin panel - yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log" -} - -# Remove the specific version of php used by the app. -# -# usage: ynh_install_php -ynh_remove_php () { - # Get the version of php used by this app - local phpversion=$(ynh_app_setting_get $app phpversion) - - if [ "$phpversion" == "7.0" ] || [ -z "$phpversion" ] - then - if [ "$phpversion" == "7.0" ] - then - ynh_print_err "Do not use ynh_remove_php to install php7.0" - fi - return 0 - fi - - # Remove the line for this app - sed --in-place "/$YNH_APP_INSTANCE_NAME:$phpversion/d" "/etc/php/ynh_app_version" - - # If no other app uses this version of php, remove it. - if ! grep --quiet "$phpversion" "/etc/php/ynh_app_version" - then - # Purge php dependences for this version. - ynh_package_autopurge "php$phpversion php${phpversion}-fpm php${phpversion}-common" - # Remove the service from the admin panel - yunohost service remove php${phpversion}-fpm - fi - - # If no other app uses alternate php versions, remove the extra repo for php - if [ ! -s "/etc/php/ynh_app_version" ] - then - ynh_secure_remove /etc/php/ynh_app_version - fi -} - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= -# Pin a repository. -# -# usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append] -# | arg: -p, --package - Packages concerned by the pin. Or all, *. -# | arg: -i, --pin - Filter for the pin. -# | arg: -p, --priority - Priority for the pin -# | arg: -n, --name - Name for the files for this repo, $app as default value. -# | arg: -a, --append - Do not overwrite existing files. -# -# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning. -# -ynh_pin_repo () { - # Declare an array to define the options of this helper. - local legacy_args=pirna - declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append ) - local package - local pin - local priority - local name - local append - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - package="${package:-*}" - priority=${priority:-50} - name="${name:-$app}" - append=${append:-0} - - if [ $append -eq 1 ] - then - append="tee -a" - else - append="tee" - fi - - mkdir -p "/etc/apt/preferences.d" - echo "Package: $package -Pin: $pin -Pin-Priority: $priority -" \ - | $append "/etc/apt/preferences.d/$name" -} - -# Add a repository. -# -# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append] -# | arg: -u, --uri - Uri of the repository. -# | arg: -s, --suite - Suite of the repository. -# | arg: -c, --component - Component of the repository. -# | arg: -n, --name - Name for the files for this repo, $app as default value. -# | arg: -a, --append - Do not overwrite existing files. -# -# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable -# uri suite component -# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable -# -ynh_add_repo () { - # Declare an array to define the options of this helper. - local legacy_args=uscna - declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append ) - local uri - local suite - local component - local name - local append - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - name="${name:-$app}" - append=${append:-0} - - if [ $append -eq 1 ] - then - append="tee -a" - else - append="tee" - fi - - mkdir -p "/etc/apt/sources.list.d" - # Add the new repo in sources.list.d - echo "deb $uri $suite $component" \ - | $append "/etc/apt/sources.list.d/$name.list" -} - -# Add an extra repository correctly, pin it and get the key. -# -# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append] -# | arg: -r, --repo - Complete url of the extra repository. -# | arg: -k, --key - url to get the public key. -# | arg: -p, --priority - Priority for the pin -# | arg: -n, --name - Name for the files for this repo, $app as default value. -# | arg: -a, --append - Do not overwrite existing files. -ynh_install_extra_repo () { - # Declare an array to define the options of this helper. - local legacy_args=rkpna - declare -Ar args_array=( [r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append ) - local repo - local key - local priority - local name - local append - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - name="${name:-$app}" - append=${append:-0} - key=${key:-0} - priority=${priority:-} - - if [ $append -eq 1 ] - then - append="--append" - wget_append="tee -a" - else - append="" - wget_append="tee" - fi - - # Split the repository into uri, suite and components. - # Remove "deb " at the beginning of the repo. - repo="${repo#deb }" - - # Get the uri - local uri="$(echo "$repo" | awk '{ print $1 }')" - - # Get the suite - local suite="$(echo "$repo" | awk '{ print $2 }')" - - # Get the components - local component="${repo##$uri $suite }" - - # Add the repository into sources.list.d - ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append - - # Pin the new repo with the default priority, so it won't be used for upgrades. - # Build $pin from the uri without http and any sub path - local pin="${uri#*://}" - pin="${pin%%/*}" - # Set a priority only if asked - if [ -n "$priority" ] - then - priority="--priority=$priority" - fi - ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append - - # Get the public key for the repo - if [ -n "$key" ] - then - mkdir -p "/etc/apt/trusted.gpg.d" - wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null - fi - - # Update the list of package with the new repo - ynh_package_update -} - -# Remove an extra repository and the assiociated configuration. -# -# usage: ynh_remove_extra_repo [--name=name] -# | arg: -n, --name - Name for the files for this repo, $app as default value. -ynh_remove_extra_repo () { - # Declare an array to define the options of this helper. - local legacy_args=n - declare -Ar args_array=( [n]=name= ) - local name - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - name="${name:-$app}" - - ynh_secure_remove "/etc/apt/sources.list.d/$name.list" - ynh_secure_remove "/etc/apt/preferences.d/$name" - ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg" - ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc" - - # Update the list of package to exclude the old repo - ynh_package_update -} - -# Install packages from an extra repository properly. -# -# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name] -# | arg: -r, --repo - Complete url of the extra repository. -# | arg: -p, --package - The packages to install from this extra repository -# | arg: -k, --key - url to get the public key. -# | arg: -n, --name - Name for the files for this repo, $app as default value. -ynh_install_extra_app_dependencies () { - # Declare an array to define the options of this helper. - local legacy_args=rpkn - declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= ) - local repo - local package - local key - local name - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - name="${name:-$app}" - key=${key:-0} - - # Set a key only if asked - if [ -n "$key" ] - then - key="--key=$key" - fi - # Add an extra repository for those packages - ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name - - # Install requested dependencies from this extra repository. - ynh_add_app_dependencies --package="$package" - - # Remove this extra repository after packages are installed - ynh_remove_extra_repo --name=$app -} - -#================================================= - -# patched version of ynh_install_app_dependencies to be used with ynh_add_app_dependencies - -# Define and install dependencies with a equivs control file -# This helper can/should only be called once per app -# -# usage: ynh_install_app_dependencies dep [dep [...]] -# | arg: dep - the package name to install in dependence -# You can give a choice between some package with this syntax : "dep1|dep2" -# Example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5" -# This mean in the dependence tree : dep1 & dep2 & (dep3 | dep4 | dep5) -# -# Requires YunoHost version 2.6.4 or higher. -ynh_install_app_dependencies () { - local dependencies=$@ - dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')" - dependencies=${dependencies//|/ | } - local manifest_path="../manifest.json" - if [ ! -e "$manifest_path" ]; then - manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place - fi - - local version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file. - if [ ${#version} -eq 0 ]; then - version="1.0" - fi - local dep_app=${app//_/-} # Replace all '_' by '-' - - # Handle specific versions - if [[ "$dependencies" =~ [\<=\>] ]] - then - # Replace version specifications by relationships syntax - # https://www.debian.org/doc/debian-policy/ch-relationships.html - # Sed clarification - # [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice. - # [\<=\>] matches < = or > - # \+ matches one or more occurence of the previous characters, for >= or >>. - # [^,]\+ matches all characters except ',' - # Ex: package>=1.0 will be replaced by package (>= 1.0) - dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')" - fi - - cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build -Section: misc -Priority: optional -Package: ${dep_app}-ynh-deps -Version: ${version} -Depends: ${dependencies} -Architecture: all -Description: Fake package for $app (YunoHost app) dependencies - This meta-package is only responsible of installing its dependencies. -EOF - ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \ - || ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies - rm /tmp/${dep_app}-ynh-deps.control - ynh_app_setting_set --app=$app --key=apt_dependencies --value="$dependencies" -} - -ynh_add_app_dependencies () { - # Declare an array to define the options of this helper. - local legacy_args=pr - declare -Ar args_array=( [p]=package= [r]=replace) - local package - local replace - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - replace=${replace:-0} - - local current_dependencies="" - if [ $replace -eq 0 ] - then - local dep_app=${app//_/-} # Replace all '_' by '-' - if ynh_package_is_installed --package="${dep_app}-ynh-deps" - then - current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) " - fi - - current_dependencies=${current_dependencies// | /|} - fi - - ynh_install_app_dependencies "${current_dependencies}${package}" -} +# usage: ynh_remove_file_checksum file +# | arg: file - The file for which the checksum will be deleted +ynh_delete_file_checksum () { + local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' + ynh_app_setting_delete $app $checksum_setting_name +} \ No newline at end of file diff --git a/scripts/_ynh_add_fpm_config b/scripts/_ynh_add_fpm_config deleted file mode 100644 index 69c3db4..0000000 --- a/scripts/_ynh_add_fpm_config +++ /dev/null @@ -1,146 +0,0 @@ -#!/bin/bash - -# Create a dedicated php-fpm config -# -# usage 1: ynh_add_fpm_config [--phpversion=7.X] [--use_template] -# | arg: -v, --phpversion - Version of php to use. -# | arg: -t, --use_template - Use this helper in template mode. -# -# ----------------------------------------------------------------------------- -# -# usage 2: ynh_add_fpm_config [--phpversion=7.X] --usage=usage --footprint=footprint -# | arg: -v, --phpversion - Version of php to use.# -# | arg: -f, --footprint - Memory footprint of the service (low/medium/high). -# low - Less than 20Mb of ram by pool. -# medium - Between 20Mb and 40Mb of ram by pool. -# high - More than 40Mb of ram by pool. -# Or specify exactly the footprint, the load of the service as Mb by pool instead of having a standard value. -# To have this value, use the following command and stress the service. -# watch -n0.5 ps -o user,cmd,%cpu,rss -u APP -# -# | arg: -u, --usage - Expected usage of the service (low/medium/high). -# low - Personal usage, behind the sso. -# medium - Low usage, few people or/and publicly accessible. -# high - High usage, frequently visited website. -# -# Requires YunoHost version 2.7.2 or higher. -ynh_add_fpm_config () { - # Declare an array to define the options of this helper. - local legacy_args=vtuf - declare -Ar args_array=( [v]=phpversion= [t]=use_template [u]=usage= [f]=footprint= ) - local phpversion - local use_template - local usage - local footprint - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - # The default behaviour is to use the template. - use_template="${use_template:-1}" - usage="${usage:-}" - footprint="${footprint:-}" - if [ -n "$usage" ] || [ -n "$footprint" ]; then - use_template=0 - fi - - # Configure PHP-FPM 7.0 by default - phpversion="${phpversion:-$YNH_PHP_VERSION}" - - local fpm_config_dir="/etc/php/$phpversion/fpm" - local fpm_service="php${phpversion}-fpm" - # Configure PHP-FPM 5 on Debian Jessie - if [ "$(ynh_get_debian_release)" == "jessie" ]; then - fpm_config_dir="/etc/php5/fpm" - fpm_service="php5-fpm" - fi - ynh_app_setting_set --app=$app --key=fpm_config_dir --value="$fpm_config_dir" - ynh_app_setting_set --app=$app --key=fpm_service --value="$fpm_service" - finalphpconf="$fpm_config_dir/pool.d/$app.conf" - ynh_backup_if_checksum_is_different --file="$finalphpconf" - - if [ $use_template -eq 1 ] - then - # Usage 1, use the template in ../conf/php-fpm.conf - sudo cp ../conf/php-fpm.conf "$finalphpconf" - ynh_replace_string --match_string="__NAMETOCHANGE__" --replace_string="$app" --target_file="$finalphpconf" - ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$finalphpconf" - ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="$finalphpconf" - ynh_replace_string --match_string="__PHPVERSION__" --replace_string="$phpversion" --target_file="$finalphpconf" - - else - # Usage 2, generate a php-fpm config file with ynh_get_scalable_phpfpm - ynh_get_scalable_phpfpm --usage=$usage --footprint=$footprint - - # Copy the default file - sudo cp "$fpm_config_dir/pool.d/www.conf" "$finalphpconf" - - # Replace standard variables into the default file - ynh_replace_string --match_string="^\[www\]" --replace_string="[$app]" --target_file="$finalphpconf" - ynh_replace_string --match_string=".*listen = .*" --replace_string="listen = /var/run/php/php$phpversion-fpm-$app.sock" --target_file="$finalphpconf" - ynh_replace_string --match_string="^user = .*" --replace_string="user = $app" --target_file="$finalphpconf" - ynh_replace_string --match_string="^group = .*" --replace_string="group = $app" --target_file="$finalphpconf" - ynh_replace_string --match_string=".*chdir = .*" --replace_string="chdir = $final_path" --target_file="$finalphpconf" - - # Configure fpm children - ynh_replace_string --match_string=".*pm = .*" --replace_string="pm = $php_pm" --target_file="$finalphpconf" - ynh_replace_string --match_string=".*pm.max_children = .*" --replace_string="pm.max_children = $php_max_children" --target_file="$finalphpconf" - ynh_replace_string --match_string=".*pm.max_requests = .*" --replace_string="pm.max_requests = 500" --target_file="$finalphpconf" - ynh_replace_string --match_string=".*request_terminate_timeout = .*" --replace_string="request_terminate_timeout = 1d" --target_file="$finalphpconf" - if [ "$php_pm" = "dynamic" ] - then - ynh_replace_string --match_string=".*pm.start_servers = .*" --replace_string="pm.start_servers = $php_start_servers" --target_file="$finalphpconf" - ynh_replace_string --match_string=".*pm.min_spare_servers = .*" --replace_string="pm.min_spare_servers = $php_min_spare_servers" --target_file="$finalphpconf" - ynh_replace_string --match_string=".*pm.max_spare_servers = .*" --replace_string="pm.max_spare_servers = $php_max_spare_servers" --target_file="$finalphpconf" - elif [ "$php_pm" = "ondemand" ] - then - ynh_replace_string --match_string=".*pm.process_idle_timeout = .*" --replace_string="pm.process_idle_timeout = 10s" --target_file="$finalphpconf" - fi - - # Comment unused parameters - if [ "$php_pm" != "dynamic" ] - then - ynh_replace_string --match_string=".*\(pm.start_servers = .*\)" --replace_string=";\1" --target_file="$finalphpconf" - ynh_replace_string --match_string=".*\(pm.min_spare_servers = .*\)" --replace_string=";\1" --target_file="$finalphpconf" - ynh_replace_string --match_string=".*\(pm.max_spare_servers = .*\)" --replace_string=";\1" --target_file="$finalphpconf" - fi - if [ "$php_pm" != "ondemand" ] - then - ynh_replace_string --match_string=".*\(pm.process_idle_timeout = .*\)" --replace_string=";\1" --target_file="$finalphpconf" - fi - - # Concatene the extra config. - if [ -e ../conf/extra_php-fpm.conf ]; then - cat ../conf/extra_php-fpm.conf >> "$finalphpconf" - fi - fi - sudo chown root: "$finalphpconf" - ynh_store_file_checksum --file="$finalphpconf" - - if [ -e "../conf/php-fpm.ini" ] - then - echo "Packagers ! Please do not use a separate php ini file, merge your directives in the pool file instead." >&2 - finalphpini="$fpm_config_dir/conf.d/20-$app.ini" - ynh_backup_if_checksum_is_different "$finalphpini" - sudo cp ../conf/php-fpm.ini "$finalphpini" - sudo chown root: "$finalphpini" - ynh_store_file_checksum "$finalphpini" - fi - ynh_systemd_action --service_name=$fpm_service --action=reload - - # Clean other php version config files for this app. Used for migration purpose. - if [ -e "/etc/php5/fpm/pool.d/$app.conf" ] - then - ynh_secure_remove --file="/etc/php5/fpm/pool.d/$app.conf" - ynh_systemd_action --service_name=php5-fpm --action=reload - fi - for i in `seq 0 4` - do - if [ "$phpversion" != "7.$i" ] - then - if [ -e "/etc/php/7.$i/fpm/pool.d/$app.conf" ] - then - ynh_secure_remove --file="/etc/php/7.$i/fpm/pool.d/$app.conf" - ynh_systemd_action --service_name=php7.$i-fpm --action=reload - fi - fi - done -} \ No newline at end of file diff --git a/scripts/backup b/scripts/backup index df35941..0aeaf10 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,12 @@ # IMPORT GENERIC HELPERS #================================================= -source ../settings/scripts/_common.sh +if [ ! -e _common.sh ]; then + # Get the _common.sh file if it's not in the current directory + cp ../settings/scripts/_common.sh ./_common.sh + chmod a+rx _common.sh +fi +source _common.sh source /usr/share/yunohost/helpers #================================================= @@ -19,76 +24,40 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -domain=$(ynh_app_setting_get --app=$app --key=domain) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) +final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get $app domain) #================================================= # STANDARD BACKUP STEPS #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_script_progression --message="Backing up the main app directory..." -ynh_backup --src_path="$final_path" +ynh_backup "$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Backing up nginx web server configuration..." -ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Backing up php-fpm configuration..." -ynh_backup --src_path="/etc/php/$YNH_PHP_VERSION/fpm/pool.d/$app.conf" +ynh_backup "/etc/php7/fpm/pool.d/$app.conf" +ynh_backup "/etc/php7/fpm/conf.d/20-$app.ini" -#================================================= -# BACKUP THE MYSQL DATABASE -#================================================= -ynh_script_progression --message="Backing up the MySQL database..." --weight=2 +# Backup directory location for the app from where the script is executed and +# which will be compressed afterward +backup_dir=$YNH_APP_BACKUP_DIR -ynh_mysql_dump_db --database="$db_name" > db.sql +# Backup sources & data +ynh_backup "/var/www/$app" "sources" -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= -ynh_script_progression --message="Backing up logrotate configuration..." - -ynh_backup "/etc/logrotate.d/$app" - -#================================================= -# BACKUP FAIL2BAN CONFIGURATION -#================================================= -ynh_script_progression --message="Backing up fail2ban configuration..." - -ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" -ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" - -#================================================= -# BACKUP THE CRON FILE -#================================================= - -ynh_backup --src_path="/etc/cron.d/$app" - -#================================================= -# BACKUP THE DATA DIRECTORY -#================================================= -ynh_script_progression --message="Backing up data directory..." - -ynh_backup --src_path="/home/yunohost.app/${app}/data" --is_big - -#================================================= -# END OF SCRIPT -#================================================= - -ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last \ No newline at end of file +# Copy Nginx conf +sudo mkdir -p ./conf +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "conf/nginx.conf" \ No newline at end of file diff --git a/scripts/config b/scripts/config deleted file mode 100644 index 50ae8b1..0000000 --- a/scripts/config +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash - -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -source _common.sh -source /usr/share/yunohost/helpers -source _ynh_add_fpm_config - -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} - -#================================================= -# LOAD VALUES -#================================================= - -# Load the real value from the app config or elsewhere. -# Then get the value from the form. -# If the form has a value for a variable, take the value from the form, -# Otherwise, keep the value from the app config. - -# Footprint for php-fpm -old_fpm_footprint="$(ynh_app_setting_get --app=$app --key=fpm_footprint)" -fpm_footprint="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FOOTPRINT:-$old_fpm_footprint}" - -# Free footprint value for php-fpm -# Check if fpm_footprint is an integer -if [ "$fpm_footprint" -eq "$fpm_footprint" ] 2> /dev/null -then - # If fpm_footprint is an integer, that's a numeric value for the footprint - old_free_footprint=$fpm_footprint - fpm_footprint=specific -else - old_free_footprint=0 -fi -free_footprint="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT:-$old_free_footprint}" - -# Usage for php-fpm -old_fpm_usage="$(ynh_app_setting_get --app=$app --key=fpm_usage)" -fpm_usage="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE:-$old_fpm_usage}" - -#================================================= -# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND -#================================================= - -show_config() { - # here you are supposed to read some config file/database/other then print the values - # ynh_return "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value" - - ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FOOTPRINT=$fpm_footprint" - ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT=$free_footprint" - ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE=$fpm_usage" -} - -#================================================= -# MODIFY THE CONFIGURATION -#================================================= - -apply_config() { - - #================================================= - # RECONFIGURE PHP-FPM - #================================================= - - if [ "$fpm_usage" != "$old_fpm_usage" ] || [ "$fpm_footprint" != "$old_fpm_footprint" ] || [ "$free_footprint" != "$old_free_footprint" ] - then - # If fpm_footprint is set to 'specific', use $free_footprint value. - if [ "$fpm_footprint" = "specific" ] - then - fpm_footprint=$free_footprint - fi - - if [ "$fpm_footprint" != "0" ] - then - ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint - else - ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below." - fi - fi -} - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SELECT THE ACTION FOLLOWING THE GIVEN ARGUMENT -#================================================= - -case $1 in - show) show_config;; - apply) apply_config;; -esac \ No newline at end of file diff --git a/scripts/install b/scripts/install index fb8f3a6..1bbd556 100644 --- a/scripts/install +++ b/scripts/install @@ -8,7 +8,6 @@ source _common.sh source /usr/share/yunohost/helpers -source _ynh_add_fpm_config #================================================= # MANAGE SCRIPT FAILURE @@ -31,8 +30,6 @@ app=$YNH_APP_INSTANCE_NAME # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." - final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -55,21 +52,13 @@ ynh_app_setting_set $app is_public $is_public #================================================= # Install dependency to convert tracks to a readable format for the browser #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=60 -ynh_install_php --phpversion="$YNH_PHP_VERSION" --package="$extra_pkg_dependencies" - -ynh_install_app_dependencies $pkg_dependencies - - -#================================================= -# CREATE A MYSQL DATABASE -#================================================= -ynh_script_progression --message="Creating a MySQL database..." --weight=2 - -db_name=$(ynh_sanitize_dbid --db_name=$app) -ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name +if [ "$(lsb_release --codename --short)" != "jessie" ] +then + ynh_install_app_dependencies php7.0-sqlite3 +else + ynh_install_app_dependencies php5-sqlite +fi #================================================= # CREATE DEDICATED USER @@ -98,50 +87,32 @@ sudo chmod 755 $final_path -R #================================================= # Create a dedicated nginx config -ynh_add_nginx_config YNH_PHP_VERSION +ynh_add_nginx_config #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring php-fpm..." --weight=2 # Create a dedicated php-fpm config -ynh_add_fpm_config --usage=medium --footprint=high - -#================================================= -# STORE THE CHECKSUM OF THE CONFIG FILE -#================================================= - -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$final_path/config/config.php" +ynh_add_fpm_config #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." - if [ $is_public -eq 0 ] -then # Remove the public access - ynh_app_setting_delete $app skipped_uris +then # Remove the public access + ynh_app_setting_delete $app skipped_uris fi # Make app public if necessary if [ $is_public -eq 1 ] then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set $app unprotected_uris "/" + # unprotected_uris allows SSO credentials to be passed anyway. + ynh_app_setting_set $app unprotected_uris "/" fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." - -ynh_systemd_action --service_name=nginx --action=reload - -#================================================= -# END OF SCRIPT -#================================================= - -ynh_script_progression --message="Installation of $app completed" --last +systemctl reload nginx \ No newline at end of file diff --git a/scripts/remove b/scripts/remove index 06899f5..8df465c 100644 --- a/scripts/remove +++ b/scripts/remove @@ -10,84 +10,109 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# LOAD SETTINGS +# MANAGE SCRIPT FAILURE #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# Retrieve arguments +#================================================= + +domain=$YNH_APP_ARG_DOMAIN +path_url=$YNH_APP_ARG_PATH +is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get --app=$app --key=domain) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - #================================================= -# REMOVE DEPENDENCIES +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Removing logrotate configuration..." -# Remove metapackage and its dependencies -ynh_remove_app_dependencies +final_path=/var/www/$app +test ! -e "$final_path" || ynh_die "This path already contains a folder" + +# Normalize the url path syntax +path_url=$(ynh_normalize_url_path $path_url) + +# Check web path availability +ynh_webpath_available $domain $path_url +# Register (book) web path +ynh_webpath_register $app $domain $path_url #================================================= -# REMOVE THE MYSQL DATABASE -#================================================= -ynh_script_progression --message="Removing the MySQL database..." --weight=5 - -# Remove a database if it exists, along with the associated user -ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name - -#================================================= -# REMOVE APP MAIN DIR +# STORE SETTINGS FROM MANIFEST #================================================= -# Remove the app directory securely -ynh_secure_remove "$final_path" +ynh_app_setting_set $app path_url $path_url +ynh_app_setting_set $app domain $domain +ynh_app_setting_set $app is_public $is_public #================================================= -# REMOVE NGINX CONFIGURATION +# Install dependency to convert tracks to a readable format for the browser #================================================= -# Remove the dedicated nginx config -ynh_remove_nginx_config +if [ "$(lsb_release --codename --short)" != "jessie" ] +then + ynh_install_app_dependencies php-sqlite3 +else + ynh_install_app_dependencies php5-sqlite +fi #================================================= -# REMOVE PHP-FPM CONFIGURATION +# CREATE DEDICATED USER #================================================= -# Remove the dedicated php-fpm config -ynh_remove_fpm_config +# Create a system user +ynh_system_user_create $app #================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." - -# Remove the app-specific logrotate config -ynh_remove_logrotate - -#================================================= -# CLEAN ACL IN HOME DIRECTORIES +# DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -for i in $(ls /home); do - # Clean ACL in every directories in /home, except those which start with 'yunohost.' - [[ ! $i == yunohost.* ]] \ - && setfacl --remove g:$app:rwx 2>&1 -done +ynh_app_setting_set $app final_path $final_path +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source "$final_path" #================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." - -# Delete a system user -ynh_system_user_delete $app - -#================================================= -# END OF SCRIPT +# Files owned by user app #================================================= -ynh_script_progression --message="Removal of $app completed" --last +sudo chown $app:$app $final_path -R +sudo chmod 755 $final_path -R + +#================================================= +# NGINX CONFIGURATION +#================================================= + +# Create a dedicated nginx config +ynh_add_nginx_config + +#================================================= +# PHP-FPM CONFIGURATION +#================================================= + +# Create a dedicated php-fpm config +ynh_add_fpm_config + +#================================================= +# SETUP SSOWAT +#================================================= + +if [ $is_public -eq 0 ] +then # Remove the public access + ynh_app_setting_delete $app skipped_uris +fi +# Make app public if necessary +if [ $is_public -eq 1 ] +then + # unprotected_uris allows SSO credentials to be passed anyway. + ynh_app_setting_set $app unprotected_uris "/" +fi + +#================================================= +# RELOAD NGINX +#================================================= + +systemctl reload nginx \ No newline at end of file diff --git a/scripts/restore b/scripts/restore index fdf3e9b..46203de 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,14 +6,8 @@ # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Get the _common.sh file if it's not in the current directory - cp ../settings/scripts/_common.sh ./_common.sh - chmod a+rx _common.sh -fi source _common.sh source /usr/share/yunohost/helpers -source _ynh_add_fpm_config #================================================= # MANAGE SCRIPT FAILURE @@ -23,131 +17,102 @@ source _ynh_add_fpm_config ynh_abort_if_errors #================================================= -# LOAD SETTINGS +# Retrieve arguments #================================================= -ynh_script_progression --message="Loading settings..." + +domain=$YNH_APP_ARG_DOMAIN +path_url=$YNH_APP_ARG_PATH +is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -final_path=$(ynh_app_setting_get $app final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) - #================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=4 - -ynh_webpath_available $domain $path_url \ - || ynh_die "Path not available: ${domain}${path_url}" -test ! -d $final_path \ - || ynh_die "There is already a directory: $final_path " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" +final_path=/var/www/$app +test ! -e "$final_path" || ynh_die "This path already contains a folder" + +# Normalize the url path syntax +path_url=$(ynh_normalize_url_path $path_url) + +# Check web path availability +ynh_webpath_available $domain $path_url +# Register (book) web path +ynh_webpath_register $app $domain $path_url #================================================= -# RESTORE THE APP MAIN DIR -#================================================= -ynh_script_progression --message="Restoring the app main directory..." - -ynh_restore_file "$final_path" - -#================================================= -# RESTORE THE MYSQL DATABASE -#================================================= -ynh_script_progression --message="Restoring the MySQL database..." --weight=9 - -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd -ynh_mysql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql - -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=3 - -# Create the dedicated user (if not existing) -ynh_system_user_create $app - -#================================================= -# RESTORE THE PHP-FPM CONFIGURATION +# STORE SETTINGS FROM MANIFEST #================================================= -ynh_restore_file --origin_path="/etc/php/$YNH_PHP_VERSION/fpm/pool.d/$app.conf" - +ynh_app_setting_set $app path_url $path_url +ynh_app_setting_set $app domain $domain +ynh_app_setting_set $app is_public $is_public #================================================= -# RESTORE THE PHP-FPM CONFIGURATION +# Install dependency to convert tracks to a readable format for the browser #================================================= + if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_restore_file "/etc/php/7.2/fpm/pool.d/$app.conf" - ynh_restore_file "/etc/php/7.2/fpm/conf.d/20-$app.ini" + ynh_install_app_dependencies php-sqlite3 else - ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf" - ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini" + ynh_install_app_dependencies php5-sqlite fi #================================================= -# SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=60 - -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies - -ynh_install_php --phpversion="$YNH_PHP_VERSION" --package="$extra_pkg_dependencies" - -#================================================= -# BACKUP THE LOGROTATE CONFIGURATION +# CREATE DEDICATED USER #================================================= -ynh_restore_file --origin_path="/etc/logrotate.d/$app" - +# Create a system user +ynh_system_user_create $app #================================================= -# RESTORE THE DATA DIRECTORY -#================================================= -ynh_script_progression --message="Restoring data directory..." --weight=2 - -datadir="/home/yunohost.app/$app/data" - -# Use --not_mandatory for the data directory, because if the backup has been made with BACKUP_CORE_ONLY, there's no data into the backup. -ynh_restore_file --origin_path="$datadir" --not_mandatory - -mkdir -p "$datadir" - -#================================================= -# RESTORE USER RIGHTS +# DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -# Fix app ownerships & permissions -chown -R $app: "$final_path" "$datadir" -chmod 640 "$final_path/config/config.php" -chmod 755 /home/yunohost.app - +ynh_app_setting_set $app final_path $final_path +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source "$final_path" #================================================= -# GENERIC FINALIZATION -#================================================= -# RELOAD NGINX AND PHP-FPM -#================================================= -ynh_script_progression --message="Reloading nginx web server and php-fpm..." - -ynh_systemd_action --service_name=php${YNH_PHP_VERSION}-fpm --action=reload -ynh_systemd_action --service_name=nginx --action=reload - -#================================================= -# END OF SCRIPT +# Files owned by user app #================================================= -ynh_script_progression --message="Restoration completed for $app" --last \ No newline at end of file +sudo chown $app:$app $final_path -R +sudo chmod 755 $final_path -R + +#================================================= +# NGINX CONFIGURATION +#================================================= + +# Create a dedicated nginx config +ynh_add_nginx_config + +#================================================= +# PHP-FPM CONFIGURATION +#================================================= + +# Create a dedicated php-fpm config +ynh_add_fpm_config + +#================================================= +# SETUP SSOWAT +#================================================= + +if [ $is_public -eq 0 ] +then # Remove the public access + ynh_app_setting_delete $app skipped_uris +fi +# Make app public if necessary +if [ $is_public -eq 1 ] +then + # unprotected_uris allows SSO credentials to be passed anyway. + ynh_app_setting_set $app unprotected_uris "/" +fi + +#================================================= +# RELOAD NGINX +#================================================= + +systemctl reload nginx \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index f9c7584..46203de 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -10,46 +10,44 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# LOAD SETTINGS +# MANAGE SCRIPT FAILURE #================================================= +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# Retrieve arguments +#================================================= + +domain=$YNH_APP_ARG_DOMAIN +path_url=$YNH_APP_ARG_PATH +is_public=$YNH_APP_ARG_IS_PUBLIC + app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -is_public=$(ynh_app_setting_get $app is_public) - #================================================= -# ENSURE DOWNWARD COMPATIBILITY +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -# Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set $app is_public 1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set $app is_public 0 - is_public=0 -fi +final_path=/var/www/$app +test ! -e "$final_path" || ynh_die "This path already contains a folder" -# If final_path doesn't exist, create it -if [ -z $final_path ]; then - final_path=/var/www/$app - ynh_app_setting_set $app final_path $final_path -fi +# Normalize the url path syntax +path_url=$(ynh_normalize_url_path $path_url) + +# Check web path availability +ynh_webpath_available $domain $path_url +# Register (book) web path +ynh_webpath_register $app $domain $path_url #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# STORE SETTINGS FROM MANIFEST #================================================= -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors +ynh_app_setting_set $app path_url $path_url +ynh_app_setting_set $app domain $domain +ynh_app_setting_set $app is_public $is_public #================================================= # Install dependency to convert tracks to a readable format for the browser @@ -57,34 +55,11 @@ ynh_abort_if_errors if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_install_app_dependencies php7.2-sqlite3 + ynh_install_app_dependencies php-sqlite3 else ynh_install_app_dependencies php5-sqlite fi -#================================================= -# CHECK THE PATH -#================================================= - -# Normalize the URL path syntax -path_url=$(ynh_normalize_url_path $path_url) - -#================================================= -# STANDARD UPGRADE STEPS -#================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE -#================================================= - -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" - -#================================================= -# NGINX CONFIGURATION -#================================================= - -# Create a dedicated nginx config -ynh_add_nginx_config - #================================================= # CREATE DEDICATED USER #================================================= @@ -92,6 +67,28 @@ ynh_add_nginx_config # Create a system user ynh_system_user_create $app +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= + +ynh_app_setting_set $app final_path $final_path +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source "$final_path" + +#================================================= +# Files owned by user app +#================================================= + +sudo chown $app:$app $final_path -R +sudo chmod 755 $final_path -R + +#================================================= +# NGINX CONFIGURATION +#================================================= + +# Create a dedicated nginx config +ynh_add_nginx_config + #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -99,15 +96,6 @@ ynh_system_user_create $app # Create a dedicated php-fpm config ynh_add_fpm_config -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set right permissions for curl installation -chown -R $app:$app $final_path - #================================================= # SETUP SSOWAT #================================================= @@ -119,7 +107,7 @@ fi # Make app public if necessary if [ $is_public -eq 1 ] then - # unprotected_uris allows SSO credentials to be passed anyway + # unprotected_uris allows SSO credentials to be passed anyway. ynh_app_setting_set $app unprotected_uris "/" fi @@ -127,4 +115,4 @@ fi # RELOAD NGINX #================================================= -systemctl reload nginx +systemctl reload nginx \ No newline at end of file From 2fb37a895177b029bcf18de2fa259a4136a4eade Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 2 Apr 2020 17:07:48 +0200 Subject: [PATCH 024/207] try to debug --- conf/php-fpm.ini | 10 ++++++++++ scripts/backup | 4 ++-- scripts/remove | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 conf/php-fpm.ini diff --git a/conf/php-fpm.ini b/conf/php-fpm.ini new file mode 100644 index 0000000..0dab855 --- /dev/null +++ b/conf/php-fpm.ini @@ -0,0 +1,10 @@ +; Common values to change to increase file upload limit +; upload_max_filesize = 50M +; post_max_size = 50M +; mail.add_x_header = Off + +; Other common parameters +; max_execution_time = 600 +; max_input_time = 300 +; memory_limit = 256M +; short_open_tag = On \ No newline at end of file diff --git a/scripts/backup b/scripts/backup index 0aeaf10..d7d42af 100644 --- a/scripts/backup +++ b/scripts/backup @@ -48,8 +48,8 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_backup "/etc/php7/fpm/pool.d/$app.conf" -ynh_backup "/etc/php7/fpm/conf.d/20-$app.ini" +ynh_backup "/etc/php7.0/fpm/pool.d/$app.conf" +ynh_backup "/etc/php7.0/fpm/conf.d/20-$app.ini" # Backup directory location for the app from where the script is executed and # which will be compressed afterward diff --git a/scripts/remove b/scripts/remove index 8df465c..1bbd556 100644 --- a/scripts/remove +++ b/scripts/remove @@ -55,7 +55,7 @@ ynh_app_setting_set $app is_public $is_public if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_install_app_dependencies php-sqlite3 + ynh_install_app_dependencies php7.0-sqlite3 else ynh_install_app_dependencies php5-sqlite fi diff --git a/scripts/restore b/scripts/restore index 46203de..3b5972a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -55,7 +55,7 @@ ynh_app_setting_set $app is_public $is_public if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_install_app_dependencies php-sqlite3 + ynh_install_app_dependencies php7.0-sqlite3 else ynh_install_app_dependencies php5-sqlite fi diff --git a/scripts/upgrade b/scripts/upgrade index 46203de..3b5972a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -55,7 +55,7 @@ ynh_app_setting_set $app is_public $is_public if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_install_app_dependencies php-sqlite3 + ynh_install_app_dependencies php7.0-sqlite3 else ynh_install_app_dependencies php5-sqlite fi From f54c767d2a0f89692c98647486062267b5d6814f Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 2 Apr 2020 17:28:53 +0200 Subject: [PATCH 025/207] try to debug --- conf/nginx.conf | 2 +- manifest.json | 2 +- scripts/backup | 4 ++-- scripts/install | 2 +- scripts/remove | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 2ca2992..eded69c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -16,7 +16,7 @@ location __PATH__ { try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php7.0-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php-fpm-__NAME__.sock; # If you don't use a dedicated fpm config for your app, # use a general fpm pool. diff --git a/manifest.json b/manifest.json index c4b3781..f494929 100644 --- a/manifest.json +++ b/manifest.json @@ -19,7 +19,7 @@ "multi_instance": true, "services": [ "nginx", - "php7.0-fpm" + "php-fpm" ], "arguments": { "install" : [ diff --git a/scripts/backup b/scripts/backup index d7d42af..708b3c2 100644 --- a/scripts/backup +++ b/scripts/backup @@ -48,8 +48,8 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_backup "/etc/php7.0/fpm/pool.d/$app.conf" -ynh_backup "/etc/php7.0/fpm/conf.d/20-$app.ini" +ynh_backup "/etc/php/fpm/pool.d/$app.conf" +ynh_backup "/etc/php/fpm/conf.d/20-$app.ini" # Backup directory location for the app from where the script is executed and # which will be compressed afterward diff --git a/scripts/install b/scripts/install index 1bbd556..8df465c 100644 --- a/scripts/install +++ b/scripts/install @@ -55,7 +55,7 @@ ynh_app_setting_set $app is_public $is_public if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_install_app_dependencies php7.0-sqlite3 + ynh_install_app_dependencies php-sqlite3 else ynh_install_app_dependencies php5-sqlite fi diff --git a/scripts/remove b/scripts/remove index 1bbd556..8df465c 100644 --- a/scripts/remove +++ b/scripts/remove @@ -55,7 +55,7 @@ ynh_app_setting_set $app is_public $is_public if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_install_app_dependencies php7.0-sqlite3 + ynh_install_app_dependencies php-sqlite3 else ynh_install_app_dependencies php5-sqlite fi diff --git a/scripts/restore b/scripts/restore index 3b5972a..46203de 100644 --- a/scripts/restore +++ b/scripts/restore @@ -55,7 +55,7 @@ ynh_app_setting_set $app is_public $is_public if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_install_app_dependencies php7.0-sqlite3 + ynh_install_app_dependencies php-sqlite3 else ynh_install_app_dependencies php5-sqlite fi diff --git a/scripts/upgrade b/scripts/upgrade index 3b5972a..46203de 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -55,7 +55,7 @@ ynh_app_setting_set $app is_public $is_public if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_install_app_dependencies php7.0-sqlite3 + ynh_install_app_dependencies php-sqlite3 else ynh_install_app_dependencies php5-sqlite fi From ca21b98aa5f4425e2ae0fdad9e6ec460bfd7d9b2 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 2 Apr 2020 18:02:34 +0200 Subject: [PATCH 026/207] try to debug --- conf/nginx.conf | 2 +- manifest.json | 2 +- scripts/backup | 4 +- scripts/install | 2 +- scripts/remove | 102 +++++++---------------------------- scripts/restore | 139 ++++++++++++++++++++++-------------------------- scripts/upgrade | 2 +- 7 files changed, 90 insertions(+), 163 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index eded69c..7a2ff02 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -16,7 +16,7 @@ location __PATH__ { try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; # If you don't use a dedicated fpm config for your app, # use a general fpm pool. diff --git a/manifest.json b/manifest.json index f494929..c4b3781 100644 --- a/manifest.json +++ b/manifest.json @@ -19,7 +19,7 @@ "multi_instance": true, "services": [ "nginx", - "php-fpm" + "php7.0-fpm" ], "arguments": { "install" : [ diff --git a/scripts/backup b/scripts/backup index 708b3c2..e8b2422 100644 --- a/scripts/backup +++ b/scripts/backup @@ -48,8 +48,8 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_backup "/etc/php/fpm/pool.d/$app.conf" -ynh_backup "/etc/php/fpm/conf.d/20-$app.ini" +ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf" +ynh_backup "/etc/php/7.0/fpm/conf.d/20-$app.ini" # Backup directory location for the app from where the script is executed and # which will be compressed afterward diff --git a/scripts/install b/scripts/install index 8df465c..1bbd556 100644 --- a/scripts/install +++ b/scripts/install @@ -55,7 +55,7 @@ ynh_app_setting_set $app is_public $is_public if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_install_app_dependencies php-sqlite3 + ynh_install_app_dependencies php7.0-sqlite3 else ynh_install_app_dependencies php5-sqlite fi diff --git a/scripts/remove b/scripts/remove index 8df465c..079d4d3 100644 --- a/scripts/remove +++ b/scripts/remove @@ -10,109 +10,47 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# MANAGE SCRIPT FAILURE +# LOAD SETTINGS #================================================= -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# Retrieve arguments -#================================================= - -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC - app=$YNH_APP_INSTANCE_NAME -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= - -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die "This path already contains a folder" - -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) - -# Check web path availability -ynh_webpath_available $domain $path_url -# Register (book) web path -ynh_webpath_register $app $domain $path_url +domain=$(ynh_app_setting_get $app domain) +final_path=$(ynh_app_setting_get $app final_path) #================================================= -# STORE SETTINGS FROM MANIFEST +# REMOVE DEPENDENCIES #================================================= -ynh_app_setting_set $app path_url $path_url -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app is_public $is_public +# Remove metapackage and its dependencies +ynh_remove_app_dependencies #================================================= -# Install dependency to convert tracks to a readable format for the browser +# REMOVE APP MAIN DIR #================================================= -if [ "$(lsb_release --codename --short)" != "jessie" ] -then - ynh_install_app_dependencies php-sqlite3 -else - ynh_install_app_dependencies php5-sqlite -fi +# Remove the app directory securely +ynh_secure_remove "$final_path" #================================================= -# CREATE DEDICATED USER +# REMOVE NGINX CONFIGURATION #================================================= -# Create a system user -ynh_system_user_create $app +# Remove the dedicated nginx config +ynh_remove_nginx_config #================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE +# REMOVE PHP-FPM CONFIGURATION #================================================= -ynh_app_setting_set $app final_path $final_path -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +# Remove the dedicated php-fpm config +ynh_remove_fpm_config #================================================= -# Files owned by user app +# GENERIC FINALIZATION +#================================================= +# REMOVE DEDICATED USER #================================================= -sudo chown $app:$app $final_path -R -sudo chmod 755 $final_path -R - -#================================================= -# NGINX CONFIGURATION -#================================================= - -# Create a dedicated nginx config -ynh_add_nginx_config - -#================================================= -# PHP-FPM CONFIGURATION -#================================================= - -# Create a dedicated php-fpm config -ynh_add_fpm_config - -#================================================= -# SETUP SSOWAT -#================================================= - -if [ $is_public -eq 0 ] -then # Remove the public access - ynh_app_setting_delete $app skipped_uris -fi -# Make app public if necessary -if [ $is_public -eq 1 ] -then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set $app unprotected_uris "/" -fi - -#================================================= -# RELOAD NGINX -#================================================= - -systemctl reload nginx \ No newline at end of file +# Delete a system user +ynh_system_user_delete $app \ No newline at end of file diff --git a/scripts/restore b/scripts/restore index 46203de..61e3b2a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,11 @@ # IMPORT GENERIC HELPERS #================================================= +if [ ! -e _common.sh ]; then + # Get the _common.sh file if it's not in the current directory + cp ../settings/scripts/_common.sh ./_common.sh + chmod a+rx _common.sh +fi source _common.sh source /usr/share/yunohost/helpers @@ -17,102 +22,86 @@ source /usr/share/yunohost/helpers ynh_abort_if_errors #================================================= -# Retrieve arguments +# LOAD SETTINGS #================================================= -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC - app=$YNH_APP_INSTANCE_NAME -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= - -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die "This path already contains a folder" - -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) - -# Check web path availability -ynh_webpath_available $domain $path_url -# Register (book) web path -ynh_webpath_register $app $domain $path_url +domain=$(ynh_app_setting_get $app domain) +path_url=$(ynh_app_setting_get $app path) +final_path=$(ynh_app_setting_get $app final_path) #================================================= -# STORE SETTINGS FROM MANIFEST +# CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_app_setting_set $app path_url $path_url -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app is_public $is_public +ynh_webpath_available $domain $path_url \ + || ynh_die "Path not available: ${domain}${path_url}" +test ! -d $final_path \ + || ynh_die "There is already a directory: $final_path " #================================================= -# Install dependency to convert tracks to a readable format for the browser +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= + +ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= + +ynh_restore_file "$final_path" + +#================================================= +# RECREATE THE DEDICATED USER +#================================================= + +# Create the dedicated user (if not existing) +ynh_system_user_create $app + +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Restore permissions on app files +chown -R $app:$app $final_path + +#================================================= +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= +if [ "$(lsb_release --codename --short)" != "jessie" ] +then + ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf" + ynh_restore_file "/etc/php/7.0/fpm/conf.d/20-$app.ini" +else + ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf" + ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini" +fi + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES #================================================= if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_install_app_dependencies php-sqlite3 + ynh_install_app_dependencies php7.0-sqlite3 else ynh_install_app_dependencies php5-sqlite fi #================================================= -# CREATE DEDICATED USER +# GENERIC FINALIZATION #================================================= - -# Create a system user -ynh_system_user_create $app - +# RELOAD NGINX AND PHP-FPM #================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE -#================================================= - -ynh_app_setting_set $app final_path $final_path -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" - -#================================================= -# Files owned by user app -#================================================= - -sudo chown $app:$app $final_path -R -sudo chmod 755 $final_path -R - -#================================================= -# NGINX CONFIGURATION -#================================================= - -# Create a dedicated nginx config -ynh_add_nginx_config - -#================================================= -# PHP-FPM CONFIGURATION -#================================================= - -# Create a dedicated php-fpm config -ynh_add_fpm_config - -#================================================= -# SETUP SSOWAT -#================================================= - -if [ $is_public -eq 0 ] -then # Remove the public access - ynh_app_setting_delete $app skipped_uris -fi -# Make app public if necessary -if [ $is_public -eq 1 ] +if [ "$(lsb_release --codename --short)" != "jessie" ] then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set $app unprotected_uris "/" + systemctl reload php7.0-fpm +else + systemctl reload php5-fpm fi - -#================================================= -# RELOAD NGINX -#================================================= - systemctl reload nginx \ No newline at end of file diff --git a/scripts/upgrade b/scripts/upgrade index 46203de..3b5972a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -55,7 +55,7 @@ ynh_app_setting_set $app is_public $is_public if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_install_app_dependencies php-sqlite3 + ynh_install_app_dependencies php7.0-sqlite3 else ynh_install_app_dependencies php5-sqlite fi From 9fa22de996f0a0bd75ec6459b2db0e569769c4ce Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 2 Apr 2020 19:03:09 +0200 Subject: [PATCH 027/207] try to debug --- conf/php-fpm.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 9095c07..89a1ab7 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -30,7 +30,7 @@ group = __USER__ ; specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. -listen = /var/run/php5-fpm-__NAMETOCHANGE__.sock +listen = /var/run/php/php7.0-fpm-__NAMETOCHANGE__.sock ; Set listen(2) backlog. A value of '-1' means unlimited. ; Default Value: 128 (-1 on FreeBSD and OpenBSD) From 5245009c35424578ea3b77d9bded58d429c00cb5 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 03:34:57 +0200 Subject: [PATCH 028/207] add hooks to copy file config.dist.php in config.local.php with good options --- hooks/post_app_change_url | 20 +++++++++++++++ hooks/post_app_install | 22 ++++++++++++++++ hooks/post_app_upgrade | 20 +++++++++++++++ scripts/_common.sh | 7 ++++++ scripts/backup | 33 +++++++++++++----------- scripts/install | 41 ++++++++++++++++++++---------- scripts/remove | 20 ++++++++++++--- scripts/restore | 53 +++++++++++++++++++-------------------- 8 files changed, 158 insertions(+), 58 deletions(-) create mode 100644 hooks/post_app_change_url create mode 100644 hooks/post_app_install create mode 100644 hooks/post_app_upgrade diff --git a/hooks/post_app_change_url b/hooks/post_app_change_url new file mode 100644 index 0000000..4c406a8 --- /dev/null +++ b/hooks/post_app_change_url @@ -0,0 +1,20 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# Change options in config.local.php +#================================================= + +ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/config.dist.php" +ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = false;" --target_file="$final_path/config.dist.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.dist.php" + +sudo cp -a $final_path/config.dist.php $final_path/local.dist.php \ No newline at end of file diff --git a/hooks/post_app_install b/hooks/post_app_install new file mode 100644 index 0000000..5fcbe84 --- /dev/null +++ b/hooks/post_app_install @@ -0,0 +1,22 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# Change options in file config.dist.php +# and copy in local.dist.php +#================================================= + +ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/config.dist.php" +ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = false;" --target_file="$final_path/config.dist.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.dist.php" +ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = 'uqn8jvlmVZLn988lOZiHd1z97hD36V40AnE0LLqLY1801LG3caO';" --target_file="$final_path/config.dist.php" + +sudo cp -a $final_path/config.dist.php $final_path/local.dist.php \ No newline at end of file diff --git a/hooks/post_app_upgrade b/hooks/post_app_upgrade new file mode 100644 index 0000000..3235aa7 --- /dev/null +++ b/hooks/post_app_upgrade @@ -0,0 +1,20 @@ +#!/bin/bash + +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# Change options in config.local.php +#================================================= + +ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/config.dist.php" +ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = false;" --target_file="$final_path/config.dist.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.dist.php" + +sudo cp -a $final_path/config.dist.php $final_path/local.dist.php diff --git a/scripts/_common.sh b/scripts/_common.sh index de37a9a..73fbed9 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,5 +1,12 @@ #!/bin/bash +#================================================= +# COMMON VARIABLES +#================================================= + +# dependencies used by the app +pkg_dependencies="php7.0-sqlite3" + # ============= FUTURE YUNOHOST HELPER ============= # Delete a file checksum from the app settings # diff --git a/scripts/backup b/scripts/backup index e8b2422..9329331 100644 --- a/scripts/backup +++ b/scripts/backup @@ -24,40 +24,45 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get $app final_path) -domain=$(ynh_app_setting_get $app domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # STANDARD BACKUP STEPS #================================================= # BACKUP THE APP MAIN DIR #================================================= +ynh_script_progression --message="Backing up the main app directory..." --time --weight=1 -ynh_backup "$final_path" +ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= + --time --weight=1ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1 -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Backing up php-fpm configuration..." --time --weight=1 -ynh_backup "/etc/php/7.0/fpm/pool.d/$app.conf" -ynh_backup "/etc/php/7.0/fpm/conf.d/20-$app.ini" +ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf" +ynh_backup --src_path="/etc/php/7.0/fpm/conf.d/20-$app.ini" -# Backup directory location for the app from where the script is executed and -# which will be compressed afterward -backup_dir=$YNH_APP_BACKUP_DIR +# # Backup directory location for the app from where the script is executed and +# # which will be compressed afterward +# backup_dir=$YNH_APP_BACKUP_DIR -# Backup sources & data -ynh_backup "/var/www/$app" "sources" +# # Backup sources & data +# ynh_backup "/var/www/$app" "sources" -# Copy Nginx conf -sudo mkdir -p ./conf -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "conf/nginx.conf" \ No newline at end of file +# # Copy Nginx conf +# sudo mkdir -p ./conf +# ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "conf/nginx.conf" \ No newline at end of file diff --git a/scripts/install b/scripts/install index 1bbd556..f3c2ba4 100644 --- a/scripts/install +++ b/scripts/install @@ -29,6 +29,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= +ynh_script_progression --message="Validating installation parameters..." --time --weight=1 final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -39,41 +40,44 @@ path_url=$(ynh_normalize_url_path $path_url) # Check web path availability ynh_webpath_available $domain $path_url # Register (book) web path -ynh_webpath_register $app $domain $path_url +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_script_progression --message="Storing installation settings..." --time --weight=1 -ynh_app_setting_set $app path_url $path_url -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app is_public $is_public +ynh_app_setting_set --app=$app --key=domain --value=$domain +ynh_app_setting_set --app=$app --key=path --value=$path_url +ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= # Install dependency to convert tracks to a readable format for the browser #================================================= +ynh_script_progression --message="Installing dependencies..." --time --weight=1 if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_install_app_dependencies php7.0-sqlite3 + ynh_install_app_dependencies $pkg_dependencies else - ynh_install_app_dependencies php5-sqlite + ynh_die --message="Votre version de Debian n'est pas compatible..." --time --weight=1 fi #================================================= # CREATE DEDICATED USER #================================================= - +ynh_script_progression --message="Configuring system user..." --time --weight=1 # Create a system user -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Setting up source files..." --time --weight=1 -ynh_app_setting_set $app final_path $final_path +ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +ynh_setup_source --dest_dir="$final_path" #================================================= # Files owned by user app @@ -85,13 +89,14 @@ sudo chmod 755 $final_path -R #================================================= # NGINX CONFIGURATION #================================================= - +ynh_script_progression --message="Configuring nginx web server..." --time --weight=1 # Create a dedicated nginx config ynh_add_nginx_config #================================================= # PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Configuring php-fpm..." --time --weight=1 # Create a dedicated php-fpm config ynh_add_fpm_config @@ -99,6 +104,9 @@ ynh_add_fpm_config #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 + + if [ $is_public -eq 0 ] then # Remove the public access @@ -108,11 +116,18 @@ fi if [ $is_public -eq 1 ] then # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set $app unprotected_uris "/" + ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" fi #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 -systemctl reload nginx \ No newline at end of file +systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Installation of $app completed" --time --last \ No newline at end of file diff --git a/scripts/remove b/scripts/remove index 079d4d3..aac63fd 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,15 +12,17 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # REMOVE DEPENDENCIES #================================================= +ynh_script_progression --message="Removing dependencies..." --time --weight=1 # Remove metapackage and its dependencies ynh_remove_app_dependencies @@ -28,13 +30,15 @@ ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= +ynh_script_progression --message="Removing app main directory..." --time --weight=1 # Remove the app directory securely -ynh_secure_remove "$final_path" +ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Removing nginx web server configuration..." --time --weight=1 # Remove the dedicated nginx config ynh_remove_nginx_config @@ -42,6 +46,7 @@ ynh_remove_nginx_config #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Removing php-fpm configuration..." --time --weight=1 # Remove the dedicated php-fpm config ynh_remove_fpm_config @@ -51,6 +56,13 @@ ynh_remove_fpm_config #================================================= # REMOVE DEDICATED USER #================================================= +ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 # Delete a system user -ynh_system_user_delete $app \ No newline at end of file +ynh_system_user_delete --username=$app + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Removal of $app completed" --time --last \ No newline at end of file diff --git a/scripts/restore b/scripts/restore index 61e3b2a..d1e75b7 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,12 +6,8 @@ # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Get the _common.sh file if it's not in the current directory - cp ../settings/scripts/_common.sh ./_common.sh - chmod a+rx _common.sh -fi -source _common.sh +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= @@ -24,16 +20,18 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading settings..." --time --weight=1 app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= +ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 ynh_webpath_available $domain $path_url \ || ynh_die "Path not available: ${domain}${path_url}" @@ -57,9 +55,10 @@ ynh_restore_file "$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 # Create the dedicated user (if not existing) -ynh_system_user_create $app +ynh_system_user_create --username=$app #================================================= # RESTORE USER RIGHTS @@ -73,11 +72,10 @@ chown -R $app:$app $final_path #================================================= if [ "$(lsb_release --codename --short)" != "jessie" ] then - ynh_restore_file "/etc/php/7.0/fpm/pool.d/$app.conf" - ynh_restore_file "/etc/php/7.0/fpm/conf.d/20-$app.ini" + ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" + ynh_restore_file --origin_path="/etc/php/7.0/fpm/conf.d/20-$app.ini" else - ynh_restore_file "/etc/php5/fpm/pool.d/$app.conf" - ynh_restore_file "/etc/php5/fpm/conf.d/20-$app.ini" + ynh_die --message="Votre version de Debian n'est pas compatible..." fi #================================================= @@ -85,23 +83,24 @@ fi #================================================= # REINSTALL DEPENDENCIES #================================================= +ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 + +# Define and install dependencies +ynh_install_app_dependencies php7.0-sqlite3 -if [ "$(lsb_release --codename --short)" != "jessie" ] -then - ynh_install_app_dependencies php7.0-sqlite3 -else - ynh_install_app_dependencies php5-sqlite -fi #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -if [ "$(lsb_release --codename --short)" != "jessie" ] -then - systemctl reload php7.0-fpm -else - systemctl reload php5-fpm -fi -systemctl reload nginx \ No newline at end of file +ynh_script_progression --message="Reloading nginx web server and php-fpm..." --time --weight=1 + +ynh_systemd_action --service_name=php7.0-fpm --action=reload +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --time --last \ No newline at end of file From f17a3c490f279dbb0931b16112a4992d7ce666d9 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 04:04:42 +0200 Subject: [PATCH 029/207] add hooks to copy file config.dist.php in config.local.php with good options --- hooks/post_app_change_url | 11 ++++++----- hooks/post_app_install | 12 ++++++------ hooks/post_app_upgrade | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/hooks/post_app_change_url b/hooks/post_app_change_url index 4c406a8..9a02bc5 100644 --- a/hooks/post_app_change_url +++ b/hooks/post_app_change_url @@ -6,15 +6,16 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh +source ../scripts/_common.sh source /usr/share/yunohost/helpers #================================================= # Change options in config.local.php #================================================= -ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/config.dist.php" -ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = false;" --target_file="$final_path/config.dist.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.dist.php" +sudo cp -a /var/www/garradin/config.dist.php var/www/garradin/local.dist.php -sudo cp -a $final_path/config.dist.php $final_path/local.dist.php \ No newline at end of file +ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/local.dist.php" +ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = false;" --target_file="$final_path/local.dist.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/local.dist.php" +ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = 'uqn8jvlmVZLn988lOZiHd1z97hD36V40AnE0LLqLY1801LG3caO';" --target_file="$final_path/config.dist.php" diff --git a/hooks/post_app_install b/hooks/post_app_install index 5fcbe84..240fa98 100644 --- a/hooks/post_app_install +++ b/hooks/post_app_install @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh +source ../scripts/_common.sh source /usr/share/yunohost/helpers #================================================= @@ -14,9 +14,9 @@ source /usr/share/yunohost/helpers # and copy in local.dist.php #================================================= -ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/config.dist.php" -ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = false;" --target_file="$final_path/config.dist.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.dist.php" -ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = 'uqn8jvlmVZLn988lOZiHd1z97hD36V40AnE0LLqLY1801LG3caO';" --target_file="$final_path/config.dist.php" +sudo cp -a /var/www/garradin/config.dist.php var/www/garradin/local.dist.php -sudo cp -a $final_path/config.dist.php $final_path/local.dist.php \ No newline at end of file +ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/local.dist.php" +ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = false;" --target_file="$final_path/local.dist.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/local.dist.php" +ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = 'uqn8jvlmVZLn988lOZiHd1z97hD36V40AnE0LLqLY1801LG3caO';" --target_file="$final_path/config.dist.php" diff --git a/hooks/post_app_upgrade b/hooks/post_app_upgrade index 3235aa7..39958e0 100644 --- a/hooks/post_app_upgrade +++ b/hooks/post_app_upgrade @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -source _common.sh +source ../scripts/_common.sh source /usr/share/yunohost/helpers #================================================= From 056ffd264b63700ceee50cc19b61782535081de7 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 04:33:13 +0200 Subject: [PATCH 030/207] try again to correct values --- hooks/post_app_change_url | 21 ++++++++++++++------- hooks/post_app_install | 18 ++++++++++++------ hooks/post_app_upgrade | 21 +++++++++++++++------ 3 files changed, 41 insertions(+), 19 deletions(-) diff --git a/hooks/post_app_change_url b/hooks/post_app_change_url index 9a02bc5..96cbda0 100644 --- a/hooks/post_app_change_url +++ b/hooks/post_app_change_url @@ -6,16 +6,23 @@ # IMPORT GENERIC HELPERS #================================================= -source ../scripts/_common.sh source /usr/share/yunohost/helpers #================================================= -# Change options in config.local.php +#Retrieve arguments #================================================= -sudo cp -a /var/www/garradin/config.dist.php var/www/garradin/local.dist.php +app=$YNH_APP_INSTANCE_NAME +final_path=/var/www/$app -ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/local.dist.php" -ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = false;" --target_file="$final_path/local.dist.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/local.dist.php" -ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = 'uqn8jvlmVZLn988lOZiHd1z97hD36V40AnE0LLqLY1801LG3caO';" --target_file="$final_path/config.dist.php" +#================================================= +# Change options in file config.dist.php +# and copy in local.dist.php +#================================================= + +sudo cp -a $final_path/config.dist.php $final_path/config.local.php + +ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = false;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = 'uqn8jvlmVZLn988lOZiHd1z97hD36V40AnE0LLqLY1801LG3caO';" --target_file="$final_path/config.local.php" diff --git a/hooks/post_app_install b/hooks/post_app_install index 240fa98..96cbda0 100644 --- a/hooks/post_app_install +++ b/hooks/post_app_install @@ -6,17 +6,23 @@ # IMPORT GENERIC HELPERS #================================================= -source ../scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +#Retrieve arguments +#================================================= + +app=$YNH_APP_INSTANCE_NAME +final_path=/var/www/$app + #================================================= # Change options in file config.dist.php # and copy in local.dist.php #================================================= -sudo cp -a /var/www/garradin/config.dist.php var/www/garradin/local.dist.php +sudo cp -a $final_path/config.dist.php $final_path/config.local.php -ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/local.dist.php" -ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = false;" --target_file="$final_path/local.dist.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/local.dist.php" -ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = 'uqn8jvlmVZLn988lOZiHd1z97hD36V40AnE0LLqLY1801LG3caO';" --target_file="$final_path/config.dist.php" +ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = false;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = 'uqn8jvlmVZLn988lOZiHd1z97hD36V40AnE0LLqLY1801LG3caO';" --target_file="$final_path/config.local.php" diff --git a/hooks/post_app_upgrade b/hooks/post_app_upgrade index 39958e0..3385e87 100644 --- a/hooks/post_app_upgrade +++ b/hooks/post_app_upgrade @@ -6,15 +6,24 @@ # IMPORT GENERIC HELPERS #================================================= -source ../scripts/_common.sh source /usr/share/yunohost/helpers #================================================= -# Change options in config.local.php +#Retrieve arguments #================================================= -ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/config.dist.php" -ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = false;" --target_file="$final_path/config.dist.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.dist.php" +app=$YNH_APP_INSTANCE_NAME +final_path=/var/www/$app + +#================================================= +# Change options in file config.dist.php +# and copy in config.local.php +#================================================= + +sudo cp -a /var/www/garradin/config.dist.php var/www/garradin/local.dist.php + +ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = false;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = 'uqn8jvlmVZLn988lOZiHd1z97hD36V40AnE0LLqLY1801LG3caO';" --target_file="$final_path/config.local.php" -sudo cp -a $final_path/config.dist.php $final_path/local.dist.php From 66463715e1bd8830c8c65b6dedb08c3c41448864 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 05:00:30 +0200 Subject: [PATCH 031/207] try again to correct values --- hooks/post_app_change_url | 4 ++-- hooks/post_app_install | 4 ++-- hooks/post_app_upgrade | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hooks/post_app_change_url b/hooks/post_app_change_url index 96cbda0..ab96f6e 100644 --- a/hooks/post_app_change_url +++ b/hooks/post_app_change_url @@ -22,7 +22,7 @@ final_path=/var/www/$app sudo cp -a $final_path/config.dist.php $final_path/config.local.php -ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = false;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = 'uqn8jvlmVZLn988lOZiHd1z97hD36V40AnE0LLqLY1801LG3caO';" --target_file="$final_path/config.local.php" diff --git a/hooks/post_app_install b/hooks/post_app_install index 96cbda0..ab96f6e 100644 --- a/hooks/post_app_install +++ b/hooks/post_app_install @@ -22,7 +22,7 @@ final_path=/var/www/$app sudo cp -a $final_path/config.dist.php $final_path/config.local.php -ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = false;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = 'uqn8jvlmVZLn988lOZiHd1z97hD36V40AnE0LLqLY1801LG3caO';" --target_file="$final_path/config.local.php" diff --git a/hooks/post_app_upgrade b/hooks/post_app_upgrade index 3385e87..2beb7ab 100644 --- a/hooks/post_app_upgrade +++ b/hooks/post_app_upgrade @@ -22,8 +22,8 @@ final_path=/var/www/$app sudo cp -a /var/www/garradin/config.dist.php var/www/garradin/local.dist.php -ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = false;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = 'uqn8jvlmVZLn988lOZiHd1z97hD36V40AnE0LLqLY1801LG3caO';" --target_file="$final_path/config.local.php" From dbb20723df2c1521f7c776a976ecce3e3cfc513e Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 05:19:38 +0200 Subject: [PATCH 032/207] try again to correct values --- hooks/post_app_change_url | 2 +- hooks/post_app_install | 2 +- hooks/post_app_upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hooks/post_app_change_url b/hooks/post_app_change_url index ab96f6e..aa2cfb2 100644 --- a/hooks/post_app_change_url +++ b/hooks/post_app_change_url @@ -22,7 +22,7 @@ final_path=/var/www/$app sudo cp -a $final_path/config.dist.php $final_path/config.local.php -ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" +# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = 'uqn8jvlmVZLn988lOZiHd1z97hD36V40AnE0LLqLY1801LG3caO';" --target_file="$final_path/config.local.php" diff --git a/hooks/post_app_install b/hooks/post_app_install index ab96f6e..aa2cfb2 100644 --- a/hooks/post_app_install +++ b/hooks/post_app_install @@ -22,7 +22,7 @@ final_path=/var/www/$app sudo cp -a $final_path/config.dist.php $final_path/config.local.php -ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" +# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = 'uqn8jvlmVZLn988lOZiHd1z97hD36V40AnE0LLqLY1801LG3caO';" --target_file="$final_path/config.local.php" diff --git a/hooks/post_app_upgrade b/hooks/post_app_upgrade index 2beb7ab..1d1a455 100644 --- a/hooks/post_app_upgrade +++ b/hooks/post_app_upgrade @@ -22,7 +22,7 @@ final_path=/var/www/$app sudo cp -a /var/www/garradin/config.dist.php var/www/garradin/local.dist.php -ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" +# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = 'uqn8jvlmVZLn988lOZiHd1z97hD36V40AnE0LLqLY1801LG3caO';" --target_file="$final_path/config.local.php" From 72514cea71c2647ede8232b80fca5206e35b5fe9 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 06:07:13 +0200 Subject: [PATCH 033/207] change the upgrade file --- scripts/upgrade | 166 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 123 insertions(+), 43 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 3b5972a..19568c0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,26 +9,84 @@ source _common.sh source /usr/share/yunohost/helpers + #================================================= -# MANAGE SCRIPT FAILURE +# LOAD SETTINGS +#================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 + +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get --app=$app --key=domain) +path_url=$(ynh_app_setting_get --app=$app --key=path) +is_public=$(ynh_app_setting_get --app=$app --key=is_public) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) || ynh_die "This path already contains a folder" + +#================================================= +# CHECK VERSION #================================================= +### This helper will compare the version of the currently installed app and the version of the upstream package. +### $upgrade_type can have 2 different values +### - UPGRADE_APP if the upstream app version has changed +### - UPGRADE_PACKAGE if only the YunoHost package has changed +### ynh_check_app_version_changed will stop the upgrade if the app is up to date. +### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. +upgrade_type=$(ynh_check_app_version_changed) + +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= + +ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 + +# Fix is_public as a boolean value +if [ "$is_public" = "Yes" ]; then + ynh_app_setting_set --app=$app --key=is_public --value=1 + is_public=1 +elif [ "$is_public" = "No" ]; then + ynh_app_setting_set --app=$app --key=is_public --value=0 + is_public=0 +fi + +# If db_name doesn't exist, create it +if [ -z "$db_name" ]; then + db_name=$(ynh_sanitize_dbid --db_name=$app) + ynh_app_setting_set --app=$app --key=db_name --value=$db_name +fi + +# If final_path doesn't exist, create it +if [ -z "$final_path" ]; then + final_path=/var/www/$app + ynh_app_setting_set --app=$app --key=final_path --value=$final_path +fi + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors #================================================= -# Retrieve arguments +# CHECK THE PATH #================================================= -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC +# Normalize the URL path syntax +# N.B. : this is for app installations before YunoHost 2.7 +# where this value might be something like /foo/ or foo/ +# instead of /foo .... +# If nobody installed your app before 2.7, then you may +# safely remove this line +path_url=$(ynh_normalize_url_path --path_url=$path_url) -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= final_path=/var/www/$app test ! -e "$final_path" || ynh_die "This path already contains a folder" @@ -42,38 +100,63 @@ ynh_webpath_available $domain $path_url ynh_webpath_register $app $domain $path_url #================================================= -# STORE SETTINGS FROM MANIFEST +# DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_app_setting_set $app path_url $path_url -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app is_public $is_public - -#================================================= -# Install dependency to convert tracks to a readable format for the browser -#================================================= - -if [ "$(lsb_release --codename --short)" != "jessie" ] +if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_install_app_dependencies php7.0-sqlite3 -else - ynh_install_app_dependencies php5-sqlite + ynh_script_progression --message="Upgrading source files..." --time --weight=1 + + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" fi +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading nginx web server configuration..." --time --weight=1 + +# Create a dedicated nginx config +ynh_add_nginx_config + +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # CREATE DEDICATED USER #================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 -# Create a system user -ynh_system_user_create $app +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app #================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE +# PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1 + +# Create a dedicated php-fpm config +ynh_add_fpm_config + +#================================================= +# SPECIFIC UPGRADE +#================================================= +# ... #================================================= -ynh_app_setting_set $app final_path $final_path -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +#================================================= +# STORE THE CONFIG FILE CHECKSUM +#================================================= + +### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. +### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. +ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE" +# Recalculate and store the checksum of the file for the next upgrade. +ynh_store_file_checksum --file="$final_path/CONFIG_FILE" #================================================= # Files owned by user app @@ -82,13 +165,6 @@ ynh_setup_source "$final_path" sudo chown $app:$app $final_path -R sudo chmod 755 $final_path -R -#================================================= -# NGINX CONFIGURATION -#================================================= - -# Create a dedicated nginx config -ynh_add_nginx_config - #================================================= # PHP-FPM CONFIGURATION #================================================= @@ -99,20 +175,24 @@ ynh_add_fpm_config #================================================= # SETUP SSOWAT #================================================= +ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1 -if [ $is_public -eq 0 ] -then # Remove the public access - ynh_app_setting_delete $app skipped_uris -fi # Make app public if necessary if [ $is_public -eq 1 ] then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set $app unprotected_uris "/" + # unprotected_uris allows SSO credentials to be passed anyway + ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" fi #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 -systemctl reload nginx \ No newline at end of file +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --time --last From 2440680a9c5e53ab4d103c1ad9e081194391c779 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 06:17:55 +0200 Subject: [PATCH 034/207] change the upgrade file --- scripts/upgrade | 6 ------ 1 file changed, 6 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 19568c0..060ec8b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -49,12 +49,6 @@ elif [ "$is_public" = "No" ]; then is_public=0 fi -# If db_name doesn't exist, create it -if [ -z "$db_name" ]; then - db_name=$(ynh_sanitize_dbid --db_name=$app) - ynh_app_setting_set --app=$app --key=db_name --value=$db_name -fi - # If final_path doesn't exist, create it if [ -z "$final_path" ]; then final_path=/var/www/$app From 8b8e4a0107928bf107523c882bc7865c387dfeba Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 07:21:18 +0200 Subject: [PATCH 035/207] try to backup sql for the upgrade --- scripts/upgrade | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 060ec8b..2ec211d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -55,6 +55,11 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi +#================================================= +# Backup squlite +#================================================= +sudo cp -a $final_path/association.squilte /tmp/association.squilte + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -128,18 +133,10 @@ ynh_script_progression --message="Making sure dedicated system user exists..." - # Create a dedicated user (if not existing) ynh_system_user_create --username=$app -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1 - -# Create a dedicated php-fpm config -ynh_add_fpm_config - #================================================= # SPECIFIC UPGRADE #================================================= -# ... +sudo cp /tmp/association.squilte $final_path/association.squilte #================================================= #================================================= @@ -162,6 +159,7 @@ sudo chmod 755 $final_path -R #================================================= # PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1 # Create a dedicated php-fpm config ynh_add_fpm_config From 8941fcc58e700f479ea5da27564b06afaa82c02f Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 07:35:00 +0200 Subject: [PATCH 036/207] try to save sqlite bdd since upgarade --- scripts/upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 2ec211d..86f235b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -58,7 +58,7 @@ fi #================================================= # Backup squlite #================================================= -sudo cp -a $final_path/association.squilte /tmp/association.squilte +sudo cp -a $final_path/association.sqlite /tmp/association.sqlite #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP @@ -136,7 +136,7 @@ ynh_system_user_create --username=$app #================================================= # SPECIFIC UPGRADE #================================================= -sudo cp /tmp/association.squilte $final_path/association.squilte +sudo cp /tmp/association.sqlite $final_path/association.sqlite #================================================= #================================================= From 330a4107e8cfef58932ce0d5dad7c71c912a764e Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 08:03:43 +0200 Subject: [PATCH 037/207] try to save sqlite bdd since upgarade --- hooks/post_app_upgrade | 6 ++++++ scripts/upgrade | 19 +++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/hooks/post_app_upgrade b/hooks/post_app_upgrade index 1d1a455..dff8796 100644 --- a/hooks/post_app_upgrade +++ b/hooks/post_app_upgrade @@ -15,6 +15,12 @@ source /usr/share/yunohost/helpers app=$YNH_APP_INSTANCE_NAME final_path=/var/www/$app +#================================================= +# backup the bdd +#================================================= +sudo cp /tmp/association.sqlite $final_path/association.sqlite + + #================================================= # Change options in file config.dist.php # and copy in config.local.php diff --git a/scripts/upgrade b/scripts/upgrade index 86f235b..e1d5e9c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -110,6 +110,13 @@ then ynh_setup_source --dest_dir="$final_path" fi +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 + +ynh_install_app_dependencies $pkg_dependencies + #================================================= # NGINX CONFIGURATION #================================================= @@ -118,12 +125,6 @@ ynh_script_progression --message="Upgrading nginx web server configuration..." - # Create a dedicated nginx config ynh_add_nginx_config -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 - -ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER @@ -133,12 +134,6 @@ ynh_script_progression --message="Making sure dedicated system user exists..." - # Create a dedicated user (if not existing) ynh_system_user_create --username=$app -#================================================= -# SPECIFIC UPGRADE -#================================================= -sudo cp /tmp/association.sqlite $final_path/association.sqlite -#================================================= - #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= From 50316c0cb9917be8ccef04d89b5a69f4b115e651 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 08:40:29 +0200 Subject: [PATCH 038/207] try to save sqlite bdd since upgarade --- hooks/post_app_upgrade | 4 +-- scripts/upgrade | 80 +++++++++++++++++++----------------------- 2 files changed, 39 insertions(+), 45 deletions(-) diff --git a/hooks/post_app_upgrade b/hooks/post_app_upgrade index dff8796..1439087 100644 --- a/hooks/post_app_upgrade +++ b/hooks/post_app_upgrade @@ -18,8 +18,8 @@ final_path=/var/www/$app #================================================= # backup the bdd #================================================= -sudo cp /tmp/association.sqlite $final_path/association.sqlite - +sudo cp -a /tmp/association.sqlite $final_path/association.sqlite +sudo cp -avr /tmp/squelettes $final_path/www/squelettes #================================================= # Change options in file config.dist.php diff --git a/scripts/upgrade b/scripts/upgrade index e1d5e9c..87f4daf 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -49,17 +49,11 @@ elif [ "$is_public" = "No" ]; then is_public=0 fi -# If final_path doesn't exist, create it -if [ -z "$final_path" ]; then - final_path=/var/www/$app - ynh_app_setting_set --app=$app --key=final_path --value=$final_path -fi - #================================================= # Backup squlite #================================================= -sudo cp -a $final_path/association.sqlite /tmp/association.sqlite - +sudo cp -avr $final_path/association.sqlite /tmp/association.sqlite +sudo cp -avr $final_path/www/squelettes /tmp/squelettes #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -74,29 +68,36 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +# #================================================= +# # CHECK THE PATH +# #================================================= + +# # Normalize the URL path syntax +# # N.B. : this is for app installations before YunoHost 2.7 +# # where this value might be something like /foo/ or foo/ +# # instead of /foo .... +# # If nobody installed your app before 2.7, then you may +# # safely remove this line +# path_url=$(ynh_normalize_url_path --path_url=$path_url) + + +# final_path=/var/www/$app +# test ! -e "$final_path" || ynh_die "This path already contains a folder" + +# # Normalize the url path syntax +# path_url=$(ynh_normalize_url_path $path_url) + +# # Check web path availability +# ynh_webpath_available $domain $path_url +# # Register (book) web path +# ynh_webpath_register $app $domain $path_url + #================================================= -# CHECK THE PATH +# UPGRADE DEPENDENCIES #================================================= +ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 -# Normalize the URL path syntax -# N.B. : this is for app installations before YunoHost 2.7 -# where this value might be something like /foo/ or foo/ -# instead of /foo .... -# If nobody installed your app before 2.7, then you may -# safely remove this line -path_url=$(ynh_normalize_url_path --path_url=$path_url) - - -final_path=/var/www/$app -test ! -e "$final_path" || ynh_die "This path already contains a folder" - -# Normalize the url path syntax -path_url=$(ynh_normalize_url_path $path_url) - -# Check web path availability -ynh_webpath_available $domain $path_url -# Register (book) web path -ynh_webpath_register $app $domain $path_url +ynh_install_app_dependencies $pkg_dependencies #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -110,13 +111,6 @@ then ynh_setup_source --dest_dir="$final_path" fi -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 - -ynh_install_app_dependencies $pkg_dependencies - #================================================= # NGINX CONFIGURATION #================================================= @@ -134,15 +128,15 @@ ynh_script_progression --message="Making sure dedicated system user exists..." - # Create a dedicated user (if not existing) ynh_system_user_create --username=$app -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= +# #================================================= +# # STORE THE CONFIG FILE CHECKSUM +# #================================================= -### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. -### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. -ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE" -# Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$final_path/CONFIG_FILE" +# ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. +# ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. +# ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE" +# # Recalculate and store the checksum of the file for the next upgrade. +# ynh_store_file_checksum --file="$final_path/CONFIG_FILE" #================================================= # Files owned by user app From 2853e25aa2673f7795bfe279f73c29d47f2e2a23 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 08:56:23 +0200 Subject: [PATCH 039/207] make the upgrade with backup of the bdd --- hooks/post_app_change_url | 1 - hooks/post_app_install | 1 - hooks/post_app_upgrade | 4 ++-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/hooks/post_app_change_url b/hooks/post_app_change_url index aa2cfb2..86403b9 100644 --- a/hooks/post_app_change_url +++ b/hooks/post_app_change_url @@ -25,4 +25,3 @@ sudo cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = 'uqn8jvlmVZLn988lOZiHd1z97hD36V40AnE0LLqLY1801LG3caO';" --target_file="$final_path/config.local.php" diff --git a/hooks/post_app_install b/hooks/post_app_install index aa2cfb2..86403b9 100644 --- a/hooks/post_app_install +++ b/hooks/post_app_install @@ -25,4 +25,3 @@ sudo cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = 'uqn8jvlmVZLn988lOZiHd1z97hD36V40AnE0LLqLY1801LG3caO';" --target_file="$final_path/config.local.php" diff --git a/hooks/post_app_upgrade b/hooks/post_app_upgrade index 1439087..75be5eb 100644 --- a/hooks/post_app_upgrade +++ b/hooks/post_app_upgrade @@ -26,10 +26,10 @@ sudo cp -avr /tmp/squelettes $final_path/www/squelettes # and copy in config.local.php #================================================= -sudo cp -a /var/www/garradin/config.dist.php var/www/garradin/local.dist.php +sudo cp -a /var/www/garradin/config.dist.php var/www/garradin/config.local.dist.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = 'uqn8jvlmVZLn988lOZiHd1z97hD36V40AnE0LLqLY1801LG3caO';" --target_file="$final_path/config.local.php" + From 7eb6ddc593eb9e811ed4248e1af74f8f08b787b4 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 09:02:04 +0200 Subject: [PATCH 040/207] syntax error on file backup --- scripts/backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/backup b/scripts/backup index 9329331..e7c034b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -44,7 +44,7 @@ ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= - --time --weight=1ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1 +ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1 ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" From 411a150351a49882fef5d499b987ff07600251c0 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 09:09:52 +0200 Subject: [PATCH 041/207] syntax error on file backup --- hooks/post_app_upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/post_app_upgrade b/hooks/post_app_upgrade index 75be5eb..8744dd3 100644 --- a/hooks/post_app_upgrade +++ b/hooks/post_app_upgrade @@ -26,7 +26,7 @@ sudo cp -avr /tmp/squelettes $final_path/www/squelettes # and copy in config.local.php #================================================= -sudo cp -a /var/www/garradin/config.dist.php var/www/garradin/config.local.dist.php +sudo cp -a /var/www/garradin/config.dist.php var/www/garradin/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" From 55d2f863f9c4a55e391949ddd57b4a3b396496c4 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 09:18:57 +0200 Subject: [PATCH 042/207] change the hook post_upgrade --- hooks/post_app_upgrade | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/hooks/post_app_upgrade b/hooks/post_app_upgrade index 8744dd3..96a858b 100644 --- a/hooks/post_app_upgrade +++ b/hooks/post_app_upgrade @@ -15,18 +15,19 @@ source /usr/share/yunohost/helpers app=$YNH_APP_INSTANCE_NAME final_path=/var/www/$app +#================================================= +# Change options in file config.dist.php +# and copy in config.local.php +#================================================= + +sudo cp -a $final_path/garradin/config.dist.php $final_path/garradin/config.local.php + #================================================= # backup the bdd #================================================= sudo cp -a /tmp/association.sqlite $final_path/association.sqlite sudo cp -avr /tmp/squelettes $final_path/www/squelettes -#================================================= -# Change options in file config.dist.php -# and copy in config.local.php -#================================================= - -sudo cp -a /var/www/garradin/config.dist.php var/www/garradin/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" From 89e4cb44eb7ae42d4061915e9b71dc6711d6f477 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 09:24:23 +0200 Subject: [PATCH 043/207] change the hook post_upgrade --- hooks/post_app_upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/post_app_upgrade b/hooks/post_app_upgrade index 96a858b..9cd6a5c 100644 --- a/hooks/post_app_upgrade +++ b/hooks/post_app_upgrade @@ -20,7 +20,7 @@ final_path=/var/www/$app # and copy in config.local.php #================================================= -sudo cp -a $final_path/garradin/config.dist.php $final_path/garradin/config.local.php +sudo cp -a $final_path/config.dist.php $final_path/config.local.php #================================================= # backup the bdd From 5eacdcef90c82a6ce6c1ad5b4f9a69a9ae9e142f Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 14:29:20 +0200 Subject: [PATCH 044/207] delete folder hooks and update the scripts install and upgrade --- hooks/post_app_change_url | 27 --------------------------- hooks/post_app_install | 27 --------------------------- hooks/post_app_upgrade | 36 ------------------------------------ scripts/install | 11 +++++++++++ scripts/upgrade | 12 +++++++++++- 5 files changed, 22 insertions(+), 91 deletions(-) delete mode 100644 hooks/post_app_change_url delete mode 100644 hooks/post_app_install delete mode 100644 hooks/post_app_upgrade diff --git a/hooks/post_app_change_url b/hooks/post_app_change_url deleted file mode 100644 index 86403b9..0000000 --- a/hooks/post_app_change_url +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -source /usr/share/yunohost/helpers - -#================================================= -#Retrieve arguments -#================================================= - -app=$YNH_APP_INSTANCE_NAME -final_path=/var/www/$app - -#================================================= -# Change options in file config.dist.php -# and copy in local.dist.php -#================================================= - -sudo cp -a $final_path/config.dist.php $final_path/config.local.php - -# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.local.php" diff --git a/hooks/post_app_install b/hooks/post_app_install deleted file mode 100644 index 86403b9..0000000 --- a/hooks/post_app_install +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -source /usr/share/yunohost/helpers - -#================================================= -#Retrieve arguments -#================================================= - -app=$YNH_APP_INSTANCE_NAME -final_path=/var/www/$app - -#================================================= -# Change options in file config.dist.php -# and copy in local.dist.php -#================================================= - -sudo cp -a $final_path/config.dist.php $final_path/config.local.php - -# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.local.php" diff --git a/hooks/post_app_upgrade b/hooks/post_app_upgrade deleted file mode 100644 index 9cd6a5c..0000000 --- a/hooks/post_app_upgrade +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -#================================================= -# GENERIC START -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -source /usr/share/yunohost/helpers - -#================================================= -#Retrieve arguments -#================================================= - -app=$YNH_APP_INSTANCE_NAME -final_path=/var/www/$app - -#================================================= -# Change options in file config.dist.php -# and copy in config.local.php -#================================================= - -sudo cp -a $final_path/config.dist.php $final_path/config.local.php - -#================================================= -# backup the bdd -#================================================= -sudo cp -a /tmp/association.sqlite $final_path/association.sqlite -sudo cp -avr /tmp/squelettes $final_path/www/squelettes - - -# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.local.php" - - diff --git a/scripts/install b/scripts/install index f3c2ba4..d66ae60 100644 --- a/scripts/install +++ b/scripts/install @@ -79,6 +79,17 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" +#================================================= +# Change options in file config.dist.php +# and copy in local.dist.php +#================================================= + +sudo cp -a $final_path/config.dist.php $final_path/config.local.php + +# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.local.php" + #================================================= # Files owned by user app #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 87f4daf..73d1392 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -50,10 +50,11 @@ elif [ "$is_public" = "No" ]; then fi #================================================= -# Backup squlite +# Backup squlite, config.local.php and squelettes directory #================================================= sudo cp -avr $final_path/association.sqlite /tmp/association.sqlite sudo cp -avr $final_path/www/squelettes /tmp/squelettes +sudo cp -a $final_path/config.local.php #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -111,6 +112,15 @@ then ynh_setup_source --dest_dir="$final_path" fi +#================================================= +# backup bdd, squelettes directory and config.local.php +#================================================= + +sudo cp -a /tmp/config.local.php $final_path/config.local.php + +sudo cp -a /tmp/association.sqlite $final_path/association.sqlite +sudo cp -avr /tmp/squelettes $final_path/www/squelettes + #================================================= # NGINX CONFIGURATION #================================================= From d600f8293c24fc8f4a876c9234e64cd17ebb91ca Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 14:46:09 +0200 Subject: [PATCH 045/207] correct url for backup file config.local.php --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 73d1392..543255d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -54,7 +54,7 @@ fi #================================================= sudo cp -avr $final_path/association.sqlite /tmp/association.sqlite sudo cp -avr $final_path/www/squelettes /tmp/squelettes -sudo cp -a $final_path/config.local.php +sudo cp -a $final_path/config.local.php /tmp/config.local.php #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= From 3318d4323b6c165610b0ff1efb4d017e47effef1 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 15:07:28 +0200 Subject: [PATCH 046/207] correct url for backup files --- scripts/upgrade | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 543255d..7c987ca 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -34,6 +34,13 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) || ynh_die "This p ### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. upgrade_type=$(ynh_check_app_version_changed) +#================================================= +# Backup squlite, config.local.php and squelettes directory +#================================================= +sudo cp -avr $path_url/association.sqlite /tmp/association.sqlite +sudo cp -avr $path_url/www/squelettes /tmp/squelettes +sudo cp -a $path_url/config.local.php /tmp/config.local.php + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -49,12 +56,6 @@ elif [ "$is_public" = "No" ]; then is_public=0 fi -#================================================= -# Backup squlite, config.local.php and squelettes directory -#================================================= -sudo cp -avr $final_path/association.sqlite /tmp/association.sqlite -sudo cp -avr $final_path/www/squelettes /tmp/squelettes -sudo cp -a $final_path/config.local.php /tmp/config.local.php #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= From 97e17d3fc8723f2fe24e0c209d223df94af7e29a Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 15:13:21 +0200 Subject: [PATCH 047/207] correct url for backup files --- scripts/upgrade | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 7c987ca..fc80f98 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,6 +9,12 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# Backup squlite, config.local.php and squelettes directory +#================================================= +sudo cp -avr /var/www/garradin/association.sqlite /tmp/association.sqlite +sudo cp -avr /var/www/garradin/www/squelettes /tmp/squelettes +sudo cp -a /var/www/garradin/config.local.php /tmp/config.local.php #================================================= # LOAD SETTINGS @@ -34,12 +40,6 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) || ynh_die "This p ### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# Backup squlite, config.local.php and squelettes directory -#================================================= -sudo cp -avr $path_url/association.sqlite /tmp/association.sqlite -sudo cp -avr $path_url/www/squelettes /tmp/squelettes -sudo cp -a $path_url/config.local.php /tmp/config.local.php #================================================= # ENSURE DOWNWARD COMPATIBILITY From a322817f7163f308175bb2b3a58e7529d7e3ab34 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 15:31:32 +0200 Subject: [PATCH 048/207] delete the backup of config.local.php because this file must be edited with this upgrade --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index fc80f98..8abb73c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= sudo cp -avr /var/www/garradin/association.sqlite /tmp/association.sqlite sudo cp -avr /var/www/garradin/www/squelettes /tmp/squelettes -sudo cp -a /var/www/garradin/config.local.php /tmp/config.local.php +sudo cp -avr /var/www/garradin/config.local.php /tmp/config.local.php #================================================= # LOAD SETTINGS From ac55f98f90efaf969ba1d45cee93af6f58655432 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 15:45:28 +0200 Subject: [PATCH 049/207] delete the backup of config.local.php because this file must be edited with this upgrade --- scripts/upgrade | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 8abb73c..0466feb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,12 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# Backup squlite, config.local.php and squelettes directory -#================================================= -sudo cp -avr /var/www/garradin/association.sqlite /tmp/association.sqlite -sudo cp -avr /var/www/garradin/www/squelettes /tmp/squelettes -sudo cp -avr /var/www/garradin/config.local.php /tmp/config.local.php #================================================= # LOAD SETTINGS @@ -56,6 +50,14 @@ elif [ "$is_public" = "No" ]; then is_public=0 fi +#================================================= +# Backup squlite, config.local.php and squelettes directory +#================================================= +ynh_script_progression --message="Backing up the bdd and squelettes before upgrading (may take a while)..." --time --weight=1 + +sudo cp -avr /var/www/garradin/association.sqlite /tmp/association.sqlite +sudo cp -avr /var/www/garradin/www/squelettes /tmp/squelettes + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -114,10 +116,20 @@ then fi #================================================= -# backup bdd, squelettes directory and config.local.php +# Change options in file config.dist.php +# and copy in local.dist.php #================================================= -sudo cp -a /tmp/config.local.php $final_path/config.local.php +sudo cp -a $final_path/config.dist.php $final_path/config.local.php + +# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.local.php" + + +#================================================= +# backup bdd, squelettes directory and config.local.php +#================================================= sudo cp -a /tmp/association.sqlite $final_path/association.sqlite sudo cp -avr /tmp/squelettes $final_path/www/squelettes From 56b9804c61abe1de78f12486f5124cb7760df117 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 16:06:51 +0200 Subject: [PATCH 050/207] change the script backup --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index d1e75b7..04568ea 100644 --- a/scripts/restore +++ b/scripts/restore @@ -49,6 +49,7 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= +ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 ynh_restore_file "$final_path" @@ -73,7 +74,6 @@ chown -R $app:$app $final_path if [ "$(lsb_release --codename --short)" != "jessie" ] then ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" - ynh_restore_file --origin_path="/etc/php/7.0/fpm/conf.d/20-$app.ini" else ynh_die --message="Votre version de Debian n'est pas compatible..." fi From b7137791d67c9c7ffd2023788c359a05a985bc88 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 16:21:35 +0200 Subject: [PATCH 051/207] change the script backup --- scripts/backup | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/backup b/scripts/backup index e7c034b..810a34e 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,12 +6,8 @@ # IMPORT GENERIC HELPERS #================================================= -if [ ! -e _common.sh ]; then - # Get the _common.sh file if it's not in the current directory - cp ../settings/scripts/_common.sh ./_common.sh - chmod a+rx _common.sh -fi -source _common.sh +#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= @@ -30,7 +26,6 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # STANDARD BACKUP STEPS @@ -54,7 +49,13 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_script_progression --message="Backing up php-fpm configuration..." --time --weight=1 ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf" -ynh_backup --src_path="/etc/php/7.0/fpm/conf.d/20-$app.ini" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last +#ynh_backup --src_path="/etc/php/7.0/fpm/conf.d/20-$app.ini" # # Backup directory location for the app from where the script is executed and # # which will be compressed afterward From 85ba7c33b8efa12eeac0dfdb6a28ee67e7458c86 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sat, 4 Apr 2020 16:34:26 +0200 Subject: [PATCH 052/207] add a missing bracket in script restore --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 04568ea..fe8a148 100644 --- a/scripts/restore +++ b/scripts/restore @@ -26,7 +26,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) -final_path=$(ynh_app_setting_get --app=$app --key=final_path +final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # CHECK IF THE APP CAN BE RESTORED From d76f167e62939c447cb17f43fd4bbaad935933a9 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Sat, 4 Apr 2020 18:43:39 +0200 Subject: [PATCH 053/207] prepare package_check --- check_process | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/check_process b/check_process index 562dcd7..e69de29 100644 --- a/check_process +++ b/check_process @@ -1,30 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) - is_public=1 (PUBLIC|public=1|private=0) - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - backup_restore=1 - multi_instance=1 - incorrect_path=1 - port_already_use=0 - change_url=0 -;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto - Level 4=na -# l'utilisateur est à créer. LDAP non supporté par le paquet de base (obligation d'utiliser de MySql) - Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 From f4a762cd6c0906273d5fbfd7a10aa958f1faab10 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Sun, 5 Apr 2020 12:13:00 +0200 Subject: [PATCH 054/207] prepare package_check --- check_process | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/check_process b/check_process index e69de29..b25c98b 100644 --- a/check_process +++ b/check_process @@ -0,0 +1,30 @@ +; Test complet + ; Manifest + domain="domain.tld" (DOMAIN) + path="/path" (PATH) + is_public=1 (PUBLIC|public=1|private=0) + ; Checks + pkg_linter=1 + setup_sub_dir=1 + setup_root=1 + setup_nourl=0 + setup_private=1 + setup_public=1 + upgrade=1 + backup_restore=1 + multi_instance=1 + incorrect_path=1 + port_already_use=0 + change_url=0 +;;; Levels + Level 1=auto + Level 2=auto + Level 3=auto + Level 4=na +# l'utilisateur est à créer. LDAP non supporté par le paquet de base (obligation d'utiliser de MySql) + Level 5=auto + Level 6=auto + Level 7=auto + Level 8=0 + Level 9=0 + Level 10=0 \ No newline at end of file From 6273c8bb653cea9c849671e444118d10e8976b9a Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Sun, 5 Apr 2020 14:54:36 +0200 Subject: [PATCH 055/207] delete php.ini not used and add the values (commented) on php_fpm.conf --- conf/php-fpm.conf | 13 +++++++++- conf/php-fpm.ini | 10 -------- manifest.json | 2 +- script_jenkins.sh | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 12 deletions(-) delete mode 100644 conf/php-fpm.ini create mode 100644 script_jenkins.sh diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 89a1ab7..3f4bc72 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -389,4 +389,15 @@ catch_workers_output = yes ;php_flag[display_errors] = off ;php_admin_value[error_log] = /var/log/fpm-php.www.log ;php_admin_flag[log_errors] = on -;php_admin_value[memory_limit] = 32M \ No newline at end of file +;php_admin_value[memory_limit] = 32M + +; Common values to change to increase file upload limit +; php_value[upload_max_filesize] = 50M +; php_value[post_max_size] = 50M +; php_valuemail.add_x_header = Off + +; Other common parameters +; php_value[max_execution_time] = 600 +; php_value[max_input_time] = 300 +; php_value[memory_limit] = 256M +; php_value[short_open_tag] = On \ No newline at end of file diff --git a/conf/php-fpm.ini b/conf/php-fpm.ini deleted file mode 100644 index 0dab855..0000000 --- a/conf/php-fpm.ini +++ /dev/null @@ -1,10 +0,0 @@ -; Common values to change to increase file upload limit -; upload_max_filesize = 50M -; post_max_size = 50M -; mail.add_x_header = Off - -; Other common parameters -; max_execution_time = 600 -; max_input_time = 300 -; memory_limit = 256M -; short_open_tag = On \ No newline at end of file diff --git a/manifest.json b/manifest.json index c4b3781..7b24aaa 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "id": "garradin", "packaging_format": 1, "requirements": { - "yunohost": ">= 2.7.2" + "yunohost": "3.5.0" }, "description": { "en": "Software to manage association", diff --git a/script_jenkins.sh b/script_jenkins.sh new file mode 100644 index 0000000..ad2bcd3 --- /dev/null +++ b/script_jenkins.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +# Usage: +# send_to_dev_ci.sh +# Use without arguments, the script will use the static list at the end of script +# +# send_to_dev_ci.sh my_app my_other_app "the directory/which/contains/my_third_app" +# Use with arguments, each argument will be considered as an app to send to the CI. + +# Get the path of this script +script_dir="$(dirname "$(realpath "$0")")" + +# Get potential arguments and store them into an array +if [ $# -ge 1 ] +then + folders_to_send=("$@") +fi + +ssh_user=rodinux +ssh_host=ci-apps-dev.yunohost.org +ssh_port=22 +ssh_key=~/.ssh/id_rsa +distant_dir=/data +SSHSOCKET=~/.ssh/ssh-socket-%r-%h-%p + +SEND_TO_CI () { + echo "============================" + echo ">>> Sending $1" + rsync -avzhuE -c --progress --delete --exclude=".git" "${1%/}" -e "ssh -i $ssh_key -p $ssh_port -o ControlPath=$SSHSOCKET" $ssh_user@$ssh_host:"$distant_dir/" + echo "=============" + echo "Build should show up here once it starts:" + echo "https://$ssh_host/jenkins/view/$ssh_user/job/$(basename "${1%/}")%20($ssh_user)/lastBuild/console" +} + +echo "Opening connection" +ssh $ssh_user@$ssh_host -p $ssh_port -i $ssh_key -f -M -N -o ControlPath=$SSHSOCKET +if [ "$?" -ne 0 ] +then + # If the user wait too long, the connection will fail. + # Same player try again + ssh $ssh_user@$ssh_host -p $ssh_port -i $ssh_key -f -M -N -o ControlPath=$SSHSOCKET +fi + +# If the script has arguments, use them +if [ -n "$folders_to_send" ] +then + # Read each arguments separately + for folder in "${folders_to_send[@]}" + do + SEND_TO_CI "$folder" + done + +# Otherwise, without arguments, use the static list +else + SEND_TO_CI "$script_dir/garradin_ynh" + SEND_TO_CI "$script_dir/APP2" + SEND_TO_CI "$script_dir/APP3" +fi + +echo "Closing connection" +ssh $ssh_user@$ssh_host -p $ssh_port -i $ssh_key -S $SSHSOCKET -O exit From 7bf9371cc64e6fd03fc53f243dc29e5f7db8f745 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Sun, 5 Apr 2020 15:01:54 +0200 Subject: [PATCH 056/207] delete sudo for bash commands --- scripts/install | 4 ++-- scripts/upgrade | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index d66ae60..75e6dda 100644 --- a/scripts/install +++ b/scripts/install @@ -80,11 +80,11 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_setup_source --dest_dir="$final_path" #================================================= -# Change options in file config.dist.php +# Change options in file config.dist.php # and copy in local.dist.php #================================================= -sudo cp -a $final_path/config.dist.php $final_path/config.local.php +cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" diff --git a/scripts/upgrade b/scripts/upgrade index 0466feb..c413b6b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -55,8 +55,8 @@ fi #================================================= ynh_script_progression --message="Backing up the bdd and squelettes before upgrading (may take a while)..." --time --weight=1 -sudo cp -avr /var/www/garradin/association.sqlite /tmp/association.sqlite -sudo cp -avr /var/www/garradin/www/squelettes /tmp/squelettes +cp -avr /var/www/garradin/association.sqlite /tmp/association.sqlite +cp -avr /var/www/garradin/www/squelettes /tmp/squelettes #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP @@ -116,11 +116,11 @@ then fi #================================================= -# Change options in file config.dist.php +# Change options in file config.dist.php # and copy in local.dist.php #================================================= -sudo cp -a $final_path/config.dist.php $final_path/config.local.php +cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" From 11508d2add1d5158d969e5b5e1387d7533e1ede1 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Sun, 5 Apr 2020 15:11:26 +0200 Subject: [PATCH 057/207] remove file script jenkins --- script_jenkins.sh | 61 ----------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 script_jenkins.sh diff --git a/script_jenkins.sh b/script_jenkins.sh deleted file mode 100644 index ad2bcd3..0000000 --- a/script_jenkins.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash - -# Usage: -# send_to_dev_ci.sh -# Use without arguments, the script will use the static list at the end of script -# -# send_to_dev_ci.sh my_app my_other_app "the directory/which/contains/my_third_app" -# Use with arguments, each argument will be considered as an app to send to the CI. - -# Get the path of this script -script_dir="$(dirname "$(realpath "$0")")" - -# Get potential arguments and store them into an array -if [ $# -ge 1 ] -then - folders_to_send=("$@") -fi - -ssh_user=rodinux -ssh_host=ci-apps-dev.yunohost.org -ssh_port=22 -ssh_key=~/.ssh/id_rsa -distant_dir=/data -SSHSOCKET=~/.ssh/ssh-socket-%r-%h-%p - -SEND_TO_CI () { - echo "============================" - echo ">>> Sending $1" - rsync -avzhuE -c --progress --delete --exclude=".git" "${1%/}" -e "ssh -i $ssh_key -p $ssh_port -o ControlPath=$SSHSOCKET" $ssh_user@$ssh_host:"$distant_dir/" - echo "=============" - echo "Build should show up here once it starts:" - echo "https://$ssh_host/jenkins/view/$ssh_user/job/$(basename "${1%/}")%20($ssh_user)/lastBuild/console" -} - -echo "Opening connection" -ssh $ssh_user@$ssh_host -p $ssh_port -i $ssh_key -f -M -N -o ControlPath=$SSHSOCKET -if [ "$?" -ne 0 ] -then - # If the user wait too long, the connection will fail. - # Same player try again - ssh $ssh_user@$ssh_host -p $ssh_port -i $ssh_key -f -M -N -o ControlPath=$SSHSOCKET -fi - -# If the script has arguments, use them -if [ -n "$folders_to_send" ] -then - # Read each arguments separately - for folder in "${folders_to_send[@]}" - do - SEND_TO_CI "$folder" - done - -# Otherwise, without arguments, use the static list -else - SEND_TO_CI "$script_dir/garradin_ynh" - SEND_TO_CI "$script_dir/APP2" - SEND_TO_CI "$script_dir/APP3" -fi - -echo "Closing connection" -ssh $ssh_user@$ssh_host -p $ssh_port -i $ssh_key -S $SSHSOCKET -O exit From 6dc8e42775cce689a4348b1def999c90e4e9ee2e Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sun, 5 Apr 2020 15:41:50 +0200 Subject: [PATCH 058/207] syntax error --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 7b24aaa..790f8be 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "id": "garradin", "packaging_format": 1, "requirements": { - "yunohost": "3.5.0" + "yunohost": ">=3.5.0" }, "description": { "en": "Software to manage association", From 8a30957fe2a3a0002f48c7e1fb9131abc5b59c7a Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sun, 5 Apr 2020 19:04:01 +0200 Subject: [PATCH 059/207] try ro change PATH nginx.conf --- conf/nginx.conf | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 7a2ff02..df88ec2 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,7 +1,7 @@ location __PATH__ { # Path to source - alias __FINALPATH__/www/ ; + alias __FINALPATH__/ ; if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; @@ -17,14 +17,6 @@ location __PATH__ { location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; - - # If you don't use a dedicated fpm config for your app, - # use a general fpm pool. - # This is to be used INSTEAD of line above - # Don't forget to adjust scripts install/upgrade/remove/backup accordingly - # - #fastcgi_pass unix:/var/run/php5-fpm.sock; - fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; From dbc98ddb7dd8ca05703a6f8f87b77aeb6cc441a4 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Sun, 5 Apr 2020 19:14:08 +0200 Subject: [PATCH 060/207] the garrdin must be insstalled on a sub-domain, back to put the correct path --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index df88ec2..e8fd78e 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,7 +1,7 @@ location __PATH__ { # Path to source - alias __FINALPATH__/ ; + alias __FINALPATH__/www/ ; if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; From 558b7e6f8a9a801250cedab4f36e764d5671d1ec Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Mon, 6 Apr 2020 22:24:19 +0200 Subject: [PATCH 061/207] try to delete slash at the end of PATH in nginx.conf --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index e8fd78e..a159644 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,7 +1,7 @@ location __PATH__ { # Path to source - alias __FINALPATH__/www/ ; + alias __FINALPATH__/www; if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; From fcde74e242f250e1a09f0a3d78275091096a614d Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Mon, 6 Apr 2020 23:53:40 +0200 Subject: [PATCH 062/207] change path_url in config.local.php for sripts install and upgrade --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 75e6dda..8919644 100644 --- a/scripts/install +++ b/scripts/install @@ -88,7 +88,7 @@ cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/$path_url/';" --target_file="$final_path/config.local.php" #================================================= # Files owned by user app diff --git a/scripts/upgrade b/scripts/upgrade index c413b6b..699be32 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -124,7 +124,7 @@ cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/garradin/';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" #================================================= From 59b191a4c43c1e51b5b3091e72ad70529cc9d8cf Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 00:15:33 +0200 Subject: [PATCH 063/207] change also the path for change_url --- scripts/change_url | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/change_url b/scripts/change_url index 4972ad6..d76615c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -57,6 +57,8 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf # Change the path in the nginx config file if [ $change_path -eq 1 ] then + # Change the path in the config.local.php + ynh_replace_string --match_string="//const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" # Make a backup of the original nginx config file if modified ynh_backup_if_checksum_is_different "$nginx_conf_path" # Replace locations starting with old_path @@ -68,6 +70,7 @@ then ynh_store_file_checksum "$nginx_conf_path" fi + # Change the domain for nginx if [ $change_domain -eq 1 ] then @@ -78,6 +81,7 @@ then ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" fi + #================================================= # GENERIC FINALISATION #================================================= From bb2412566a2417f80d7efbf73590e7978a781182 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 00:27:15 +0200 Subject: [PATCH 064/207] change also the path for change_url --- scripts/change_url | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index d76615c..eca34e9 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -44,6 +44,8 @@ change_path=0 if [ "$old_path" != "$new_path" ] then change_path=1 +# Change the path in the config.local.php + ynh_replace_string --match_string="//const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi #================================================= @@ -57,8 +59,6 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf # Change the path in the nginx config file if [ $change_path -eq 1 ] then - # Change the path in the config.local.php - ynh_replace_string --match_string="//const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" # Make a backup of the original nginx config file if modified ynh_backup_if_checksum_is_different "$nginx_conf_path" # Replace locations starting with old_path From d8aeba6ee0e8905dfcc99621a93b30affb72722f Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 00:44:12 +0200 Subject: [PATCH 065/207] change also the path for change_url --- scripts/change_url | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index eca34e9..e37ee48 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -44,9 +44,6 @@ change_path=0 if [ "$old_path" != "$new_path" ] then change_path=1 -# Change the path in the config.local.php - ynh_replace_string --match_string="//const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" -fi #================================================= # STANDARD MODIFICATIONS @@ -59,6 +56,9 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf # Change the path in the nginx config file if [ $change_path -eq 1 ] then +# Change the path in the config.local.php + ynh_replace_string --match_string="//const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$new_path/config.local.php" +fi # Make a backup of the original nginx config file if modified ynh_backup_if_checksum_is_different "$nginx_conf_path" # Replace locations starting with old_path From 82a4641ea7c8e27176ae8257c29dac76744097ae Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 00:51:30 +0200 Subject: [PATCH 066/207] change also the path for change_url --- scripts/change_url | 5 ++--- scripts/install | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index e37ee48..70bb37f 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -56,8 +56,6 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf # Change the path in the nginx config file if [ $change_path -eq 1 ] then -# Change the path in the config.local.php - ynh_replace_string --match_string="//const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$new_path/config.local.php" fi # Make a backup of the original nginx config file if modified ynh_backup_if_checksum_is_different "$nginx_conf_path" @@ -80,7 +78,8 @@ then # Store file checksum for the new config file location ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" fi - +# Change the path in the config.local.php + ynh_replace_string --match_string="//const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$new_path/config.local.php" #================================================= # GENERIC FINALISATION diff --git a/scripts/install b/scripts/install index 8919644..7327a06 100644 --- a/scripts/install +++ b/scripts/install @@ -88,7 +88,7 @@ cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/$path_url/';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" #================================================= # Files owned by user app From a30d4f767513cf32a17fcf6bbc8b011e81677bb0 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 00:55:58 +0200 Subject: [PATCH 067/207] change also the path for change_url --- scripts/change_url | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index 70bb37f..e3b76c7 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -44,6 +44,7 @@ change_path=0 if [ "$old_path" != "$new_path" ] then change_path=1 +fi #================================================= # STANDARD MODIFICATIONS @@ -56,7 +57,6 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf # Change the path in the nginx config file if [ $change_path -eq 1 ] then -fi # Make a backup of the original nginx config file if modified ynh_backup_if_checksum_is_different "$nginx_conf_path" # Replace locations starting with old_path From 2df243aa9dd5b503606a24179aaa33fbd3107e8c Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 01:13:29 +0200 Subject: [PATCH 068/207] change also the path for change_url --- scripts/change_url | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index e3b76c7..d9da808 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -53,6 +53,7 @@ fi #================================================= nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf +final_path=/var/www/$app # Change the path in the nginx config file if [ $change_path -eq 1 ] @@ -66,6 +67,7 @@ then ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path" # Calculate and store the nginx config file checksum ynh_store_file_checksum "$nginx_conf_path" + ynh_replace_string --match_string="//const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi @@ -78,10 +80,7 @@ then # Store file checksum for the new config file location ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" fi -# Change the path in the config.local.php - ynh_replace_string --match_string="//const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$new_path/config.local.php" -#================================================= # GENERIC FINALISATION #================================================= # RELOAD NGINX From 40f6ed1741000cb0fcbca626899acf927cb5c576 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 01:23:44 +0200 Subject: [PATCH 069/207] change also the path for change_url --- scripts/change_url | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index d9da808..dbd60b3 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -61,13 +61,13 @@ then # Make a backup of the original nginx config file if modified ynh_backup_if_checksum_is_different "$nginx_conf_path" # Replace locations starting with old_path + ynh_replace_string --match_string="//const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" # Look for every location possible patterns (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location) ynh_replace_string "location\( \(=\|~\|~\*\|\^~\)\)\? $old_path" "location\1 $new_path" "$nginx_conf_path" # Replace path in "return" directives ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path" # Calculate and store the nginx config file checksum ynh_store_file_checksum "$nginx_conf_path" - ynh_replace_string --match_string="//const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi From 51ed793aa865812dd700a880ae17effc5a64b830 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 01:39:37 +0200 Subject: [PATCH 070/207] change also the path for change_url --- scripts/change_url | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index dbd60b3..654bb14 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -61,13 +61,14 @@ then # Make a backup of the original nginx config file if modified ynh_backup_if_checksum_is_different "$nginx_conf_path" # Replace locations starting with old_path - ynh_replace_string --match_string="//const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" # Look for every location possible patterns (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location) ynh_replace_string "location\( \(=\|~\|~\*\|\^~\)\)\? $old_path" "location\1 $new_path" "$nginx_conf_path" # Replace path in "return" directives ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path" # Calculate and store the nginx config file checksum ynh_store_file_checksum "$nginx_conf_path" + # ynh_replace_string + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi From f52938879e75abe04ca4b88e42bd99edcb23df73 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 7 Apr 2020 03:32:36 +0200 Subject: [PATCH 071/207] try to debug upgrade --- scripts/upgrade | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 699be32..a80ce44 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,7 +21,6 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) || ynh_die "This path already contains a folder" - #================================================= # CHECK VERSION #================================================= @@ -38,7 +37,6 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= - ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 # Fix is_public as a boolean value @@ -55,8 +53,18 @@ fi #================================================= ynh_script_progression --message="Backing up the bdd and squelettes before upgrading (may take a while)..." --time --weight=1 -cp -avr /var/www/garradin/association.sqlite /tmp/association.sqlite -cp -avr /var/www/garradin/www/squelettes /tmp/squelettes +bdd=/var/www/garradin/association.sqlite +squelettes=/var/www/garradin//www/squelettes + +if [ -d "$squelettes" ] +then + cp -ar $squelettes /tmp/squelettes +fi + +if [ -b "$bdd" ] +then + cp -ar $bdd /tmp/association.sqlite +fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP @@ -106,11 +114,10 @@ ynh_install_app_dependencies $pkg_dependencies #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Upgrading source files..." --time --weight=1 if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --time --weight=1 - # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" fi @@ -130,9 +137,17 @@ ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string #================================================= # backup bdd, squelettes directory and config.local.php #================================================= +backup_bdd=/tmp/association.sqlite +backup_squelettes=/tmp/squelettes -sudo cp -a /tmp/association.sqlite $final_path/association.sqlite -sudo cp -avr /tmp/squelettes $final_path/www/squelettes +if [ -d "$backup_squelettes" ] +then + cp -ar /tmp/squelettes $final_path/www/squelettes +fi + +if [ -b "$backup_bdd" ] + cp -ar /tmp/association.sqlite $final_path/association.sqlite +fi #================================================= # NGINX CONFIGURATION @@ -142,7 +157,6 @@ ynh_script_progression --message="Upgrading nginx web server configuration..." - # Create a dedicated nginx config ynh_add_nginx_config - #================================================= # CREATE DEDICATED USER #================================================= From e0ad533a23870f8fb169d761c5ba948d83278c4f Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 03:45:34 +0200 Subject: [PATCH 072/207] error syntax --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index a80ce44..84ad963 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -146,6 +146,7 @@ then fi if [ -b "$backup_bdd" ] +then cp -ar /tmp/association.sqlite $final_path/association.sqlite fi From 173d02455d6d04d181c4afa2db849023ca99eb89 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 7 Apr 2020 04:36:13 +0200 Subject: [PATCH 073/207] chnage the code in upgrade to look for exist or not file association.bdd --- scripts/upgrade | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 84ad963..ccc4ef0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -61,9 +61,9 @@ then cp -ar $squelettes /tmp/squelettes fi -if [ -b "$bdd" ] +if [ -e "$bdd" ] then - cp -ar $bdd /tmp/association.sqlite + cp -a $bdd /tmp/association.sqlite fi #================================================= @@ -145,9 +145,9 @@ then cp -ar /tmp/squelettes $final_path/www/squelettes fi -if [ -b "$backup_bdd" ] -then - cp -ar /tmp/association.sqlite $final_path/association.sqlite +if [ -e "$backup_bdd" ] +then + cp -a /tmp/association.sqlite $final_path/association.sqlite fi #================================================= From 6694f285f49040c5880c564e42edad936eb19388 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 12:19:39 +0200 Subject: [PATCH 074/207] try to debug update script conditions --- scripts/upgrade | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index ccc4ef0..06ddfde 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -53,8 +53,8 @@ fi #================================================= ynh_script_progression --message="Backing up the bdd and squelettes before upgrading (may take a while)..." --time --weight=1 -bdd=/var/www/garradin/association.sqlite -squelettes=/var/www/garradin//www/squelettes +bdd=$final_path/association.sqlite +squelettes=$final_path/www/squelettes if [ -d "$squelettes" ] then @@ -122,21 +122,10 @@ then ynh_setup_source --dest_dir="$final_path" fi -#================================================= -# Change options in file config.dist.php -# and copy in local.dist.php -#================================================= - -cp -a $final_path/config.dist.php $final_path/config.local.php - -# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" - - #================================================= # backup bdd, squelettes directory and config.local.php #================================================= + backup_bdd=/tmp/association.sqlite backup_squelettes=/tmp/squelettes @@ -150,6 +139,18 @@ then cp -a /tmp/association.sqlite $final_path/association.sqlite fi + +#================================================= +# Change options in file config.dist.php +# and copy in local.dist.php +#================================================= + +cp -a $final_path/config.dist.php $final_path/config.local.php + +# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" + #================================================= # NGINX CONFIGURATION #================================================= From fd5defe25cfcd6d6447c381fe2a0106247cf4943 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 7 Apr 2020 13:28:59 +0200 Subject: [PATCH 075/207] try change install and update to debug scripts --- scripts/install | 3 ++- scripts/upgrade | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 7327a06..472d319 100644 --- a/scripts/install +++ b/scripts/install @@ -87,8 +87,9 @@ ynh_setup_source --dest_dir="$final_path" cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = $final_path/www" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" #================================================= # Files owned by user app diff --git a/scripts/upgrade b/scripts/upgrade index 06ddfde..2c9bf4c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -148,8 +148,9 @@ fi cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = $final_path/www" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" #================================================= # NGINX CONFIGURATION From 3e43ddd71e855276099f8dcd8db0b53baae7402c Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 13:47:22 +0200 Subject: [PATCH 076/207] try to debug update script conditions --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 472d319..44ff59d 100644 --- a/scripts/install +++ b/scripts/install @@ -87,7 +87,7 @@ ynh_setup_source --dest_dir="$final_path" cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = $final_path/www" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = $final_path/" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" diff --git a/scripts/upgrade b/scripts/upgrade index 2c9bf4c..4e8c4cc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -148,7 +148,7 @@ fi cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = $final_path/www" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = $final_path/" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" From 82639bb806fd48f99457bce65f2419ce2c95e2b1 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 14:02:57 +0200 Subject: [PATCH 077/207] try to debug update script conditions --- scripts/install | 2 +- scripts/upgrade | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 44ff59d..472d319 100644 --- a/scripts/install +++ b/scripts/install @@ -87,7 +87,7 @@ ynh_setup_source --dest_dir="$final_path" cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = $final_path/" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = $final_path/www" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" diff --git a/scripts/upgrade b/scripts/upgrade index 4e8c4cc..06ddfde 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -148,9 +148,8 @@ fi cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = $final_path/" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" #================================================= # NGINX CONFIGURATION From 6192bb687ef060064ed433d5eeb756c002449a41 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 14:17:32 +0200 Subject: [PATCH 078/207] try to debug update script conditions --- scripts/install | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 472d319..7327a06 100644 --- a/scripts/install +++ b/scripts/install @@ -87,9 +87,8 @@ ynh_setup_source --dest_dir="$final_path" cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = $final_path/www" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" #================================================= # Files owned by user app From 274ae1af7015b0174658367ec5c88d6e91b8d570 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 15:21:20 +0200 Subject: [PATCH 079/207] check_url available for check_package --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index b25c98b..6da1a82 100644 --- a/check_process +++ b/check_process @@ -15,7 +15,7 @@ multi_instance=1 incorrect_path=1 port_already_use=0 - change_url=0 + change_url=1 ;;; Levels Level 1=auto Level 2=auto From a8bb3d1711ca3af8f4c3f9b9e479dad9df9955ae Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 7 Apr 2020 16:12:46 +0200 Subject: [PATCH 080/207] try to make better check_packages dependencies --- check_process | 2 +- scripts/change_url | 2 ++ scripts/restore | 9 +++------ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/check_process b/check_process index 6da1a82..b1210b1 100644 --- a/check_process +++ b/check_process @@ -6,7 +6,7 @@ ; Checks pkg_linter=1 setup_sub_dir=1 - setup_root=1 + setup_root=0 setup_nourl=0 setup_private=1 setup_public=1 diff --git a/scripts/change_url b/scripts/change_url index 654bb14..0798955 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -80,6 +80,8 @@ then mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" + # ynh_replace_string + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi # GENERIC FINALISATION diff --git a/scripts/restore b/scripts/restore index fe8a148..75164ec 100644 --- a/scripts/restore +++ b/scripts/restore @@ -71,12 +71,9 @@ chown -R $app:$app $final_path #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= -if [ "$(lsb_release --codename --short)" != "jessie" ] -then - ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" -else - ynh_die --message="Votre version de Debian n'est pas compatible..." -fi +ynh_script_progression --message="Restore php-fpm configuration..." --time --weight=1 + +ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= # SPECIFIC RESTORATION From 5f01245abddc187b74a68d42cfd2a5caad02b17a Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Tue, 7 Apr 2020 16:48:22 +0200 Subject: [PATCH 081/207] try to make better check_packages dependencies --- scripts/change_url | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 0798955..e768040 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -58,6 +58,8 @@ final_path=/var/www/$app # Change the path in the nginx config file if [ $change_path -eq 1 ] then + # ynh_replace_string + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" # Make a backup of the original nginx config file if modified ynh_backup_if_checksum_is_different "$nginx_conf_path" # Replace locations starting with old_path @@ -67,8 +69,6 @@ then ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path" # Calculate and store the nginx config file checksum ynh_store_file_checksum "$nginx_conf_path" - # ynh_replace_string - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi @@ -81,7 +81,6 @@ then # Store file checksum for the new config file location ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" # ynh_replace_string - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi # GENERIC FINALISATION From de2f191a86f45c870f0e29187d8c35c36fbaec94 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 18:03:14 +0200 Subject: [PATCH 082/207] try to make possible install on root path and change url from or to root path --- conf/nginx.conf | 4 ++-- scripts/change_url | 24 ++++++++++++++++++------ scripts/install | 7 ++++++- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index a159644..fbcf8b5 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -8,13 +8,13 @@ location __PATH__ { } # Example PHP configuration (remove if not used) - index index.php; + index index.php /_route.php;; # Common parameter to increase upload size limit in conjuction with dedicated php-fpm file #client_max_body_size 50M; - try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { + try_files $uri $uri/ index.php /_route.php; fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; fastcgi_index index.php; diff --git a/scripts/change_url b/scripts/change_url index e768040..8b82734 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -37,13 +37,13 @@ old_path=$(ynh_normalize_url_path $old_path) change_domain=0 if [ "$old_domain" != "$new_domain" ] then - change_domain=1 + change_domain=1 fi change_path=0 if [ "$old_path" != "$new_path" ] then - change_path=1 + change_path=1 fi #================================================= @@ -58,8 +58,6 @@ final_path=/var/www/$app # Change the path in the nginx config file if [ $change_path -eq 1 ] then - # ynh_replace_string - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" # Make a backup of the original nginx config file if modified ynh_backup_if_checksum_is_different "$nginx_conf_path" # Replace locations starting with old_path @@ -69,6 +67,21 @@ then ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path" # Calculate and store the nginx config file checksum ynh_store_file_checksum "$nginx_conf_path" + # ynh_replace_string + if old_url != "/" + then + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" + else + ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" + fi + + if new_url != "/" + then + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" + else + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" + fi + fi @@ -77,10 +90,9 @@ if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location ynh_delete_file_checksum "$nginx_conf_path" - mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf + mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" - # ynh_replace_string fi # GENERIC FINALISATION diff --git a/scripts/install b/scripts/install index 7327a06..ccf548f 100644 --- a/scripts/install +++ b/scripts/install @@ -88,8 +88,13 @@ cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" +if path_url != "/" +then + ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" +else + ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" +fi #================================================= # Files owned by user app #================================================= From 8e416c03522136211a287eb142405a50aab80e4e Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 18:08:24 +0200 Subject: [PATCH 083/207] try to make possible install on root path and change url from or to root path --- scripts/change_url | 4 ++-- scripts/install | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 8b82734..f8e1b03 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -68,14 +68,14 @@ then # Calculate and store the nginx config file checksum ynh_store_file_checksum "$nginx_conf_path" # ynh_replace_string - if old_url != "/" + if $old_url != "/" then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" else ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi - if new_url != "/" + if $new_url != "/" then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" else diff --git a/scripts/install b/scripts/install index ccf548f..ec0bd7f 100644 --- a/scripts/install +++ b/scripts/install @@ -89,7 +89,7 @@ cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" -if path_url != "/" +if $path_url != "/" then ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" else From 8297a8050b841f090a372fd89ce22a030f62a552 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 18:16:27 +0200 Subject: [PATCH 084/207] try to make possible install on root path and change url from or to root path --- scripts/change_url | 4 ++-- scripts/install | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index f8e1b03..c8c18e1 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -68,14 +68,14 @@ then # Calculate and store the nginx config file checksum ynh_store_file_checksum "$nginx_conf_path" # ynh_replace_string - if $old_url != "/" + if $old_url != / then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" else ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi - if $new_url != "/" + if $new_url != / then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" else diff --git a/scripts/install b/scripts/install index ec0bd7f..10c1b7e 100644 --- a/scripts/install +++ b/scripts/install @@ -89,7 +89,7 @@ cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" -if $path_url != "/" +if $path_url != / then ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" else From f0d6e0116aca4394efc200edc49e2d5605f88823 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 18:18:40 +0200 Subject: [PATCH 085/207] try to make possible install on root path and change url from or to root path --- conf/nginx.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index fbcf8b5..5292783 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -8,13 +8,13 @@ location __PATH__ { } # Example PHP configuration (remove if not used) - index index.php /_route.php;; + index index.php; # Common parameter to increase upload size limit in conjuction with dedicated php-fpm file #client_max_body_size 50M; location ~ [^/]\.php(/|$) { - try_files $uri $uri/ index.php /_route.php; + try_files $uri $uri/ index.php; fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; fastcgi_index index.php; From 853c60a09217e52d4889fe348bc386d067daa3fa Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 18:22:25 +0200 Subject: [PATCH 086/207] try to make possible install on root path and change url from or to root path --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 10c1b7e..32c262b 100644 --- a/scripts/install +++ b/scripts/install @@ -91,9 +91,9 @@ ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string if $path_url != / then - ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" + ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" else - ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" + ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" fi #================================================= # Files owned by user app From 002c6b1d449a346525d1b09b87c57081317698f6 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 18:32:12 +0200 Subject: [PATCH 087/207] try to make possible install on root path and change url from or to root path --- conf/nginx.conf | 2 +- scripts/install | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 5292783..3b36f07 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -8,7 +8,7 @@ location __PATH__ { } # Example PHP configuration (remove if not used) - index index.php; + # index index.php; # Common parameter to increase upload size limit in conjuction with dedicated php-fpm file #client_max_body_size 50M; diff --git a/scripts/install b/scripts/install index 32c262b..10c1b7e 100644 --- a/scripts/install +++ b/scripts/install @@ -91,9 +91,9 @@ ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string if $path_url != / then - ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" + ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" else - ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" + ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" fi #================================================= # Files owned by user app From 1a99a69f7c5f36293744191a2b72bb020536d1ec Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 18:52:49 +0200 Subject: [PATCH 088/207] try to make possible install on root path and change url from or to root path --- scripts/install | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/install b/scripts/install index 10c1b7e..d150526 100644 --- a/scripts/install +++ b/scripts/install @@ -92,8 +92,6 @@ ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string if $path_url != / then ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" -else - ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" fi #================================================= # Files owned by user app From 7e4b9eca7631b94044cd4873a1bbce61a52e9389 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 19:00:57 +0200 Subject: [PATCH 089/207] try to make possible install on root path and change url from or to root path --- conf/nginx.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 3b36f07..7c4f09a 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -8,13 +8,13 @@ location __PATH__ { } # Example PHP configuration (remove if not used) - # index index.php; + index index.php /_route.php; # Common parameter to increase upload size limit in conjuction with dedicated php-fpm file #client_max_body_size 50M; location ~ [^/]\.php(/|$) { - try_files $uri $uri/ index.php; + try_files $uri $uri/ index.php /_route.php; fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; fastcgi_index index.php; From a4ada7041111efc29373508da392a47e64543d4a Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 19:05:40 +0200 Subject: [PATCH 090/207] try to make possible install on root path and change url from or to root path --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index d150526..a6d34a4 100644 --- a/scripts/install +++ b/scripts/install @@ -89,7 +89,7 @@ cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" -if $path_url != / +if $path_url != '/' then ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" fi From 7fbd49baada7ff30d043c31353dcc498e1911442 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 19:09:51 +0200 Subject: [PATCH 091/207] try to make possible install on root path and change url from or to root path --- scripts/install | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index a6d34a4..7327a06 100644 --- a/scripts/install +++ b/scripts/install @@ -88,11 +88,8 @@ cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" -if $path_url != '/' -then - ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" -fi #================================================= # Files owned by user app #================================================= From d123e8a6d6306cacfe5fabf05e62e94514f0019c Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 19:19:15 +0200 Subject: [PATCH 092/207] try to make possible install on root path and change url from or to root path --- conf/nginx.conf | 2 +- scripts/change_url | 15 +-------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 7c4f09a..265611a 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -8,7 +8,7 @@ location __PATH__ { } # Example PHP configuration (remove if not used) - index index.php /_route.php; + # index index.php /_route.php; # Common parameter to increase upload size limit in conjuction with dedicated php-fpm file #client_max_body_size 50M; diff --git a/scripts/change_url b/scripts/change_url index c8c18e1..96e3e4a 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -68,20 +68,7 @@ then # Calculate and store the nginx config file checksum ynh_store_file_checksum "$nginx_conf_path" # ynh_replace_string - if $old_url != / - then - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" - else - ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" - fi - - if $new_url != / - then - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" - else - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" - fi - + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi From 05cc520dd9b170a55d8a9a7db2b5e28323eade6d Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 19:46:56 +0200 Subject: [PATCH 093/207] try to make possible install on root path and change url from or to root path --- conf/nginx.conf | 4 ++-- scripts/install | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 265611a..5292783 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -8,13 +8,13 @@ location __PATH__ { } # Example PHP configuration (remove if not used) - # index index.php /_route.php; + index index.php; # Common parameter to increase upload size limit in conjuction with dedicated php-fpm file #client_max_body_size 50M; location ~ [^/]\.php(/|$) { - try_files $uri $uri/ index.php /_route.php; + try_files $uri $uri/ index.php; fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; fastcgi_index index.php; diff --git a/scripts/install b/scripts/install index 7327a06..d7f6478 100644 --- a/scripts/install +++ b/scripts/install @@ -89,6 +89,7 @@ cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = '/var/www/garradin/www';" --target_file="$final_path/config.local.php" #================================================= # Files owned by user app From ea6749662d8e60c0aff7d08cbdb0b56baf9fbccc Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 20:00:37 +0200 Subject: [PATCH 094/207] try to make possible install on root path and change url from or to root path --- conf/nginx.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 5292783..bcfc888 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -8,13 +8,13 @@ location __PATH__ { } # Example PHP configuration (remove if not used) - index index.php; # Common parameter to increase upload size limit in conjuction with dedicated php-fpm file #client_max_body_size 50M; location ~ [^/]\.php(/|$) { - try_files $uri $uri/ index.php; + try_files $uri $uri/ index.php /routes.php; + index index.php /_route.php; fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; fastcgi_index index.php; From efecd9f88fed8910a7f113dff706b4d1c9ac1a6f Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 20:26:17 +0200 Subject: [PATCH 095/207] come back to precedent config por nginx --- conf/nginx.conf | 6 +++--- scripts/install | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index bcfc888..36a7e15 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -8,13 +8,13 @@ location __PATH__ { } # Example PHP configuration (remove if not used) + index index.php; # Common parameter to increase upload size limit in conjuction with dedicated php-fpm file #client_max_body_size 50M; + try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { - try_files $uri $uri/ index.php /routes.php; - index index.php /_route.php; fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; fastcgi_index index.php; @@ -27,4 +27,4 @@ location __PATH__ { # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; -} +} \ No newline at end of file diff --git a/scripts/install b/scripts/install index d7f6478..7327a06 100644 --- a/scripts/install +++ b/scripts/install @@ -89,7 +89,6 @@ cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = '/var/www/garradin/www';" --target_file="$final_path/config.local.php" #================================================= # Files owned by user app From 135ac5033dfe48e8cc847910b3eff4295a4b4ac2 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Tue, 7 Apr 2020 23:46:46 +0200 Subject: [PATCH 096/207] just a test to watch if it is possible like this install on root path --- scripts/change_url | 10 +++++++--- scripts/install | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 96e3e4a..682215d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -68,9 +68,13 @@ then # Calculate and store the nginx config file checksum ynh_store_file_checksum "$nginx_conf_path" # ynh_replace_string - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" -fi - + if [ $new_path != '/' ] + then + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" + else + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '/';" --target_file="$final_path/config.local.php" + fi +fi # Change the domain for nginx if [ $change_domain -eq 1 ] diff --git a/scripts/install b/scripts/install index 7327a06..5c34850 100644 --- a/scripts/install +++ b/scripts/install @@ -88,7 +88,7 @@ cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/';" --target_file="$final_path/config.local.php" #================================================= # Files owned by user app From 7536ad48829765989a364832524761125cc6b009 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Wed, 8 Apr 2020 00:29:27 +0200 Subject: [PATCH 097/207] come back to this code, have not found how to install on root path with this version --- scripts/change_url | 7 +------ scripts/install | 4 ++-- scripts/upgrade | 1 - 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 682215d..ce53487 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -68,12 +68,7 @@ then # Calculate and store the nginx config file checksum ynh_store_file_checksum "$nginx_conf_path" # ynh_replace_string - if [ $new_path != '/' ] - then - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" - else - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '/';" --target_file="$final_path/config.local.php" - fi + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi # Change the domain for nginx diff --git a/scripts/install b/scripts/install index 5c34850..b11cf9a 100644 --- a/scripts/install +++ b/scripts/install @@ -87,8 +87,8 @@ ynh_setup_source --dest_dir="$final_path" cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '/';" --target_file="$final_path/config.local.php" +# ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" #================================================= # Files owned by user app diff --git a/scripts/upgrade b/scripts/upgrade index 06ddfde..e92853f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -148,7 +148,6 @@ fi cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" #================================================= From 896c1f39273689df3fe31493c7a731d33daa69c6 Mon Sep 17 00:00:00 2001 From: Rodolphe Robles Date: Wed, 8 Apr 2020 00:33:18 +0200 Subject: [PATCH 098/207] but back check_up as origin --- check_process | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check_process b/check_process index b1210b1..b25c98b 100644 --- a/check_process +++ b/check_process @@ -6,7 +6,7 @@ ; Checks pkg_linter=1 setup_sub_dir=1 - setup_root=0 + setup_root=1 setup_nourl=0 setup_private=1 setup_public=1 @@ -15,7 +15,7 @@ multi_instance=1 incorrect_path=1 port_already_use=0 - change_url=1 + change_url=0 ;;; Levels Level 1=auto Level 2=auto From eef837e3726be16eaa4722cc3bcdbc8ccbea262f Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 10:43:15 +0200 Subject: [PATCH 099/207] add a search for nginx.conf --- conf/nginx.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index a159644..fbcf8b5 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -8,13 +8,13 @@ location __PATH__ { } # Example PHP configuration (remove if not used) - index index.php; + index index.php /_route.php;; # Common parameter to increase upload size limit in conjuction with dedicated php-fpm file #client_max_body_size 50M; - try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { + try_files $uri $uri/ index.php /_route.php; fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; fastcgi_index index.php; From cbc7e7005df96b721ee72df0376b620337fed008 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 13:53:16 +0200 Subject: [PATCH 100/207] try change nginx.conf and how to add a line on config.local.php --- conf/nginx.conf | 37 ++++++++++++++++++++++--------------- scripts/install | 5 +++-- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index b366318..586c8d6 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,28 +1,35 @@ location __PATH__ { # Path to source - alias __FINALPATH__/www; + root __FINALPATH__/www ; if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } - # Example PHP configuration (remove if not used) - index index.php /_route.php;; - - # Common parameter to increase upload size limit in conjuction with dedicated php-fpm file - #client_max_body_size 50M; - - location ~ [^/]\.php(/|$) { + location / { try_files $uri $uri/ index.php /_route.php; - fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; - fastcgi_index index.php; - include fastcgi_params; - fastcgi_param REMOTE_USER $remote_user; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param SCRIPT_FILENAME $request_filename; + index index.php /_route.php; } + +location ~ \.php { + try_files $uri $uri/ /_route.php; + fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; + include fastcgi_params; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $request_filename; + +# location ~ [^/]\.php(/|$) { +# try_files $uri $uri/ index.php /_route.php; +# fastcgi_split_path_info ^(.+?\.php)(/.*)$; +# fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; +# fastcgi_index index.php; +# include fastcgi_params; +# fastcgi_param REMOTE_USER $remote_user; +# fastcgi_param PATH_INFO $fastcgi_path_info; +# fastcgi_param SCRIPT_FILENAME $request_filename; +} # PHP configuration end # Include SSOWAT user panel. diff --git a/scripts/install b/scripts/install index b11cf9a..b3f4799 100644 --- a/scripts/install +++ b/scripts/install @@ -84,11 +84,12 @@ ynh_setup_source --dest_dir="$final_path" # and copy in local.dist.php #================================================= -cp -a $final_path/config.dist.php $final_path/config.local.php +echo "const WWW_URI = '$path_url';" >> $final_path/config.local.php +#cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" # ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" +#ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" #================================================= # Files owned by user app From 9a9f7cf8437d7b607e5ca9010da5407da09bc199 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 14:00:43 +0200 Subject: [PATCH 101/207] try change nginx.conf and how to add a line on config.local.php --- conf/nginx.conf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 586c8d6..0f0e75e 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,13 +1,13 @@ location __PATH__ { # Path to source - root __FINALPATH__/www ; + root __FINALPATH__/www/ ; if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } - location / { +location / { try_files $uri $uri/ index.php /_route.php; index index.php /_route.php; } @@ -15,7 +15,7 @@ location __PATH__ { location ~ \.php { try_files $uri $uri/ /_route.php; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; - include fastcgi_params; + include fastcgi.conf; fastcgi_param REMOTE_USER $remote_user; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $request_filename; From 920cc1205a722e3c7734373eecd45858cf2860ec Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 14:09:31 +0200 Subject: [PATCH 102/207] try change nginx.conf --- conf/nginx.conf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 0f0e75e..2d09ea6 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -7,10 +7,10 @@ location __PATH__ { rewrite ^ https://$server_name$request_uri? permanent; } -location / { - try_files $uri $uri/ index.php /_route.php; - index index.php /_route.php; - } + +try_files $uri $uri/ index.php /_route.php; +index index.php /_route.php; + location ~ \.php { try_files $uri $uri/ /_route.php; From 02908c90862271d60cb449887c213380ec1eacfb Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 14:17:22 +0200 Subject: [PATCH 103/207] try change nginx.conf --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index b3f4799..254d494 100644 --- a/scripts/install +++ b/scripts/install @@ -84,7 +84,7 @@ ynh_setup_source --dest_dir="$final_path" # and copy in local.dist.php #================================================= -echo "const WWW_URI = '$path_url';" >> $final_path/config.local.php +#echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php #cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" From 9f30ac07ee7f4eba721d5d677b4634b4a61b0726 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 14:29:16 +0200 Subject: [PATCH 104/207] try change nginx.conf --- conf/nginx.conf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 2d09ea6..4b0f3a5 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,12 +1,11 @@ location __PATH__ { - # Path to source - root __FINALPATH__/www/ ; +# Path to source +root __FINALPATH__/www/ ; - if ($scheme = http) { +if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; - } - +} try_files $uri $uri/ index.php /_route.php; index index.php /_route.php; @@ -14,6 +13,7 @@ index index.php /_route.php; location ~ \.php { try_files $uri $uri/ /_route.php; + fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; include fastcgi.conf; fastcgi_param REMOTE_USER $remote_user; From e601e60b3b560a1e8cf4990ce778a66138143bd8 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 14:33:16 +0200 Subject: [PATCH 105/207] change install --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 254d494..2f21077 100644 --- a/scripts/install +++ b/scripts/install @@ -85,11 +85,11 @@ ynh_setup_source --dest_dir="$final_path" #================================================= #echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php -#cp -a $final_path/config.dist.php $final_path/config.local.php +cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" # ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" -#ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" #================================================= # Files owned by user app From a87ff6e9f37bae9ca3817fbd7bf19d5382be436d Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 15:00:09 +0200 Subject: [PATCH 106/207] try change nginx.conf --- conf/nginx.conf | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 4b0f3a5..e76ff4b 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,7 +1,7 @@ -location __PATH__ { +location __PATH__/ { # Path to source -root __FINALPATH__/www/ ; +alias __FINALPATH__/www/ ; if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; @@ -15,7 +15,8 @@ location ~ \.php { try_files $uri $uri/ /_route.php; fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; - include fastcgi.conf; + fastcgi_index index.php; + include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $request_filename; From 1992aca2130bc9072b44e0798e761fc79642e1f0 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 15:22:21 +0200 Subject: [PATCH 107/207] try change nginx.conf --- conf/nginx.conf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index e76ff4b..73491b3 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,18 +1,18 @@ location __PATH__/ { # Path to source -alias __FINALPATH__/www/ ; +alias __FINALPATH__/www ; if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } -try_files $uri $uri/ index.php /_route.php; -index index.php /_route.php; +try_files $uri $uri/ index.php +index index.php location ~ \.php { - try_files $uri $uri/ /_route.php; + try_files $uri $uri/ fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; fastcgi_index index.php; From fe1eb39e3ba8df65a70bf888dfea53783b251ec6 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 15:25:17 +0200 Subject: [PATCH 108/207] try change nginx.conf --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 73491b3..f029eec 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -12,7 +12,7 @@ index index.php location ~ \.php { - try_files $uri $uri/ + try_files $uri $uri/ index.php; fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; fastcgi_index index.php; From f442f53b8ce2841b31e3275ff0582304ce5873c9 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 15:29:38 +0200 Subject: [PATCH 109/207] try change nginx.conf --- conf/nginx.conf | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index f029eec..9922f5f 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -7,9 +7,7 @@ if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } -try_files $uri $uri/ index.php -index index.php - +index index.php; location ~ \.php { try_files $uri $uri/ index.php; From 0a48c5960f7aa5377584dd3d0a7ee85d52b598d6 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 15:34:50 +0200 Subject: [PATCH 110/207] try change nginx.conf --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 9922f5f..9368874 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -8,9 +8,9 @@ if ($scheme = http) { } index index.php; +try_files $uri $uri/ index.php; location ~ \.php { - try_files $uri $uri/ index.php; fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; fastcgi_index index.php; From 031b9471fa84839a43792a48b1aa29838dbf02d6 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 15:44:55 +0200 Subject: [PATCH 111/207] try change nginx.conf --- conf/nginx.conf | 3 --- 1 file changed, 3 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 9368874..7b17562 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -7,9 +7,6 @@ if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } -index index.php; -try_files $uri $uri/ index.php; - location ~ \.php { fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; From 38750f05f4db6f9030b5c65cbee57efad1ac23e7 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 15:48:46 +0200 Subject: [PATCH 112/207] try change nginx.conf --- conf/nginx.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/conf/nginx.conf b/conf/nginx.conf index 7b17562..5edd960 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -7,6 +7,10 @@ if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } + # Example PHP configuration (remove if not used) + index index.php; + try_files $uri $uri/ index.php; + location ~ \.php { fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; From e8c9ab997060cc2505ad642d4650cd67c89d7c65 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 15:53:00 +0200 Subject: [PATCH 113/207] try change nginx.conf --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 5edd960..e323645 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -11,7 +11,7 @@ if ($scheme = http) { index index.php; try_files $uri $uri/ index.php; -location ~ \.php { +location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; fastcgi_index index.php; From bd56a81f01ce50e8f146bdced5b4704f485b8ab6 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 16:03:12 +0200 Subject: [PATCH 114/207] try change nginx.conf --- conf/nginx.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index e323645..04b7102 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,7 +1,7 @@ -location __PATH__/ { +location __PATH__ { # Path to source -alias __FINALPATH__/www ; +alias __FINALPATH__/www/ ; if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; From 7b5abb2e1a049c9bb435539307d90ae8f4c09465 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 16:16:05 +0200 Subject: [PATCH 115/207] try change nginx.conf --- conf/nginx.conf | 4 ++-- scripts/change_url | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 04b7102..fa9058b 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -8,8 +8,8 @@ if ($scheme = http) { } # Example PHP configuration (remove if not used) - index index.php; - try_files $uri $uri/ index.php; + index index.php /_route.php; + try_files $uri $uri/ index.php /_route.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; diff --git a/scripts/change_url b/scripts/change_url index ce53487..067a756 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -69,7 +69,7 @@ then ynh_store_file_checksum "$nginx_conf_path" # ynh_replace_string ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" -fi +fi # Change the domain for nginx if [ $change_domain -eq 1 ] @@ -81,6 +81,7 @@ then ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" fi +#================================================= # GENERIC FINALISATION #================================================= # RELOAD NGINX From 87db3cee48b902c7231853d82dc0b8efa29729f0 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 16:25:09 +0200 Subject: [PATCH 116/207] success, change check_path --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index b25c98b..6da1a82 100644 --- a/check_process +++ b/check_process @@ -15,7 +15,7 @@ multi_instance=1 incorrect_path=1 port_already_use=0 - change_url=0 + change_url=1 ;;; Levels Level 1=auto Level 2=auto From b880d01691b6e0ea9a0c2eaa1e194222cd27e94a Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 17:23:01 +0200 Subject: [PATCH 117/207] few change to delete blanks --- conf/nginx.conf | 10 ---------- scripts/install | 2 -- scripts/upgrade | 2 -- 3 files changed, 14 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index fa9058b..8328b41 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -19,16 +19,6 @@ location ~ [^/]\.php(/|$) { fastcgi_param REMOTE_USER $remote_user; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $request_filename; - -# location ~ [^/]\.php(/|$) { -# try_files $uri $uri/ index.php /_route.php; -# fastcgi_split_path_info ^(.+?\.php)(/.*)$; -# fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; -# fastcgi_index index.php; -# include fastcgi_params; -# fastcgi_param REMOTE_USER $remote_user; -# fastcgi_param PATH_INFO $fastcgi_path_info; -# fastcgi_param SCRIPT_FILENAME $request_filename; } # PHP configuration end diff --git a/scripts/install b/scripts/install index 2f21077..39f5c2c 100644 --- a/scripts/install +++ b/scripts/install @@ -118,8 +118,6 @@ ynh_add_fpm_config #================================================= ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 - - if [ $is_public -eq 0 ] then # Remove the public access ynh_app_setting_delete $app skipped_uris diff --git a/scripts/upgrade b/scripts/upgrade index e92853f..0778dec 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,7 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers - #================================================= # LOAD SETTINGS #================================================= @@ -139,7 +138,6 @@ then cp -a /tmp/association.sqlite $final_path/association.sqlite fi - #================================================= # Change options in file config.dist.php # and copy in local.dist.php From 20cc7504a910c9c8cbaa80576d227bed2507b099 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 17:56:34 +0200 Subject: [PATCH 118/207] delete sudo not need on install --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 39f5c2c..ecde0c5 100644 --- a/scripts/install +++ b/scripts/install @@ -95,8 +95,8 @@ ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string # Files owned by user app #================================================= -sudo chown $app:$app $final_path -R -sudo chmod 755 $final_path -R +chown $app:$app $final_path -R +chmod 755 $final_path -R #================================================= # NGINX CONFIGURATION From 45bd6b3a49547ff45faacdcd05f7bcda705e855e Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 18:07:07 +0200 Subject: [PATCH 119/207] comment ynh_delete_file_checksum in common.sh --- scripts/_common.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 73fbed9..d290ad2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -14,7 +14,7 @@ pkg_dependencies="php7.0-sqlite3" # # usage: ynh_remove_file_checksum file # | arg: file - The file for which the checksum will be deleted -ynh_delete_file_checksum () { - local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' - ynh_app_setting_delete $app $checksum_setting_name -} \ No newline at end of file +# ynh_delete_file_checksum () { +# local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' +# ynh_app_setting_delete $app $checksum_setting_name +# } \ No newline at end of file From 4850b1715ba0b325de8b05d22b007b28f7cde0b0 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 18:08:06 +0200 Subject: [PATCH 120/207] delete ynh_delete_file_checksum in common.sh --- scripts/_common.sh | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index d290ad2..6248f06 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,13 +8,3 @@ pkg_dependencies="php7.0-sqlite3" # ============= FUTURE YUNOHOST HELPER ============= -# Delete a file checksum from the app settings -# -# $app should be defined when calling this helper -# -# usage: ynh_remove_file_checksum file -# | arg: file - The file for which the checksum will be deleted -# ynh_delete_file_checksum () { -# local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_' -# ynh_app_setting_delete $app $checksum_setting_name -# } \ No newline at end of file From 0aa1ea1b35ca03692385a5b354c8ca6fea08f752 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 8 Apr 2020 18:53:30 +0200 Subject: [PATCH 121/207] delete sudo on upgrade, no need --- scripts/upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 0778dec..de80e5f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -178,8 +178,8 @@ ynh_system_user_create --username=$app # Files owned by user app #================================================= -sudo chown $app:$app $final_path -R -sudo chmod 755 $final_path -R +chown $app:$app $final_path -R +chmod 755 $final_path -R #================================================= # PHP-FPM CONFIGURATION From 3aeae720be24011c56fa75a809f000225a6568ea Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 11:37:55 +0200 Subject: [PATCH 122/207] put condition in install and update for config.local.php --- scripts/install | 3 +-- scripts/upgrade | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/scripts/install b/scripts/install index ecde0c5..59b22e7 100644 --- a/scripts/install +++ b/scripts/install @@ -86,10 +86,9 @@ ynh_setup_source --dest_dir="$final_path" #echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php cp -a $final_path/config.dist.php $final_path/config.local.php - +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" # ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" #================================================= # Files owned by user app diff --git a/scripts/upgrade b/scripts/upgrade index de80e5f..e635a93 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -54,6 +54,7 @@ ynh_script_progression --message="Backing up the bdd and squelettes before upgra bdd=$final_path/association.sqlite squelettes=$final_path/www/squelettes +conf=$final_path/www/config.local.php if [ -d "$squelettes" ] then @@ -65,6 +66,11 @@ then cp -a $bdd /tmp/association.sqlite fi +if [ -e "$conf" ] +then + cp -a $bdd /tmp/config.local.php +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -127,26 +133,28 @@ fi backup_bdd=/tmp/association.sqlite backup_squelettes=/tmp/squelettes +backup_conf=/tmp/config.local.php if [ -d "$backup_squelettes" ] then - cp -ar /tmp/squelettes $final_path/www/squelettes + cp -ar $backup_squelettes $final_path/www/squelettes fi if [ -e "$backup_bdd" ] then - cp -a /tmp/association.sqlite $final_path/association.sqlite + cp -a $backup_bdd $final_path/association.sqlite fi -#================================================= -# Change options in file config.dist.php -# and copy in local.dist.php -#================================================= - -cp -a $final_path/config.dist.php $final_path/config.local.php +if [ -e "$backup_conf" ] +then + cp -a $backup_conf $final_path/config.local.php + echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php +else + cp -a $final_path/config.dist.php $final_path/config.local.php + ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" +fi # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" #================================================= # NGINX CONFIGURATION From 3b39673791cb28b8dd05d08ac25d8d5a99152136 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 11:56:03 +0200 Subject: [PATCH 123/207] put condition in install and update for config.local.php --- scripts/upgrade | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index e635a93..f186f46 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -147,8 +147,7 @@ fi if [ -e "$backup_conf" ] then - cp -a $backup_conf $final_path/config.local.php - echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php + cp -a $backup_conf $final_path/config.local.php && echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php else cp -a $final_path/config.dist.php $final_path/config.local.php ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" From b40973c0a50410461870df088b1e45808c1e218c Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 12:17:39 +0200 Subject: [PATCH 124/207] try to save secret key if exist on update --- scripts/upgrade | 54 ++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index f186f46..46e9e05 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -127,33 +127,6 @@ then ynh_setup_source --dest_dir="$final_path" fi -#================================================= -# backup bdd, squelettes directory and config.local.php -#================================================= - -backup_bdd=/tmp/association.sqlite -backup_squelettes=/tmp/squelettes -backup_conf=/tmp/config.local.php - -if [ -d "$backup_squelettes" ] -then - cp -ar $backup_squelettes $final_path/www/squelettes -fi - -if [ -e "$backup_bdd" ] -then - cp -a $backup_bdd $final_path/association.sqlite -fi - -if [ -e "$backup_conf" ] -then - cp -a $backup_conf $final_path/config.local.php && echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php -else - cp -a $final_path/config.dist.php $final_path/config.local.php - ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" -fi - -# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" #================================================= # NGINX CONFIGURATION @@ -215,6 +188,33 @@ ynh_script_progression --message="Reloading nginx web server..." --time --weight ynh_systemd_action --service_name=nginx --action=reload +#================================================= +# backup bdd, squelettes directory and config.local.php +#================================================= + +backup_bdd=/tmp/association.sqlite +backup_squelettes=/tmp/squelettes +backup_conf=/tmp/config.local.php + +if [ -d "$backup_squelettes" ] +then + cp -ar $backup_squelettes $final_path/www/squelettes +fi + +if [ -e "$backup_bdd" ] +then + cp -a $backup_bdd $final_path/association.sqlite +fi + +if [ -e "$backup_conf" ] +then + cp -a $backup_conf $final_path/config.local.php && echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php +else + cp -a $final_path/config.dist.php $final_path/config.local.php + ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" +fi + +# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" #================================================= # END OF SCRIPT #================================================= From 6e88b09c061a695975ba363a1c61b066b0ac85f3 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 12:27:38 +0200 Subject: [PATCH 125/207] try to save secret key if exist on update --- scripts/upgrade | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 46e9e05..a07782c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -54,7 +54,6 @@ ynh_script_progression --message="Backing up the bdd and squelettes before upgra bdd=$final_path/association.sqlite squelettes=$final_path/www/squelettes -conf=$final_path/www/config.local.php if [ -d "$squelettes" ] then @@ -66,11 +65,6 @@ then cp -a $bdd /tmp/association.sqlite fi -if [ -e "$conf" ] -then - cp -a $bdd /tmp/config.local.php -fi - #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -194,7 +188,6 @@ ynh_systemd_action --service_name=nginx --action=reload backup_bdd=/tmp/association.sqlite backup_squelettes=/tmp/squelettes -backup_conf=/tmp/config.local.php if [ -d "$backup_squelettes" ] then @@ -206,12 +199,10 @@ then cp -a $backup_bdd $final_path/association.sqlite fi -if [ -e "$backup_conf" ] -then - cp -a $backup_conf $final_path/config.local.php && echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php -else - cp -a $final_path/config.dist.php $final_path/config.local.php - ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" +echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php + +#cp -a $final_path/config.dist.php $final_path/config.local.php +# ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" fi # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" From 09a789697346f4e9fefe30ce08c53d6bf2f53f3d Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 12:30:00 +0200 Subject: [PATCH 126/207] try to save secret key if exist on update --- scripts/upgrade | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index a07782c..703b879 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -203,7 +203,6 @@ echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php #cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" -fi # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" #================================================= From d1156bb199af10835f4cbe43ed52d3aba8b5f3f6 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 12:43:28 +0200 Subject: [PATCH 127/207] try to save secret key if exist on update --- scripts/install | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/scripts/install b/scripts/install index 59b22e7..43ce2e8 100644 --- a/scripts/install +++ b/scripts/install @@ -79,16 +79,6 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" -#================================================= -# Change options in file config.dist.php -# and copy in local.dist.php -#================================================= - -#echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php -cp -a $final_path/config.dist.php $final_path/config.local.php -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" -# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" -# ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" #================================================= # Files owned by user app @@ -135,6 +125,17 @@ ynh_script_progression --message="Reloading nginx web server..." --time --weight systemctl reload nginx +#================================================= +# Change options in file config.dist.php +# and copy in local.dist.php +#================================================= + +echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php +# cp -a $final_path/config.dist.php $final_path/config.local.php +# ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" +# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" +# ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" + #================================================= # END OF SCRIPT #================================================= From 3864349b6c833c2e0a14b0943d5a11cbe6521fd1 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 12:52:14 +0200 Subject: [PATCH 128/207] try to keep secret key script on install --- scripts/install | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/scripts/install b/scripts/install index 43ce2e8..f24618b 100644 --- a/scripts/install +++ b/scripts/install @@ -87,6 +87,15 @@ ynh_setup_source --dest_dir="$final_path" chown $app:$app $final_path -R chmod 755 $final_path -R +#================================================= +# Change options in file config.dist.php +# and copy in local.dist.php +#================================================= + +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.dist.php" +# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" +# ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" + #================================================= # NGINX CONFIGURATION #================================================= @@ -125,17 +134,6 @@ ynh_script_progression --message="Reloading nginx web server..." --time --weight systemctl reload nginx -#================================================= -# Change options in file config.dist.php -# and copy in local.dist.php -#================================================= - -echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php -# cp -a $final_path/config.dist.php $final_path/config.local.php -# ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" -# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" -# ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" - #================================================= # END OF SCRIPT #================================================= From 599e7af7746810577695c683f9b68e9ddd966f17 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 13:05:20 +0200 Subject: [PATCH 129/207] back to previous version --- scripts/install | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/scripts/install b/scripts/install index f24618b..70b9641 100644 --- a/scripts/install +++ b/scripts/install @@ -87,14 +87,6 @@ ynh_setup_source --dest_dir="$final_path" chown $app:$app $final_path -R chmod 755 $final_path -R -#================================================= -# Change options in file config.dist.php -# and copy in local.dist.php -#================================================= - -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.dist.php" -# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" -# ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" #================================================= # NGINX CONFIGURATION @@ -134,6 +126,16 @@ ynh_script_progression --message="Reloading nginx web server..." --time --weight systemctl reload nginx +#================================================= +# Change options in file config.dist.php +# and copy in local.dist.php +#================================================= + +#echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php +cp -a $final_path/config.dist.php $final_path/config.local.php +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" +# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" +# ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" #================================================= # END OF SCRIPT #================================================= From 4e2b45921b9a36bb46a6bc6b01a0d6aa8aabfeab Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 14:11:27 +0200 Subject: [PATCH 130/207] try to keep secret key script on install --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 703b879..8b14923 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -208,5 +208,5 @@ echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php #================================================= # END OF SCRIPT #================================================= - +ynh_local_curl "page_uri" ynh_script_progression --message="Upgrade of $app completed" --time --last From 2a82b01c09d69c5fee51c51bc74338a56942483b Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 14:14:59 +0200 Subject: [PATCH 131/207] try to keep secret key script on install --- scripts/install | 7 ++++--- scripts/upgrade | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index 70b9641..786214d 100644 --- a/scripts/install +++ b/scripts/install @@ -131,11 +131,12 @@ systemctl reload nginx # and copy in local.dist.php #================================================= -#echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php -cp -a $final_path/config.dist.php $final_path/config.local.php -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" +ynh_local_curl "page_uri" +echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php +# ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" # ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 8b14923..6c534ee 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -203,10 +203,9 @@ echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php #cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" - # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" + #================================================= # END OF SCRIPT #================================================= -ynh_local_curl "page_uri" ynh_script_progression --message="Upgrade of $app completed" --time --last From faa5d045b2fe2af1b4ad9e751c5f8c9d87b37b99 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 14:54:14 +0200 Subject: [PATCH 132/207] try create secret key script on install --- scripts/install | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 786214d..eb6fc13 100644 --- a/scripts/install +++ b/scripts/install @@ -130,12 +130,14 @@ systemctl reload nginx # Change options in file config.dist.php # and copy in local.dist.php #================================================= +key=$(ynh_string_random --length=8) +cp -a $final_path/config.dist.php $final_path/config.local.php -ynh_local_curl "page_uri" -echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php -# ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" # ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" +# echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php #================================================= # END OF SCRIPT From e92c77df9bf7700a3c6ae1b660732d6de82003f7 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 14:58:29 +0200 Subject: [PATCH 133/207] create secret key script on install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index eb6fc13..2020f7f 100644 --- a/scripts/install +++ b/scripts/install @@ -130,7 +130,7 @@ systemctl reload nginx # Change options in file config.dist.php # and copy in local.dist.php #================================================= -key=$(ynh_string_random --length=8) +key=$(ynh_string_random --length=64) cp -a $final_path/config.dist.php $final_path/config.local.php ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" From d689169e145484882a768e313985564484216733 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 15:06:34 +0200 Subject: [PATCH 134/207] put same lenght for secret key then the example in config.dist.php script for install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 2020f7f..b6b6388 100644 --- a/scripts/install +++ b/scripts/install @@ -130,7 +130,7 @@ systemctl reload nginx # Change options in file config.dist.php # and copy in local.dist.php #================================================= -key=$(ynh_string_random --length=64) +key=$(ynh_string_random --length=50) cp -a $final_path/config.dist.php $final_path/config.local.php ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" From 7da9eb853b5dd769084f63b20e7f5d4eda5b3b31 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 16:00:23 +0200 Subject: [PATCH 135/207] try to debug slash for root directory in install and upgrade --- scripts/change_url | 45 ++++++++++++++++++++++++++++++++------------- scripts/install | 9 +++++++-- scripts/upgrade | 6 +++++- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 067a756..7685e2a 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -51,34 +51,46 @@ fi #================================================= # MODIFY URL IN NGINX CONF #================================================= - +ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf final_path=/var/www/$app # Change the path in the nginx config file if [ $change_path -eq 1 ] then + # # Make a backup of the original nginx config file if modified + # ynh_backup_if_checksum_is_different "$nginx_conf_path" + # # Replace locations starting with old_path + # # Look for every location possible patterns (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location) + # ynh_replace_string "location\( \(=\|~\|~\*\|\^~\)\)\? $old_path" "location\1 $new_path" "$nginx_conf_path" + # # Replace path in "return" directives + # ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path" + # # Calculate and store the nginx config file checksum + # ynh_store_file_checksum "$nginx_conf_path" + # # ynh_replace_string # Make a backup of the original nginx config file if modified - ynh_backup_if_checksum_is_different "$nginx_conf_path" - # Replace locations starting with old_path - # Look for every location possible patterns (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location) - ynh_replace_string "location\( \(=\|~\|~\*\|\^~\)\)\? $old_path" "location\1 $new_path" "$nginx_conf_path" - # Replace path in "return" directives - ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path" - # Calculate and store the nginx config file checksum - ynh_store_file_checksum "$nginx_conf_path" - # ynh_replace_string + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" + # Set global variables for nginx helper + domain="$old_domain" + path_url="$new_path" + # Create a dedicated nginx config + ynh_add_nginx_config +elif [ "$new_path" == "/" ] +then + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" +else ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi +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 --file="$nginx_conf_path" mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location - ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= @@ -86,5 +98,12 @@ fi #================================================= # RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --time --last \ No newline at end of file diff --git a/scripts/install b/scripts/install index b6b6388..3d48aba 100644 --- a/scripts/install +++ b/scripts/install @@ -132,9 +132,14 @@ systemctl reload nginx #================================================= key=$(ynh_string_random --length=50) cp -a $final_path/config.dist.php $final_path/config.local.php - -ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" +if [ "$path_url" == "/" ] +then + ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" +else + ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" +fi + # ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" # ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" # echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php diff --git a/scripts/upgrade b/scripts/upgrade index 6c534ee..30bbc66 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -185,6 +185,11 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= # backup bdd, squelettes directory and config.local.php #================================================= +if [ "$new_path" == "/" ] + echo "const WWW_URI = '$path_url';" >> $final_path/config.local.php +else + echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php +fi backup_bdd=/tmp/association.sqlite backup_squelettes=/tmp/squelettes @@ -199,7 +204,6 @@ then cp -a $backup_bdd $final_path/association.sqlite fi -echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php #cp -a $final_path/config.dist.php $final_path/config.local.php # ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" From 462780defa828f6d098fa3e6401479602f1127d2 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 16:05:23 +0200 Subject: [PATCH 136/207] try to debug slash for root directory in cahnge_url --- scripts/change_url | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index 7685e2a..ba0024e 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -81,7 +81,6 @@ then else ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi -fi # Change the domain for nginx if [ $change_domain -eq 1 ] From a7541b6d0d5ebad604b811ceda4801a91b8dd44d Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 16:23:39 +0200 Subject: [PATCH 137/207] try to debug slash for root directory in change_url --- scripts/change_url | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index ba0024e..00e04b0 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -75,12 +75,6 @@ then path_url="$new_path" # Create a dedicated nginx config ynh_add_nginx_config -elif [ "$new_path" == "/" ] -then - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" -else - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" -fi # Change the domain for nginx if [ $change_domain -eq 1 ] @@ -101,6 +95,15 @@ ynh_script_progression --message="Reloading nginx web server..." --time --weight ynh_systemd_action --service_name=nginx --action=reload +#================================================= +# last configuration +#================================================= +if [ $change_path -eq 1 && "$new_path" == "/"] +then + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" +else + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" +fi #================================================= # END OF SCRIPT #================================================= From ac3153d399ad8bfe4882f64c2026147a21b6437f Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 16:34:30 +0200 Subject: [PATCH 138/207] try to debug slash for root directory in change_url --- scripts/change_url | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 00e04b0..4a039ee 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -73,8 +73,15 @@ then # Set global variables for nginx helper domain="$old_domain" path_url="$new_path" +if [ "$new_path" == "/"] +then + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" +else + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" +fi # Create a dedicated nginx config ynh_add_nginx_config +fi # Change the domain for nginx if [ $change_domain -eq 1 ] @@ -98,12 +105,6 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= # last configuration #================================================= -if [ $change_path -eq 1 && "$new_path" == "/"] -then - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" -else - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" -fi #================================================= # END OF SCRIPT #================================================= From 4b25e8fc5e64793b7dcd6ca79953f2d62bbc594b Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 17:17:00 +0200 Subject: [PATCH 139/207] try to put clean upgrade script --- scripts/change_url | 10 ---- scripts/install | 6 -- scripts/upgrade | 134 ++++++++++++++++++++++----------------------- 3 files changed, 64 insertions(+), 86 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 4a039ee..05d8e7d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -58,16 +58,6 @@ final_path=/var/www/$app # Change the path in the nginx config file if [ $change_path -eq 1 ] then - # # Make a backup of the original nginx config file if modified - # ynh_backup_if_checksum_is_different "$nginx_conf_path" - # # Replace locations starting with old_path - # # Look for every location possible patterns (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location) - # ynh_replace_string "location\( \(=\|~\|~\*\|\^~\)\)\? $old_path" "location\1 $new_path" "$nginx_conf_path" - # # Replace path in "return" directives - # ynh_replace_string "return \([[:digit:]]\{3\}\) $old_path" "return \1 $new_path" "$nginx_conf_path" - # # Calculate and store the nginx config file checksum - # ynh_store_file_checksum "$nginx_conf_path" - # # ynh_replace_string # Make a backup of the original nginx config file if modified ynh_backup_if_checksum_is_different --file="$nginx_conf_path" # Set global variables for nginx helper diff --git a/scripts/install b/scripts/install index 3d48aba..2ba6b3d 100644 --- a/scripts/install +++ b/scripts/install @@ -79,7 +79,6 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" - #================================================= # Files owned by user app #================================================= @@ -87,7 +86,6 @@ ynh_setup_source --dest_dir="$final_path" chown $app:$app $final_path -R chmod 755 $final_path -R - #================================================= # NGINX CONFIGURATION #================================================= @@ -140,10 +138,6 @@ else ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" fi -# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" -# ynh_replace_string --match_string="const PREFER_HTTPS = false;" --replace_string="const PREFER_HTTPS = true;" --target_file="$final_path/config.local.php" -# echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 30bbc66..5569589 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -32,7 +32,6 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) || ynh_die "This p ### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. upgrade_type=$(ynh_check_app_version_changed) - #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -50,7 +49,7 @@ fi #================================================= # Backup squlite, config.local.php and squelettes directory #================================================= -ynh_script_progression --message="Backing up the bdd and squelettes before upgrading (may take a while)..." --time --weight=1 +ynh_script_progression --message="Backing up the data before upgrading (may take a while)..." --time --weight=1 bdd=$final_path/association.sqlite squelettes=$final_path/www/squelettes @@ -83,32 +82,13 @@ ynh_abort_if_errors # # CHECK THE PATH # #================================================= -# # Normalize the URL path syntax -# # N.B. : this is for app installations before YunoHost 2.7 -# # where this value might be something like /foo/ or foo/ -# # instead of /foo .... -# # If nobody installed your app before 2.7, then you may -# # safely remove this line -# path_url=$(ynh_normalize_url_path --path_url=$path_url) - - -# final_path=/var/www/$app -# test ! -e "$final_path" || ynh_die "This path already contains a folder" - -# # Normalize the url path syntax -# path_url=$(ynh_normalize_url_path $path_url) - -# # Check web path availability -# ynh_webpath_available $domain $path_url -# # Register (book) web path -# ynh_webpath_register $app $domain $path_url - -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 - -ynh_install_app_dependencies $pkg_dependencies +# Normalize the URL path syntax +# N.B. : this is for app installations before YunoHost 2.7 +# where this value might be something like /foo/ or foo/ +# instead of /foo .... +# If nobody installed your app before 2.7, then you may +# safely remove this line +path_url=$(ynh_normalize_url_path --path_url=$path_url) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -121,6 +101,21 @@ then ynh_setup_source --dest_dir="$final_path" fi +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --time --weight=1 + +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app + #================================================= # NGINX CONFIGURATION @@ -131,12 +126,45 @@ ynh_script_progression --message="Upgrading nginx web server configuration..." - ynh_add_nginx_config #================================================= -# CREATE DEDICATED USER +# PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 +ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1 -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app +# Create a dedicated php-fpm config +ynh_add_fpm_config + +#================================================= +# Change options in file config.dist.php +# and copy in local.dist.php +#================================================= +ynh_script_progression --message="final configuration needed..." --time --weight=1 + +key=$(ynh_string_random --length=50) +cp -a $final_path/config.dist.php $final_path/config.local.php +ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" +if [ "$path_url" == "/" ] +then + ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" +else + ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" +fi +#================================================= +# backup bdd, squelettes directory and config.local.php +#================================================= +ynh_script_progression --message="restore data..." --time --weight=1 + +backup_bdd=/tmp/association.sqlite +backup_squelettes=/tmp/squelettes + +if [ -d "$backup_squelettes" ] +then + cp -ar $backup_squelettes $final_path/www/squelettes +fi + +if [ -e "$backup_bdd" ] +then + cp -a $backup_bdd $final_path/association.sqlite +fi # #================================================= # # STORE THE CONFIG FILE CHECKSUM @@ -144,25 +172,18 @@ ynh_system_user_create --username=$app # ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. # ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. -# ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE" +ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE" # # Recalculate and store the checksum of the file for the next upgrade. -# ynh_store_file_checksum --file="$final_path/CONFIG_FILE" +ynh_store_file_checksum --file="$final_path/CONFIG_FILE" #================================================= # Files owned by user app #================================================= +# Set permissions on app files chown $app:$app $final_path -R chmod 755 $final_path -R -#================================================= -# PHP-FPM CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading php-fpm configuration..." --time --weight=1 - -# Create a dedicated php-fpm config -ynh_add_fpm_config - #================================================= # SETUP SSOWAT #================================================= @@ -182,34 +203,7 @@ ynh_script_progression --message="Reloading nginx web server..." --time --weight ynh_systemd_action --service_name=nginx --action=reload -#================================================= -# backup bdd, squelettes directory and config.local.php -#================================================= -if [ "$new_path" == "/" ] - echo "const WWW_URI = '$path_url';" >> $final_path/config.local.php -else - echo "const WWW_URI = '$path_url/';" >> $final_path/config.local.php -fi - -backup_bdd=/tmp/association.sqlite -backup_squelettes=/tmp/squelettes - -if [ -d "$backup_squelettes" ] -then - cp -ar $backup_squelettes $final_path/www/squelettes -fi - -if [ -e "$backup_bdd" ] -then - cp -a $backup_bdd $final_path/association.sqlite -fi - - -#cp -a $final_path/config.dist.php $final_path/config.local.php -# ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" -# ynh_replace_string --match_string="const ROOT = __DIR__;" --replace_string="const ROOT = /var/www/garradin/;" --target_file="$final_path/config.local.php" - #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --time --last +ynh_script_progression --message="Upgrade of $app completed" --time --last \ No newline at end of file From c23f8e2f0d81bb7ac2d5ac99d28963a6eaaa3eca Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 17:27:51 +0200 Subject: [PATCH 140/207] try to debug change_url script --- scripts/change_url | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index 05d8e7d..f9d0673 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -63,7 +63,7 @@ then # Set global variables for nginx helper domain="$old_domain" path_url="$new_path" -if [ "$new_path" == "/"] +if [ "$new_path" == "/" ] then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" else From c7a722ac430795dd9d37db9a1d2338535f1b54ac Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 17:37:14 +0200 Subject: [PATCH 141/207] try to debug change_url script --- scripts/change_url | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index f9d0673..a53c0ac 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -63,14 +63,14 @@ then # Set global variables for nginx helper domain="$old_domain" path_url="$new_path" + # Create a dedicated nginx config + ynh_add_nginx_config if [ "$new_path" == "/" ] then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" else ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi - # Create a dedicated nginx config - ynh_add_nginx_config fi # Change the domain for nginx From 068ebaa75d17ff0e5578d06a2f8e17557c9413b7 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 17:48:08 +0200 Subject: [PATCH 142/207] try to debug change_url script --- scripts/change_url | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index a53c0ac..027cc57 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -68,7 +68,7 @@ then if [ "$new_path" == "/" ] then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" -else +elif ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi fi From 07fbcd5b472c5921b2d3b04f55441af7868bd9ae Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 17:50:31 +0200 Subject: [PATCH 143/207] try to debug change_url script --- scripts/change_url | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index 027cc57..aeb4087 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -71,7 +71,6 @@ then elif ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi -fi # Change the domain for nginx if [ $change_domain -eq 1 ] From c5ad3437a982e026847d39f5128039895c1ac0f3 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 17:59:44 +0200 Subject: [PATCH 144/207] try to debug change_url script --- scripts/change_url | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index aeb4087..2ff41a7 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -65,10 +65,14 @@ then path_url="$new_path" # Create a dedicated nginx config ynh_add_nginx_config -if [ "$new_path" == "/" ] +fi + +if [ $change_path -eq 1 ] && [ "$new_path" == "/" ] then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" -elif +fi + +if [ $change_path -eq 1 ] && [ "$new_path" != "/" ] ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi From a361f4c8463903f6f28493295cc60ffd3b19574e Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 18:01:44 +0200 Subject: [PATCH 145/207] try to debug change_url script --- scripts/change_url | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/change_url b/scripts/change_url index 2ff41a7..b3c5e9c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -73,6 +73,7 @@ then fi if [ $change_path -eq 1 ] && [ "$new_path" != "/" ] +then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi From fce9193244d714ebe331e5cddd3237bb9661aeca Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 18:09:00 +0200 Subject: [PATCH 146/207] try to debug change_url script --- scripts/change_url | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index b3c5e9c..0d89903 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -70,10 +70,7 @@ fi if [ $change_path -eq 1 ] && [ "$new_path" == "/" ] then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" -fi - -if [ $change_path -eq 1 ] && [ "$new_path" != "/" ] -then +else ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi From f8a64dddd5412a311d0a191a6532518a97f229c5 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 18:16:46 +0200 Subject: [PATCH 147/207] try to debug change_url script --- scripts/change_url | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/change_url b/scripts/change_url index 0d89903..3d3d129 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -67,6 +67,7 @@ then ynh_add_nginx_config fi +# change the config.local.conf if [ $change_path -eq 1 ] && [ "$new_path" == "/" ] then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" From 68ff57c334c1694cd8f6d694b8d66868f4413e5e Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 18:21:49 +0200 Subject: [PATCH 148/207] try to debug change_url script --- scripts/change_url | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 3d3d129..bdbf80c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -68,11 +68,11 @@ then fi # change the config.local.conf -if [ $change_path -eq 1 ] && [ "$new_path" == "/" ] +if [ $change_path -eq 1 ] && [ "$path_url" == "/" ] then - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" else - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" fi # Change the domain for nginx From c7b5add13c0a5187ab10cf5b382851944067b31e Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 18:34:46 +0200 Subject: [PATCH 149/207] try to debug change_url script --- scripts/change_url | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index bdbf80c..fb3ac16 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -68,11 +68,11 @@ then fi # change the config.local.conf -if [ $change_path -eq 1 ] && [ "$path_url" == "/" ] +if [ $change_path -eq 1 ] && [ "$new_path" == "/" ] then - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" + ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" else - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" + ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi # Change the domain for nginx From c09b0f4633dd84a5272578dc08429e1cb4f241b7 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 18:39:39 +0200 Subject: [PATCH 150/207] try to debug change_url script --- scripts/change_url | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index fb3ac16..dfbe5e8 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -68,11 +68,11 @@ then fi # change the config.local.conf -if [ $change_path -eq 1 ] && [ "$new_path" == "/" ] +if [ $change_path -eq 1 ] && [ "$old_path" == "/" ] then - ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" -else ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" +else + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" fi # Change the domain for nginx From 71c6b63a9be2608b6f35e59c0ee35eda4be51512 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 18:47:00 +0200 Subject: [PATCH 151/207] change manifest --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 790f8be..46f61bf 100644 --- a/manifest.json +++ b/manifest.json @@ -9,7 +9,7 @@ "en": "Software to manage association", "fr": "Logiciel libre de gestion d'association" }, - "version": "0.9.5~ynh1", + "version": "0.9.5~ynh3", "url": "http://garradin.eu/a-propos/", "license": "GPL-3.0-or-later", "maintainer": { From bc06c8349455007f867feb8f18baf1d1c172e89e Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 18:59:14 +0200 Subject: [PATCH 152/207] change url debug --- scripts/change_url | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index dfbe5e8..3d3d129 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -68,11 +68,11 @@ then fi # change the config.local.conf -if [ $change_path -eq 1 ] && [ "$old_path" == "/" ] +if [ $change_path -eq 1 ] && [ "$new_path" == "/" ] then - ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" -else ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" +else + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi # Change the domain for nginx From 8a77cfbd88032587fa74c656c4f3eab1d1a4536a Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 9 Apr 2020 20:01:27 +0200 Subject: [PATCH 153/207] change Readme --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e074cb9..96d92fe 100644 --- a/README.md +++ b/README.md @@ -11,17 +11,18 @@ site de garradin : http://garradin.eu [![Integration level](https://dash.yunohost.org/integration/garradin.svg)](https://ci-apps.yunohost.org/jenkins/job/garradin%20%28Community%29/lastBuild/consoleFull)
[![Install Garradin with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=garradin) -## Installation : +## Installation : - CLI `sudo yunohost app install https://github.com/Yunohost-Apps/garradin_ynh` - À travers l'interface d'administration -### TODO list : -- Backup de la base de donnée SQlite (AIDE REQUISE) ? +### TODO list : +- Backup de la base de donnée SQlite (AIDE REQUISE)? [Résolu] +- Permissions de certains fichiers sensibles ? -#### Problèmes / Avertissements : -- le système SSO n'est pas implémenté, ni l'installation directe. L'utilisateur admin devra créer son compte avec le formulaire de création de compte qu'il trouvera à la fin de l'installation. Plusieurs raisons m'ont poussé à ne pas implémenter le SSO : +#### Problèmes / Avertissements : +- le système SSO n'est pas implémenté, ni l'installation directe. L'utilisateur admin devra créer son compte avec le formulaire de création de compte qu'il trouvera à la fin de l'installation. Plusieurs raisons m'ont poussé à ne pas implémenter le SSO : - Le SSO n'est pas implémenté dans l'app originale. - Avoir 150+ utilisateurs dans Yunohost n'est pas très pratique, ni très sécurisé, et revient en fin de compte à centraliser les services. - Ce formulaire laisse le choix à l'administrateur de choisir les modalités de création de son compte. On pourrait peut-être me reprocher de ne pas avoir intégré ce formulaire dans le formulaire d'installation que l'utilisateur remplit avant l'installation de ce paquet. Il est vrai que j'aurais pu mettre les ~dix champs qui compose le formulaire de Garradin, mais je ne trouvais pas cela très pratique. From 09a7abac5ab8ad821069a8f68d626ca06317846b Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 10 Apr 2020 01:17:19 +0200 Subject: [PATCH 154/207] change url debug --- scripts/change_url | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index 3d3d129..e870162 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -72,7 +72,7 @@ if [ $change_path -eq 1 ] && [ "$new_path" == "/" ] then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" else - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" + ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi # Change the domain for nginx From 6ad56466d10012455bdb91984f2a35ef39e34837 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 10 Apr 2020 01:29:45 +0200 Subject: [PATCH 155/207] change url debug --- scripts/change_url | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index e870162..3d3d129 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -72,7 +72,7 @@ if [ $change_path -eq 1 ] && [ "$new_path" == "/" ] then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" else - ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi # Change the domain for nginx From d23c65acd11c3a7b531c44c95da2bcb11ed3887b Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 10 Apr 2020 10:50:36 +0200 Subject: [PATCH 156/207] add a line in config.local.php for domain in change_url script --- scripts/change_url | 7 ++++--- scripts/install | 1 + scripts/upgrade | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 3d3d129..1f0400a 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -59,9 +59,8 @@ final_path=/var/www/$app 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 --file="$nginx_conf_path" # Set global variables for nginx helper - domain="$old_domain" path_url="$new_path" # Create a dedicated nginx config ynh_add_nginx_config @@ -78,11 +77,13 @@ fi # Change the domain for nginx if [ $change_domain -eq 1 ] then + domain="$new_domain" # Delete file checksum for the old conf file location ynh_delete_file_checksum --file="$nginx_conf_path" mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location - ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + #ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + ynh_replace_string --match_string="const WWW_URL = '$old_domain' . WWW_URI" --replace_string="const WWW_URI = '$new_domain . WWW_URI';" --target_file="$final_path/config.local.php" fi #================================================= diff --git a/scripts/install b/scripts/install index 2ba6b3d..8c73e04 100644 --- a/scripts/install +++ b/scripts/install @@ -131,6 +131,7 @@ systemctl reload nginx key=$(ynh_string_random --length=50) cp -a $final_path/config.dist.php $final_path/config.local.php ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URL = 'http://garradin.chezmoi.tld' . WWW_URI" --replace_string="const WWW_URI = '$domain . WWW_URI';" --target_file="$final_path/config.local.php" if [ "$path_url" == "/" ] then ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" diff --git a/scripts/upgrade b/scripts/upgrade index 5569589..98f6ece 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -142,6 +142,7 @@ ynh_script_progression --message="final configuration needed..." --time --weight key=$(ynh_string_random --length=50) cp -a $final_path/config.dist.php $final_path/config.local.php ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URL = 'http://garradin.chezmoi.tld' . WWW_URI" --replace_string="const WWW_URI = '$domain . WWW_URI';" --target_file="$final_path/config.local.php" if [ "$path_url" == "/" ] then ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" From 193b5fee013eb1d032c1bd2e17d66ea65eeada06 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 10 Apr 2020 11:08:28 +0200 Subject: [PATCH 157/207] add a line in config.local.php for domain in change_url script --- scripts/change_url | 2 +- scripts/install | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 1f0400a..bdb335a 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -83,7 +83,7 @@ then mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location #ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - ynh_replace_string --match_string="const WWW_URL = '$old_domain' . WWW_URI" --replace_string="const WWW_URI = '$new_domain . WWW_URI';" --target_file="$final_path/config.local.php" + ynh_replace_string --match_string="const WWW_URL = '$old_domain' . WWW_URI;" --replace_string="const WWW_URI = '$new_domain . WWW_URI;" --target_file="$final_path/config.local.php" fi #================================================= diff --git a/scripts/install b/scripts/install index 8c73e04..9b3f6f1 100644 --- a/scripts/install +++ b/scripts/install @@ -131,7 +131,7 @@ systemctl reload nginx key=$(ynh_string_random --length=50) cp -a $final_path/config.dist.php $final_path/config.local.php ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URL = 'http://garradin.chezmoi.tld' . WWW_URI" --replace_string="const WWW_URI = '$domain . WWW_URI';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URL = 'http://garradin.chezmoi.tld' . WWW_URI;" --replace_string="const WWW_URI = '$domain . WWW_URI;" --target_file="$final_path/config.local.php" if [ "$path_url" == "/" ] then ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" diff --git a/scripts/upgrade b/scripts/upgrade index 98f6ece..a0ba937 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -142,7 +142,7 @@ ynh_script_progression --message="final configuration needed..." --time --weight key=$(ynh_string_random --length=50) cp -a $final_path/config.dist.php $final_path/config.local.php ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URL = 'http://garradin.chezmoi.tld' . WWW_URI" --replace_string="const WWW_URI = '$domain . WWW_URI';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URL = 'http://garradin.chezmoi.tld' . WWW_URI;" --replace_string="const WWW_URI = '$domain' . WWW_URI;" --target_file="$final_path/config.local.php" if [ "$path_url" == "/" ] then ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" From ce9565b6f6cba7f17484ac36d6ac46fa40a8f670 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 10 Apr 2020 11:14:02 +0200 Subject: [PATCH 158/207] add a line in config.local.php for domain in change_url script --- scripts/change_url | 2 +- scripts/install | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index bdb335a..c771a7c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -83,7 +83,7 @@ then mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location #ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - ynh_replace_string --match_string="const WWW_URL = '$old_domain' . WWW_URI;" --replace_string="const WWW_URI = '$new_domain . WWW_URI;" --target_file="$final_path/config.local.php" + ynh_replace_string --match_string="const WWW_URL = '$old_domain' . WWW_URI;" --replace_string="const WWW_URI = '$new_domain' . WWW_URI;" --target_file="$final_path/config.local.php" fi #================================================= diff --git a/scripts/install b/scripts/install index 9b3f6f1..6b83346 100644 --- a/scripts/install +++ b/scripts/install @@ -131,7 +131,7 @@ systemctl reload nginx key=$(ynh_string_random --length=50) cp -a $final_path/config.dist.php $final_path/config.local.php ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URL = 'http://garradin.chezmoi.tld' . WWW_URI;" --replace_string="const WWW_URI = '$domain . WWW_URI;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URL = 'http://garradin.chezmoi.tld' . WWW_URI;" --replace_string="const WWW_URI = '$domain' . WWW_URI;" --target_file="$final_path/config.local.php" if [ "$path_url" == "/" ] then ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" From 4449ee7ecb12dae2cf74bd84f69142f6d70d6015 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 10 Apr 2020 11:27:16 +0200 Subject: [PATCH 159/207] add a lines for doamin in config.local.php in change_url install and upgrade script --- scripts/change_url | 2 +- scripts/install | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index c771a7c..e1f1a17 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -83,7 +83,7 @@ then mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location #ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - ynh_replace_string --match_string="const WWW_URL = '$old_domain' . WWW_URI;" --replace_string="const WWW_URI = '$new_domain' . WWW_URI;" --target_file="$final_path/config.local.php" + ynh_replace_string --match_string="const WWW_URL = '$old_domain' . WWW_URI;" --replace_string="const WWW_URI = 'https:/$new_domain' . WWW_URI;" --target_file="$final_path/config.local.php" fi #================================================= diff --git a/scripts/install b/scripts/install index 6b83346..59563bd 100644 --- a/scripts/install +++ b/scripts/install @@ -131,7 +131,7 @@ systemctl reload nginx key=$(ynh_string_random --length=50) cp -a $final_path/config.dist.php $final_path/config.local.php ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URL = 'http://garradin.chezmoi.tld' . WWW_URI;" --replace_string="const WWW_URI = '$domain' . WWW_URI;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URL = 'http://garradin.chezmoi.tld' . WWW_URI;" --replace_string="const WWW_URI = 'https:/$domain' . WWW_URI;" --target_file="$final_path/config.local.php" if [ "$path_url" == "/" ] then ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" diff --git a/scripts/upgrade b/scripts/upgrade index a0ba937..5d4a466 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -142,7 +142,7 @@ ynh_script_progression --message="final configuration needed..." --time --weight key=$(ynh_string_random --length=50) cp -a $final_path/config.dist.php $final_path/config.local.php ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URL = 'http://garradin.chezmoi.tld' . WWW_URI;" --replace_string="const WWW_URI = '$domain' . WWW_URI;" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const WWW_URL = 'http://garradin.chezmoi.tld' . WWW_URI;" --replace_string="const WWW_URI = 'https:/$domain' . WWW_URI;" --target_file="$final_path/config.local.php" if [ "$path_url" == "/" ] then ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" From d327d07ca3d64ecb356e229359a41d70c9010f3e Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 10 Apr 2020 12:22:43 +0200 Subject: [PATCH 160/207] comme back to previous version --- scripts/change_url | 1 - scripts/install | 1 - scripts/upgrade | 1 - 3 files changed, 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index e1f1a17..1e864fa 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -83,7 +83,6 @@ then mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location #ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - ynh_replace_string --match_string="const WWW_URL = '$old_domain' . WWW_URI;" --replace_string="const WWW_URI = 'https:/$new_domain' . WWW_URI;" --target_file="$final_path/config.local.php" fi #================================================= diff --git a/scripts/install b/scripts/install index 59563bd..2ba6b3d 100644 --- a/scripts/install +++ b/scripts/install @@ -131,7 +131,6 @@ systemctl reload nginx key=$(ynh_string_random --length=50) cp -a $final_path/config.dist.php $final_path/config.local.php ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URL = 'http://garradin.chezmoi.tld' . WWW_URI;" --replace_string="const WWW_URI = 'https:/$domain' . WWW_URI;" --target_file="$final_path/config.local.php" if [ "$path_url" == "/" ] then ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" diff --git a/scripts/upgrade b/scripts/upgrade index 5d4a466..5569589 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -142,7 +142,6 @@ ynh_script_progression --message="final configuration needed..." --time --weight key=$(ynh_string_random --length=50) cp -a $final_path/config.dist.php $final_path/config.local.php ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" -ynh_replace_string --match_string="//const WWW_URL = 'http://garradin.chezmoi.tld' . WWW_URI;" --replace_string="const WWW_URI = 'https:/$domain' . WWW_URI;" --target_file="$final_path/config.local.php" if [ "$path_url" == "/" ] then ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" From 6d98d6dcb3165e9cc623e24f5f0ad090bd164f00 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 10 Apr 2020 14:12:57 +0200 Subject: [PATCH 161/207] sripts modified, try to resolve change url --- scripts/change_url | 37 +++++++++++++++++++++++++++++++------ scripts/upgrade | 10 ++++++++-- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 1e864fa..a262f9b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -22,13 +22,38 @@ new_path=$YNH_APP_NEW_PATH app=$YNH_APP_INSTANCE_NAME #================================================= -# CHECK THE SYNTAX OF THE PATHS +# LOAD SETTINGS #================================================= +ynh_script_progression --message="Loading installation settings..." --time --weight=1 -test -n "$old_path" || old_path="/" -test -n "$new_path" || new_path="/" -new_path=$(ynh_normalize_url_path $new_path) -old_path=$(ynh_normalize_url_path $old_path) +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get --app=$app --key=final_path) + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --time --weight=1 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +# #================================================= +# # CHECK THE SYNTAX OF THE PATHS +# #================================================= + +# test -n "$old_path" || old_path="/" +# test -n "$new_path" || new_path="/" +# new_path=$(ynh_normalize_url_path $new_path) +# old_path=$(ynh_normalize_url_path $old_path) #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED @@ -82,7 +107,7 @@ then ynh_delete_file_checksum --file="$nginx_conf_path" mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location - #ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 5569589..3ccb84b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -46,6 +46,12 @@ elif [ "$is_public" = "No" ]; then is_public=0 fi +# If final_path doesn't exist, create it +if [ -z "$final_path" ]; then + final_path=/var/www/$app + ynh_app_setting_set --app=$app --key=final_path --value=$final_path +fi + #================================================= # Backup squlite, config.local.php and squelettes directory #================================================= @@ -148,9 +154,9 @@ then else ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" fi -#================================================= +#======================================================= # backup bdd, squelettes directory and config.local.php -#================================================= +#======================================================= ynh_script_progression --message="restore data..." --time --weight=1 backup_bdd=/tmp/association.sqlite From ebf27696812e74fd6dcee50644f7d87e174a3674 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 10 Apr 2020 14:19:41 +0200 Subject: [PATCH 162/207] sripts modified, try to resolve change url --- scripts/change_url | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index a262f9b..87a60f7 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -102,8 +102,7 @@ fi # Change the domain for nginx if [ $change_domain -eq 1 ] then - domain="$new_domain" - # 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" mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location From 5121efa39861613d5c23badfefb436fa6b0b70bc Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 10 Apr 2020 14:44:35 +0200 Subject: [PATCH 163/207] sripts modified, try to resolve change url --- scripts/change_url | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 87a60f7..683bfa0 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -29,23 +29,6 @@ ynh_script_progression --message="Loading installation settings..." --time --wei # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --time --weight=1 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. - ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - # #================================================= # # CHECK THE SYNTAX OF THE PATHS # #================================================= @@ -86,6 +69,7 @@ then # Make a backup of the original nginx config file if modified # ynh_backup_if_checksum_is_different --file="$nginx_conf_path" # Set global variables for nginx helper + domain="$old_domain" path_url="$new_path" # Create a dedicated nginx config ynh_add_nginx_config @@ -102,11 +86,11 @@ fi # Change the domain for nginx if [ $change_domain -eq 1 ] 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" mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location - ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + #ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= From d898ed56f92ec703511d9198cfc9409ed4a477c6 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 10 Apr 2020 14:51:33 +0200 Subject: [PATCH 164/207] sripts modified, try to resolve change url --- scripts/change_url | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index 683bfa0..1771172 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -67,7 +67,7 @@ final_path=/var/www/$app 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 --file="$nginx_conf_path" # Set global variables for nginx helper domain="$old_domain" path_url="$new_path" From 5117e798741bec9cb0d90685d5bdd323692c6003 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 10 Apr 2020 14:58:21 +0200 Subject: [PATCH 165/207] sripts modified, try to resolve change url --- scripts/change_url | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index 1771172..01fbe36 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -79,8 +79,10 @@ fi if [ $change_path -eq 1 ] && [ "$new_path" == "/" ] then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" +elif [ "$old_path" == "/"] + ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" else - ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" + ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi # Change the domain for nginx From ffea248595e3592fd034d3885f9bf451eb8e4911 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 10 Apr 2020 15:09:06 +0200 Subject: [PATCH 166/207] sripts modified, try to resolve change url --- scripts/change_url | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index 01fbe36..876aab1 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -81,7 +81,7 @@ then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" elif [ "$old_path" == "/"] ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" -else +else [ "$new_path" != "/" -o "$old_path" != "/"] ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi From efd7b5e9c1c35ab83b93adaeda01fe567a8f055f Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 10 Apr 2020 15:11:59 +0200 Subject: [PATCH 167/207] sripts modified, try to resolve change url --- scripts/change_url | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 876aab1..ab36669 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -79,9 +79,9 @@ fi if [ $change_path -eq 1 ] && [ "$new_path" == "/" ] then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" -elif [ "$old_path" == "/"] +elif [ "$old_path" == "/" ] ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" -else [ "$new_path" != "/" -o "$old_path" != "/"] +else [ "$new_path" != "/" -o "$old_path" != "/" ] ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi From 1af05404d7db6d04b032c1e04ab4d874b52232f1 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 10 Apr 2020 15:26:29 +0200 Subject: [PATCH 168/207] sripts modified, try to resolve change url --- scripts/change_url | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index ab36669..efbd34e 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -81,7 +81,7 @@ then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" elif [ "$old_path" == "/" ] ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" -else [ "$new_path" != "/" -o "$old_path" != "/" ] +elif [ "$new_path" != "/" -o "$old_path" != "/" ] ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi From ce4849e82b8718f609debfb671e9d9f4bc1b3040 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 10 Apr 2020 15:32:15 +0200 Subject: [PATCH 169/207] sripts modified, try to resolve change url --- scripts/change_url | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index efbd34e..e7b454e 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -80,8 +80,9 @@ if [ $change_path -eq 1 ] && [ "$new_path" == "/" ] then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" elif [ "$old_path" == "/" ] +then ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" -elif [ "$new_path" != "/" -o "$old_path" != "/" ] +else ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi From da7dfd3172da8eb56af1fccee85f0a4bae732d8b Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 10 Apr 2020 15:43:57 +0200 Subject: [PATCH 170/207] sripts modified, try to resolve change url --- scripts/change_url | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index e7b454e..93fd82a 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -79,10 +79,10 @@ fi if [ $change_path -eq 1 ] && [ "$new_path" == "/" ] then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" -elif [ "$old_path" == "/" ] +elif [ $change_path -eq 1 ] && [ "$old_path" == "/" ] then ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" -else +else [ $change_path -eq 1 ] ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi From 7572a959cc70a45f51bb9b7c6f8da8dfe3e56b76 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 10 Apr 2020 17:07:35 +0200 Subject: [PATCH 171/207] remove file_checksum md5 not needed --- README.md | 1 - scripts/backup | 13 ------------- scripts/install | 16 ++++++++-------- scripts/upgrade | 10 ---------- 4 files changed, 8 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 96d92fe..d4c6a25 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,6 @@ site de garradin : http://garradin.eu - À travers l'interface d'administration ### TODO list : -- Backup de la base de donnée SQlite (AIDE REQUISE)? [Résolu] - Permissions de certains fichiers sensibles ? #### Problèmes / Avertissements : diff --git a/scripts/backup b/scripts/backup index 810a34e..27102aa 100644 --- a/scripts/backup +++ b/scripts/backup @@ -53,17 +53,4 @@ ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= # END OF SCRIPT #================================================= - ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last -#ynh_backup --src_path="/etc/php/7.0/fpm/conf.d/20-$app.ini" - -# # Backup directory location for the app from where the script is executed and -# # which will be compressed afterward -# backup_dir=$YNH_APP_BACKUP_DIR - -# # Backup sources & data -# ynh_backup "/var/www/$app" "sources" - -# # Copy Nginx conf -# sudo mkdir -p ./conf -# ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "conf/nginx.conf" \ No newline at end of file diff --git a/scripts/install b/scripts/install index 2ba6b3d..062eb91 100644 --- a/scripts/install +++ b/scripts/install @@ -79,12 +79,6 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path" -#================================================= -# Files owned by user app -#================================================= - -chown $app:$app $final_path -R -chmod 755 $final_path -R #================================================= # NGINX CONFIGURATION @@ -125,8 +119,7 @@ ynh_script_progression --message="Reloading nginx web server..." --time --weight systemctl reload nginx #================================================= -# Change options in file config.dist.php -# and copy in local.dist.php +# MODIFY A CONFIG FILE #================================================= key=$(ynh_string_random --length=50) cp -a $final_path/config.dist.php $final_path/config.local.php @@ -138,6 +131,13 @@ else ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" fi +#================================================= +# Files owned by user app +#================================================= + +chown $app:$app $final_path -R +chmod 755 $final_path -R + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 3ccb84b..1f53880 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -172,16 +172,6 @@ then cp -a $backup_bdd $final_path/association.sqlite fi -# #================================================= -# # STORE THE CONFIG FILE CHECKSUM -# #================================================= - -# ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. -# ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. -ynh_backup_if_checksum_is_different --file="$final_path/CONFIG_FILE" -# # Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="$final_path/CONFIG_FILE" - #================================================= # Files owned by user app #================================================= From 35b475e0689a970c3a08df55ab52a32de6c7b49f Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Fri, 10 Apr 2020 17:45:02 +0200 Subject: [PATCH 172/207] cleaning syntax --- scripts/change_url | 15 +++++---------- scripts/install | 8 +++++--- scripts/restore | 3 +-- scripts/upgrade | 8 +++----- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 93fd82a..7244972 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -43,14 +43,12 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= change_domain=0 -if [ "$old_domain" != "$new_domain" ] -then +if [ "$old_domain" != "$new_domain" ]; then change_domain=1 fi change_path=0 -if [ "$old_path" != "$new_path" ] -then +if [ "$old_path" != "$new_path" ]; then change_path=1 fi @@ -76,19 +74,16 @@ then fi # change the config.local.conf -if [ $change_path -eq 1 ] && [ "$new_path" == "/" ] -then +if [ $change_path -eq 1 ] && [ "$new_path" == "/" ]; then ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path';" --target_file="$final_path/config.local.php" -elif [ $change_path -eq 1 ] && [ "$old_path" == "/" ] -then +elif [ $change_path -eq 1 ] && [ "$old_path" == "/" ]; then ynh_replace_string --match_string="const WWW_URI = '$old_path';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" else [ $change_path -eq 1 ] ynh_replace_string --match_string="const WWW_URI = '$old_path/';" --replace_string="const WWW_URI = '$new_path/';" --target_file="$final_path/config.local.php" fi # Change the domain for nginx -if [ $change_domain -eq 1 ] -then +if [ $change_domain -eq 1 ]; then # Delete file checksum for the old conf file location ynh_delete_file_checksum --file="$nginx_conf_path" mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf diff --git a/scripts/install b/scripts/install index 062eb91..744f84c 100644 --- a/scripts/install +++ b/scripts/install @@ -121,11 +121,13 @@ systemctl reload nginx #================================================= # MODIFY A CONFIG FILE #================================================= -key=$(ynh_string_random --length=50) +# copy config.dist.php creating config.local.php cp -a $final_path/config.dist.php $final_path/config.local.php +# create a key for the secret key CSFR; +key=$(ynh_string_random --length=50) +# edit config.local.php ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" -if [ "$path_url" == "/" ] -then +if [ "$path_url" == "/" ]; then ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" else ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url/';" --target_file="$final_path/config.local.php" diff --git a/scripts/restore b/scripts/restore index 75164ec..53d9726 100644 --- a/scripts/restore +++ b/scripts/restore @@ -83,8 +83,7 @@ ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 # Define and install dependencies -ynh_install_app_dependencies php7.0-sqlite3 - +ynh_install_app_dependencies $pkg_dependencies #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 1f53880..eaeffbf 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -53,20 +53,18 @@ if [ -z "$final_path" ]; then fi #================================================= -# Backup squlite, config.local.php and squelettes directory +# Backup Data #================================================= ynh_script_progression --message="Backing up the data before upgrading (may take a while)..." --time --weight=1 bdd=$final_path/association.sqlite squelettes=$final_path/www/squelettes -if [ -d "$squelettes" ] -then +if [ -d "$squelettes" ]; then cp -ar $squelettes /tmp/squelettes fi -if [ -e "$bdd" ] -then +if [ -e "$bdd" ]; then cp -a $bdd /tmp/association.sqlite fi From 253c773bb2c710e8989bcbf9b02c5f2251e43096 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Sat, 11 Apr 2020 16:29:36 +0200 Subject: [PATCH 173/207] forget correct string to replace in config.local.php --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 744f84c..997d3bd 100644 --- a/scripts/install +++ b/scripts/install @@ -126,7 +126,7 @@ cp -a $final_path/config.dist.php $final_path/config.local.php # create a key for the secret key CSFR; key=$(ynh_string_random --length=50) # edit config.local.php -ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" if [ "$path_url" == "/" ]; then ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" else diff --git a/scripts/upgrade b/scripts/upgrade index eaeffbf..be4b06b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -145,7 +145,7 @@ ynh_script_progression --message="final configuration needed..." --time --weight key=$(ynh_string_random --length=50) cp -a $final_path/config.dist.php $final_path/config.local.php -ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="//const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" if [ "$path_url" == "/" ] then ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" From 71983a0345d2b0f18771f4a7e84ed1b4a7f6b43c Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Sat, 11 Apr 2020 16:33:40 +0200 Subject: [PATCH 174/207] back to the correct string to replace, I mistake on the last commit --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 997d3bd..744f84c 100644 --- a/scripts/install +++ b/scripts/install @@ -126,7 +126,7 @@ cp -a $final_path/config.dist.php $final_path/config.local.php # create a key for the secret key CSFR; key=$(ynh_string_random --length=50) # edit config.local.php -ynh_replace_string --match_string="//const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" if [ "$path_url" == "/" ]; then ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" else diff --git a/scripts/upgrade b/scripts/upgrade index be4b06b..eaeffbf 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -145,7 +145,7 @@ ynh_script_progression --message="final configuration needed..." --time --weight key=$(ynh_string_random --length=50) cp -a $final_path/config.dist.php $final_path/config.local.php -ynh_replace_string --match_string="//const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" +ynh_replace_string --match_string="const SECRET_KEY = '3xUhIgGwuovRKOjVsVPQ5yUMfXUSIOX2GKzcebsz5OINrYC50r';" --replace_string="const SECRET_KEY = '$key';" --target_file="$final_path/config.local.php" if [ "$path_url" == "/" ] then ynh_replace_string --match_string="//const WWW_URI = '/asso/';" --replace_string="const WWW_URI = '$path_url';" --target_file="$final_path/config.local.php" From 637a7f282d5aeacbe5b88c1ab9daf9cf68b8e224 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 29 Apr 2020 01:16:00 +0200 Subject: [PATCH 175/207] try to fix unskipped uris obsolete --- manifest.json | 2 +- scripts/_common.sh | 35 +++++++++++++++++++++++++ scripts/install | 56 +++++++++++++++++++++++---------------- scripts/upgrade | 65 ++++++++++++++++++++++++++++++++++------------ 4 files changed, 117 insertions(+), 41 deletions(-) diff --git a/manifest.json b/manifest.json index 46f61bf..5424020 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "id": "garradin", "packaging_format": 1, "requirements": { - "yunohost": ">=3.5.0" + "yunohost": ">=3.7.0" }, "description": { "en": "Software to manage association", diff --git a/scripts/_common.sh b/scripts/_common.sh index 6248f06..05ab34a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,3 +8,38 @@ pkg_dependencies="php7.0-sqlite3" # ============= FUTURE YUNOHOST HELPER ============= + +# Check if a permission exists +# +# While waiting for this new helper https://github.com/YunoHost/yunohost/pull/905 +# We have to use another one because the new helper use a new YunoHost command, not available for now. +# +# usage: ynh_permission_has_user --permission=permission --user=user +# | arg: -p, --permission - the permission to check +# | arg: -u, --user - the user seek in the permission +# +# example: ynh_permission_has_user --permission=main --user=visitors +# +# Requires YunoHost version 3.7.1 or higher. +ynh_permission_has_user() { + local legacy_args=pu + # Declare an array to define the options of this helper. + declare -Ar args_array=( [p]=permission= [u]=user= ) + local permission + local user + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + if ! ynh_permission_exists --permission=$permission + then + return 1 + fi + + # List all permissions + # Filter only the required permission with a multiline sed (Here a cut from the permission to the next one), remove the url and his value + perm="$(yunohost user permission list --full --output-as plain | sed --quiet "/^#$app.$permission/,/^#[[:alnum:]]/p" | sed "/^##url/,+1d")" + # Remove all lines starting by # (got from the plain output before) + allowed_users="$(echo "$perm" | grep --invert-match '^#')" + # Grep the list of users an return the result if the user is indeed into the list + echo "$allowed_users" | grep --quiet --word "$user" +} \ No newline at end of file diff --git a/scripts/install b/scripts/install index 744f84c..2298608 100644 --- a/scripts/install +++ b/scripts/install @@ -20,11 +20,10 @@ ynh_abort_if_errors # Retrieve arguments #================================================= -domain=$YNH_APP_ARG_DOMAIN -path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC - -app=$YNH_APP_INSTANCE_NAME +#domain=$YNH_APP_ARG_DOMAIN +#path_url=$YNH_APP_ARG_PATH +#is_public=$YNH_APP_ARG_IS_PUBLIC +#app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS @@ -49,7 +48,7 @@ ynh_script_progression --message="Storing installation settings..." --time --wei ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=is_public --value=$is_public +#ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= # Install dependency to convert tracks to a readable format for the browser @@ -95,28 +94,39 @@ ynh_script_progression --message="Configuring php-fpm..." --time --weight=1 # Create a dedicated php-fpm config ynh_add_fpm_config +#================================================= +# Files owned by user app +#================================================= + +chown $app:$app $final_path -R +chmod 755 $final_path -R + +# Remove the public access +ynh_app_setting_delete --app=$app --key=skipped_uris #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --time --weight=1 +ynh_script_progression --message="Configuring permissions..." --time --weight=1 -if [ $is_public -eq 0 ] -then # Remove the public access - ynh_app_setting_delete $app skipped_uris -fi +# if [ $is_public -eq 0 ] +# then # Remove the public access +# ynh_app_setting_delete $app skipped_uris +# fi +# # Make app public if necessary +# if [ $is_public -eq 1 ] +# then +# # unprotected_uris allows SSO credentials to be passed anyway. +# ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" +# fi # Make app public if necessary if [ $is_public -eq 1 ] then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" + # Everyone can access the app. + # The "main" permission is automatically created before the install script. + ynh_permission_update --permission "main" --add "visitors" fi - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 - -systemctl reload nginx +# Only the users can access to the panel of the app +# ynh_permission_update --permission="main" --add "all_users" #================================================= # MODIFY A CONFIG FILE @@ -134,11 +144,11 @@ else fi #================================================= -# Files owned by user app +# RELOAD NGINX #================================================= +ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 -chown $app:$app $final_path -R -chmod 755 $final_path -R +systemctl reload nginx #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index eaeffbf..2545157 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,7 +18,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) +#is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) || ynh_die "This path already contains a folder" #================================================= # CHECK VERSION @@ -37,14 +37,14 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 -# Fix is_public as a boolean value -if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=1 - is_public=1 -elif [ "$is_public" = "No" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=0 - is_public=0 -fi +# # Fix is_public as a boolean value +# if [ "$is_public" = "Yes" ]; then +# ynh_app_setting_set --app=$app --key=is_public --value=1 +# is_public=1 +# elif [ "$is_public" = "No" ]; then +# ynh_app_setting_set --app=$app --key=is_public --value=0 +# is_public=0 +# fi # If final_path doesn't exist, create it if [ -z "$final_path" ]; then @@ -52,6 +52,30 @@ if [ -z "$final_path" ]; then ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi +### If nobody installed your app before 3.7, +### then you may safely remove these lines + +# Cleaning legacy permissions +is_public=$(ynh_app_setting_get --app=$app --key=is_public) + +if [ -n "$is_public" ]; then + # Remove unprotected_uris + ynh_app_setting_delete --app=$app --key=unprotected_uris + # Remove protected_uris + ynh_app_setting_delete --app=$app --key=protected_uris + + # Removing skipped/unprotected_uris under certain conditions, remove the visitors group added during the migration process of 3.7 + # Remove skipped_uris. If the app was public, add visitors again to the main permission + if ynh_permission_has_user --permission=main --user=visitors + then + ynh_app_setting_delete --app=$app --key=skipped_uris + ynh_permission_update --permission "main" --add "visitors" + else + ynh_app_setting_delete --app=$app --key=skipped_uris + fi + ynh_app_setting_delete --app=$app --key=is_public +fi + #================================================= # Backup Data #================================================= @@ -92,7 +116,7 @@ ynh_abort_if_errors # instead of /foo .... # If nobody installed your app before 2.7, then you may # safely remove this line -path_url=$(ynh_normalize_url_path --path_url=$path_url) +#path_url=$(ynh_normalize_url_path --path_url=$path_url) #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -181,14 +205,21 @@ chmod 755 $final_path -R #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." --time --weight=1 +ynh_script_progression --message="Upgrading permissions configuration..." --time --weight=1 -# Make app public if necessary -if [ $is_public -eq 1 ] -then - # unprotected_uris allows SSO credentials to be passed anyway - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" -fi + + +# # Make app public if necessary +# if [ $is_public -eq 1 ] +# then +# # unprotected_uris allows SSO credentials to be passed anyway +# ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" +# fi + +# Create the admin permission if needed +# if ! ynh_permission_exists --permission "all_users"; then +# ynh_permission_create --permission "all_users" --url "/admin" --allowed $admin +# fi #================================================= # RELOAD NGINX From c43d47071f106cffd5feb200b801fc8e32b5e841 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 29 Apr 2020 01:57:58 +0200 Subject: [PATCH 176/207] try to fix unskipped uris obsolete --- scripts/upgrade | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 2545157..55d4dc6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -56,7 +56,7 @@ fi ### then you may safely remove these lines # Cleaning legacy permissions -is_public=$(ynh_app_setting_get --app=$app --key=is_public) +# is_public=$(ynh_app_setting_get --app=$app --key=is_public) if [ -n "$is_public" ]; then # Remove unprotected_uris @@ -64,9 +64,9 @@ if [ -n "$is_public" ]; then # Remove protected_uris ynh_app_setting_delete --app=$app --key=protected_uris - # Removing skipped/unprotected_uris under certain conditions, remove the visitors group added during the migration process of 3.7 - # Remove skipped_uris. If the app was public, add visitors again to the main permission - if ynh_permission_has_user --permission=main --user=visitors + #Removing skipped/unprotected_uris under certain conditions, remove the visitors group added during the migration process of 3.7 + #Remove skipped_uris. If the app was public, add visitors again to the main permission + elif ynh_permission_has_user --permission=main --user=visitors then ynh_app_setting_delete --app=$app --key=skipped_uris ynh_permission_update --permission "main" --add "visitors" @@ -216,10 +216,10 @@ ynh_script_progression --message="Upgrading permissions configuration..." --time # ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" # fi -# Create the admin permission if needed -# if ! ynh_permission_exists --permission "all_users"; then -# ynh_permission_create --permission "all_users" --url "/admin" --allowed $admin -# fi +# Create the visitors permission if needed +if ! ynh_permission_exists --permission "visitors"; then + ynh_permission_create --permission "visitors" --url "/admin" --allowed $admin +fi #================================================= # RELOAD NGINX From 3ec9b2c9fdb5d55e8709c4a869b3d32d63e70b32 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 29 Apr 2020 02:01:02 +0200 Subject: [PATCH 177/207] try to fix unskipped uris obsolete --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 55d4dc6..1bc02fc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -66,7 +66,7 @@ if [ -n "$is_public" ]; then #Removing skipped/unprotected_uris under certain conditions, remove the visitors group added during the migration process of 3.7 #Remove skipped_uris. If the app was public, add visitors again to the main permission - elif ynh_permission_has_user --permission=main --user=visitors + if ynh_permission_has_user --permission=main --user=visitors then ynh_app_setting_delete --app=$app --key=skipped_uris ynh_permission_update --permission "main" --add "visitors" From 33fe6bebed7d1ba56faca483e91dc933e691ff7f Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 29 Apr 2020 02:04:51 +0200 Subject: [PATCH 178/207] try to fix unskipped uris obsolete --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 1bc02fc..43c4393 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -218,7 +218,7 @@ ynh_script_progression --message="Upgrading permissions configuration..." --time # Create the visitors permission if needed if ! ynh_permission_exists --permission "visitors"; then - ynh_permission_create --permission "visitors" --url "/admin" --allowed $admin + ynh_permission_create --permission "visitors" fi #================================================= From ec8c8ddb5aae07aac0c542b0baf7b71fa659bc10 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 29 Apr 2020 02:16:04 +0200 Subject: [PATCH 179/207] try to fix unskipped uris obsolete --- scripts/install | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 2298608..6ae5ff5 100644 --- a/scripts/install +++ b/scripts/install @@ -20,10 +20,10 @@ ynh_abort_if_errors # Retrieve arguments #================================================= -#domain=$YNH_APP_ARG_DOMAIN +domain=$YNH_APP_ARG_DOMAIN #path_url=$YNH_APP_ARG_PATH -#is_public=$YNH_APP_ARG_IS_PUBLIC -#app=$YNH_APP_INSTANCE_NAME +is_public=$YNH_APP_ARG_IS_PUBLIC +app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS From 61c063f03a4ed676d03a50dbcdeabb3ed4156c0e Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 29 Apr 2020 02:25:10 +0200 Subject: [PATCH 180/207] try to fix unskipped uris obsolete --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 6ae5ff5..07f5d85 100644 --- a/scripts/install +++ b/scripts/install @@ -21,8 +21,8 @@ ynh_abort_if_errors #================================================= domain=$YNH_APP_ARG_DOMAIN -#path_url=$YNH_APP_ARG_PATH -is_public=$YNH_APP_ARG_IS_PUBLIC +path_url=$YNH_APP_ARG_PATH +#is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME #================================================= From ecf2a8f8c0e0453535c1e1699f6ff9a151293cd9 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 29 Apr 2020 02:44:02 +0200 Subject: [PATCH 181/207] try to fix unskipped uris obsolete --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 07f5d85..1eb5c1f 100644 --- a/scripts/install +++ b/scripts/install @@ -22,7 +22,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH -#is_public=$YNH_APP_ARG_IS_PUBLIC +is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME #================================================= From a5c1e0806e520105f7f08db1b9dee955cb7283be Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 29 Apr 2020 02:51:54 +0200 Subject: [PATCH 182/207] cleaning old lines --- scripts/install | 11 ----------- scripts/upgrade | 18 ------------------ 2 files changed, 29 deletions(-) diff --git a/scripts/install b/scripts/install index 1eb5c1f..e059abf 100644 --- a/scripts/install +++ b/scripts/install @@ -48,7 +48,6 @@ ynh_script_progression --message="Storing installation settings..." --time --wei ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url -#ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= # Install dependency to convert tracks to a readable format for the browser @@ -108,16 +107,6 @@ ynh_app_setting_delete --app=$app --key=skipped_uris #================================================= ynh_script_progression --message="Configuring permissions..." --time --weight=1 -# if [ $is_public -eq 0 ] -# then # Remove the public access -# ynh_app_setting_delete $app skipped_uris -# fi -# # Make app public if necessary -# if [ $is_public -eq 1 ] -# then -# # unprotected_uris allows SSO credentials to be passed anyway. -# ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" -# fi # Make app public if necessary if [ $is_public -eq 1 ] then diff --git a/scripts/upgrade b/scripts/upgrade index 43c4393..17b65c0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -37,15 +37,6 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 -# # Fix is_public as a boolean value -# if [ "$is_public" = "Yes" ]; then -# ynh_app_setting_set --app=$app --key=is_public --value=1 -# is_public=1 -# elif [ "$is_public" = "No" ]; then -# ynh_app_setting_set --app=$app --key=is_public --value=0 -# is_public=0 -# fi - # If final_path doesn't exist, create it if [ -z "$final_path" ]; then final_path=/var/www/$app @@ -207,15 +198,6 @@ chmod 755 $final_path -R #================================================= ynh_script_progression --message="Upgrading permissions configuration..." --time --weight=1 - - -# # Make app public if necessary -# if [ $is_public -eq 1 ] -# then -# # unprotected_uris allows SSO credentials to be passed anyway -# ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" -# fi - # Create the visitors permission if needed if ! ynh_permission_exists --permission "visitors"; then ynh_permission_create --permission "visitors" From 2bbedf11e0aae423ded9c7d47187cac04f0c6268 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 29 Apr 2020 03:44:14 +0200 Subject: [PATCH 183/207] try to chnage vulnerability path --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 8328b41..9e4198e 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,4 @@ -location __PATH__ { +location __PATH__/ { # Path to source alias __FINALPATH__/www/ ; From 513acdf3a111c322a5d929fb0441725008e63197 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 29 Apr 2020 04:10:23 +0200 Subject: [PATCH 184/207] come back within a slash at path nginx conf --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 9e4198e..8328b41 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,4 @@ -location __PATH__/ { +location __PATH__ { # Path to source alias __FINALPATH__/www/ ; From 3b70f3e26d6c7d2c36e54ff02e742543f9f6f469 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Mon, 15 Jun 2020 11:45:14 +0200 Subject: [PATCH 185/207] try update version garradin to 0.9.6 --- conf/app.src | 4 ++-- scripts/change_url | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/conf/app.src b/conf/app.src index e58db5a..793816f 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-0.9.5.tar.bz2 -SOURCE_SUM=48f8d62d8c86b3aef2d090b2a7d04873c9642d6efc451389f58a5d6e89d89612 +SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-0.9.6.tar.bz2 +SOURCE_SUM=a0c4dcc6adc25a6f093bc09b0ed4c7efcbfde0726b790431c293112800ccc282 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.bz2 SOURCE_IN_SUBDIR=true diff --git a/scripts/change_url b/scripts/change_url index 7244972..64f0a01 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -58,6 +58,7 @@ fi # MODIFY URL IN NGINX CONF #================================================= ynh_script_progression --message="Updating nginx web server configuration..." --time --weight=1 + nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf final_path=/var/www/$app From 0e593df4e6515e3f3d15c216488c3773738680be Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Mon, 15 Jun 2020 12:06:02 +0200 Subject: [PATCH 186/207] cleaning syntax unused and try upgrade version --- manifest.json | 2 +- scripts/_common.sh | 2 +- scripts/install | 8 ++------ scripts/upgrade | 2 -- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/manifest.json b/manifest.json index 5424020..34c3f48 100644 --- a/manifest.json +++ b/manifest.json @@ -9,7 +9,7 @@ "en": "Software to manage association", "fr": "Logiciel libre de gestion d'association" }, - "version": "0.9.5~ynh3", + "version": "0.9.6~ynh3", "url": "http://garradin.eu/a-propos/", "license": "GPL-3.0-or-later", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index 05ab34a..2ec5196 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="php7.0-sqlite3" +pkg_dependencies="php-sqlite3" # ============= FUTURE YUNOHOST HELPER ============= diff --git a/scripts/install b/scripts/install index e059abf..ba784e1 100644 --- a/scripts/install +++ b/scripts/install @@ -54,12 +54,8 @@ ynh_app_setting_set --app=$app --key=path --value=$path_url #================================================= ynh_script_progression --message="Installing dependencies..." --time --weight=1 -if [ "$(lsb_release --codename --short)" != "jessie" ] -then - ynh_install_app_dependencies $pkg_dependencies -else - ynh_die --message="Votre version de Debian n'est pas compatible..." --time --weight=1 -fi +ynh_install_app_dependencies $pkg_dependencies + #================================================= # CREATE DEDICATED USER diff --git a/scripts/upgrade b/scripts/upgrade index 17b65c0..a764151 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -50,8 +50,6 @@ fi # is_public=$(ynh_app_setting_get --app=$app --key=is_public) if [ -n "$is_public" ]; then - # Remove unprotected_uris - ynh_app_setting_delete --app=$app --key=unprotected_uris # Remove protected_uris ynh_app_setting_delete --app=$app --key=protected_uris From 37d06a0b4c3aa1c1402e559a179ed3e39ac7a375 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Mon, 15 Jun 2020 13:04:07 +0200 Subject: [PATCH 187/207] come back to version 0.9.5 and still stay from the previous PR request --- conf/app.src | 2 +- manifest.json | 2 +- scripts/_common.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index 793816f..b35da6a 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,4 +1,4 @@ -SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-0.9.6.tar.bz2 +SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-0.9.5.tar.bz2 SOURCE_SUM=a0c4dcc6adc25a6f093bc09b0ed4c7efcbfde0726b790431c293112800ccc282 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.bz2 diff --git a/manifest.json b/manifest.json index 34c3f48..5424020 100644 --- a/manifest.json +++ b/manifest.json @@ -9,7 +9,7 @@ "en": "Software to manage association", "fr": "Logiciel libre de gestion d'association" }, - "version": "0.9.6~ynh3", + "version": "0.9.5~ynh3", "url": "http://garradin.eu/a-propos/", "license": "GPL-3.0-or-later", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index 2ec5196..05ab34a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="php-sqlite3" +pkg_dependencies="php7.0-sqlite3" # ============= FUTURE YUNOHOST HELPER ============= From a59f193344576a84a5ec17d1267298c999ba8a26 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 17 Jun 2020 16:46:30 +0200 Subject: [PATCH 188/207] correct sha256sum for 0.9.5 version --- .../pull_request_template.md | 16 ++++++++-------- conf/app.src | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md index 0922b30..9979eb1 100644 --- a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -1,18 +1,18 @@ ## Problem -- +- ## Solution -- +- ## PR Status -- +- ## Validation --- *Minor decision* -- **Upgrade previous version** : -- [ ] **Code review** : -- [ ] **Approval (LGTM)** : -- [ ] **Approval (LGTM)** : -- **CI succeeded** : [![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/garradin_ynh%20xxx%20(Official)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/nextcloud_ynh%20xxx%20(Official)/) +- **Upgrade previous version** : +- [ ] **Code review** : +- [ ] **Approval (LGTM)** : +- [ ] **Approval (LGTM)** : +- **CI succeeded** : [![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/garradin_ynh%20xxx%20(Official)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/nextcloud_ynh%20xxx%20(Official)/) When the PR is mark as ready to merge, you have to wait for 3 days before really merge it. diff --git a/conf/app.src b/conf/app.src index b35da6a..e58db5a 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-0.9.5.tar.bz2 -SOURCE_SUM=a0c4dcc6adc25a6f093bc09b0ed4c7efcbfde0726b790431c293112800ccc282 +SOURCE_SUM=48f8d62d8c86b3aef2d090b2a7d04873c9642d6efc451389f58a5d6e89d89612 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.bz2 SOURCE_IN_SUBDIR=true From 973d048f6d2799bccfbc997628af94c1c1451044 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 17 Jun 2020 17:09:51 +0200 Subject: [PATCH 189/207] change source to upgrade version garradin, change packages_dependencies as php-sqlite3 will install the corect dependencies also --- conf/app.src | 2 +- manifest.json | 2 +- scripts/_common.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index b35da6a..793816f 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,4 +1,4 @@ -SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-0.9.5.tar.bz2 +SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-0.9.6.tar.bz2 SOURCE_SUM=a0c4dcc6adc25a6f093bc09b0ed4c7efcbfde0726b790431c293112800ccc282 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.bz2 diff --git a/manifest.json b/manifest.json index 5424020..371f6fd 100644 --- a/manifest.json +++ b/manifest.json @@ -9,7 +9,7 @@ "en": "Software to manage association", "fr": "Logiciel libre de gestion d'association" }, - "version": "0.9.5~ynh3", + "version": "0.9.6~ynh3", "url": "http://garradin.eu/a-propos/", "license": "GPL-3.0-or-later", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index 05ab34a..2ec5196 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="php7.0-sqlite3" +pkg_dependencies="php-sqlite3" # ============= FUTURE YUNOHOST HELPER ============= From a59b2f7aabcbd80fb326303641bbda63cb7b49f4 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 17 Jun 2020 17:58:24 +0200 Subject: [PATCH 190/207] add an increase size limit in nginx.conf --- conf/nginx.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conf/nginx.conf b/conf/nginx.conf index 8328b41..50e50e6 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -22,6 +22,9 @@ location ~ [^/]\.php(/|$) { } # PHP configuration end + # Increase size limit + client_max_body_size 2M; + # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; } \ No newline at end of file From 9b817517aeb220783e5e53ae9162ede90d0abe82 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 17 Jun 2020 18:48:08 +0200 Subject: [PATCH 191/207] remove trailing spaces --- .../pull_request_template.md | 16 +++++----- conf/nginx.conf | 31 ++++++++++--------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md index 0922b30..9979eb1 100644 --- a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -1,18 +1,18 @@ ## Problem -- +- ## Solution -- +- ## PR Status -- +- ## Validation --- *Minor decision* -- **Upgrade previous version** : -- [ ] **Code review** : -- [ ] **Approval (LGTM)** : -- [ ] **Approval (LGTM)** : -- **CI succeeded** : [![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/garradin_ynh%20xxx%20(Official)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/nextcloud_ynh%20xxx%20(Official)/) +- **Upgrade previous version** : +- [ ] **Code review** : +- [ ] **Approval (LGTM)** : +- [ ] **Approval (LGTM)** : +- **CI succeeded** : [![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/garradin_ynh%20xxx%20(Official)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/nextcloud_ynh%20xxx%20(Official)/) When the PR is mark as ready to merge, you have to wait for 3 days before really merge it. diff --git a/conf/nginx.conf b/conf/nginx.conf index 50e50e6..eec0539 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,30 +1,31 @@ location __PATH__ { -# Path to source -alias __FINALPATH__/www/ ; + # Path to source + alias __FINALPATH__/www/ ; -if ($scheme = http) { + if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; -} + } - # Example PHP configuration (remove if not used) + # Example PHP configuration (remove if not used) index index.php /_route.php; try_files $uri $uri/ index.php /_route.php; -location ~ [^/]\.php(/|$) { - fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; - fastcgi_index index.php; - include fastcgi_params; - fastcgi_param REMOTE_USER $remote_user; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param SCRIPT_FILENAME $request_filename; -} - # PHP configuration end + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $request_filename; + } # Increase size limit client_max_body_size 2M; + # PHP configuration end + # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; } \ No newline at end of file From 7e5926e016afb231d986b8b52b5b1cbdf58f18b7 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 17 Jun 2020 19:23:36 +0200 Subject: [PATCH 192/207] add an explanation for is_public in manifest --- manifest.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manifest.json b/manifest.json index 371f6fd..0b4bde0 100644 --- a/manifest.json +++ b/manifest.json @@ -49,6 +49,10 @@ "en": "Is it a public application?", "fr": "Est-ce une application publique ?" }, + "help": { + "en": "The SSO is not implemented for this app and yunohost is not sure for hundred of users..." + "fr": "Le SSO n'est pas implémenté pour cette application et yunohost n'est pas sûr pour une centaine d'utilisateurs..." + }, "default": true } ] From 777bc3dfcf9417377655c6842fdab9dd506372d1 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 17 Jun 2020 19:44:22 +0200 Subject: [PATCH 193/207] syntax --- scripts/install | 2 +- scripts/upgrade | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index ba784e1..d2f9c94 100644 --- a/scripts/install +++ b/scripts/install @@ -56,11 +56,11 @@ ynh_script_progression --message="Installing dependencies..." --time --weight=1 ynh_install_app_dependencies $pkg_dependencies - #================================================= # CREATE DEDICATED USER #================================================= ynh_script_progression --message="Configuring system user..." --time --weight=1 + # Create a system user ynh_system_user_create --username=$app diff --git a/scripts/upgrade b/scripts/upgrade index a764151..a708b02 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -18,7 +18,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) -#is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) || ynh_die "This path already contains a folder" #================================================= # CHECK VERSION From 851a3b1ca15bdcbc2287741fbb281117d34f4bc7 Mon Sep 17 00:00:00 2001 From: frju365 Date: Wed, 17 Jun 2020 20:18:24 +0200 Subject: [PATCH 194/207] Typo --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 6463da4..6a94ac3 100644 --- a/manifest.json +++ b/manifest.json @@ -52,7 +52,7 @@ "fr": "Est-ce une application publique ?" }, "help": { - "en": "The SSO is not implemented for this app and yunohost is not sure for hundred of users..." + "en": "The SSO is not implemented for this app and yunohost is not sure for hundred of users...", "fr": "Le SSO n'est pas implémenté pour cette application et yunohost n'est pas sûr pour une centaine d'utilisateurs..." }, "default": true From ab97ad0273c5e76cbb33d6c1f4d6faf1b873db7c Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 17 Jun 2020 20:20:36 +0200 Subject: [PATCH 195/207] try add a slash in path to source nginx.conf --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index af69520..2bb1f0e 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,4 @@ -location __PATH__ { +location __PATH__/ { # Path to source alias __FINALPATH__/www/ ; From 1cb25749889e488b6aa6598da26aee58e1cf9713 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 17 Jun 2020 20:40:11 +0200 Subject: [PATCH 196/207] remove slash in path to source nginx.conf --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 2bb1f0e..af69520 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,4 @@ -location __PATH__/ { +location __PATH__ { # Path to source alias __FINALPATH__/www/ ; From c8e99e661ea4dd1fea689e3671333c7e0190519d Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Wed, 17 Jun 2020 22:02:35 +0200 Subject: [PATCH 197/207] add backup before upgrade --- scripts/change_url | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 64f0a01..3eed07a 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -29,14 +29,22 @@ ynh_script_progression --message="Loading installation settings..." --time --wei # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) -# #================================================= -# # CHECK THE SYNTAX OF THE PATHS -# #================================================= +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --time --weight=1 -# test -n "$old_path" || old_path="/" -# test -n "$new_path" || new_path="/" -# new_path=$(ynh_normalize_url_path $new_path) -# old_path=$(ynh_normalize_url_path $old_path) +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. + ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" + + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED From 649e36dd23b57d603fbe00d7b7e0ab7bd6efd2d6 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 18 Jun 2020 00:26:17 +0200 Subject: [PATCH 198/207] remove active trap backup --- scripts/change_url | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 3eed07a..3a62f9c 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -29,23 +29,6 @@ ynh_script_progression --message="Loading installation settings..." --time --wei # Needed for helper "ynh_add_nginx_config" final_path=$(ynh_app_setting_get --app=$app --key=final_path) -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." --time --weight=1 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. - ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= From 658e20d9cb005b9221fcc22cf4aa40b17a453660 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 23 Jul 2020 12:23:04 +0200 Subject: [PATCH 199/207] try to change nginx conf without alias --- conf/nginx.conf | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index af69520..9e7c3de 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,20 +1,22 @@ -location __PATH__ { +location / { # Path to source -alias __FINALPATH__/www/ ; +root __FINALPATH__/www/ ; if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } # Example PHP configuration (remove if not used) - index index.php /_route.php; - try_files $uri $uri/ index.php /_route.php; - location ~ [^/]\.php(/|$) { - fastcgi_split_path_info ^(.+?\.php)(/.*)$; + location / { + try_files $uri $uri/ index.php /_route.php; + index index.php /_route.php; + } + + location ~ \.php { + try_files $uri $uri/ /_route.php; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; - fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; fastcgi_param PATH_INFO $fastcgi_path_info; From 3879310ecd33946831091035f44de589dd4f6fe9 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 23 Jul 2020 12:35:09 +0200 Subject: [PATCH 200/207] Revert "try to change nginx conf without alias" This reverts commit 658e20d9cb005b9221fcc22cf4aa40b17a453660. come back initial --- conf/nginx.conf | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 9e7c3de..af69520 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,22 +1,20 @@ -location / { +location __PATH__ { # Path to source -root __FINALPATH__/www/ ; +alias __FINALPATH__/www/ ; if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } # Example PHP configuration (remove if not used) + index index.php /_route.php; + try_files $uri $uri/ index.php /_route.php; - location / { - try_files $uri $uri/ index.php /_route.php; - index index.php /_route.php; - } - - location ~ \.php { - try_files $uri $uri/ /_route.php; + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; + fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; fastcgi_param PATH_INFO $fastcgi_path_info; From dae3e132a1761e7edf40566c200913245d6bb941 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 23 Jul 2020 13:31:33 +0200 Subject: [PATCH 201/207] try debug uris nginx conf --- conf/nginx.conf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index af69520..727721f 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -8,13 +8,16 @@ if ($scheme = http) { } # Example PHP configuration (remove if not used) + location __PATH__ { index index.php /_route.php; try_files $uri $uri/ index.php /_route.php; + } location ~ [^/]\.php(/|$) { + try_files $uri $uri/ /_route.php; fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; - fastcgi_index index.php; + # fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; fastcgi_param PATH_INFO $fastcgi_path_info; From 3e7c77733cb960690e276c8d9e363bc633e65da3 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 23 Jul 2020 13:37:09 +0200 Subject: [PATCH 202/207] try debug uris nginx conf --- conf/nginx.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 727721f..09f18cb 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,4 @@ -location __PATH__ { +location __PATH__/ { # Path to source alias __FINALPATH__/www/ ; @@ -8,7 +8,7 @@ if ($scheme = http) { } # Example PHP configuration (remove if not used) - location __PATH__ { + location __PATH__/ { index index.php /_route.php; try_files $uri $uri/ index.php /_route.php; } From d3ccbfe60503e58d8927e3184488c386e3088103 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 23 Jul 2020 14:47:11 +0200 Subject: [PATCH 203/207] update garradin version --- conf/app.src | 4 ++-- conf/nginx.conf | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/app.src b/conf/app.src index 793816f..a24c59a 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-0.9.6.tar.bz2 -SOURCE_SUM=a0c4dcc6adc25a6f093bc09b0ed4c7efcbfde0726b790431c293112800ccc282 +SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-0.9.8.tar.bz2 +SOURCE_SUM=98aa01b86521ff66dcc951ab6f0eb1915e3cee5dada15ba20c96ab72512f1e83 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.bz2 SOURCE_IN_SUBDIR=true diff --git a/conf/nginx.conf b/conf/nginx.conf index 09f18cb..cda2ca4 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -31,4 +31,4 @@ if ($scheme = http) { # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; -} \ No newline at end of file +} From 7d8c0794f0f3993834b4cd97c59eeb5ce30fb8ee Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 23 Jul 2020 14:47:52 +0200 Subject: [PATCH 204/207] update garradin version --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 6a94ac3..58e2823 100644 --- a/manifest.json +++ b/manifest.json @@ -10,7 +10,7 @@ "fr": "Logiciel libre de gestion d'association" }, - "version": "0.9.6~ynh3", + "version": "0.9.8~ynh3", "url": "http://garradin.eu/a-propos/", "license": "GPL-3.0-or-later", From e81141789fac0ed784f9fa670af1d6d5d3280538 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 23 Jul 2020 14:58:59 +0200 Subject: [PATCH 205/207] try debug uris nginx conf --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index cda2ca4..7f58bb4 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,4 @@ -location __PATH__/ { +location __PATH__ { # Path to source alias __FINALPATH__/www/ ; From c1816bc9f21704f71f4f00ae47ae137e894c3365 Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 23 Jul 2020 15:04:38 +0200 Subject: [PATCH 206/207] protect sensibles urls --- conf/nginx.conf | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/conf/nginx.conf b/conf/nginx.conf index 7f58bb4..cf253bc 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -6,6 +6,18 @@ alias __FINALPATH__/www/ ; if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } + + # Protecting sensibles urls + location ~ 403 { + rewrite ^(.*)$ /include/ redirect; + rewrite ^(.*)$ /cache/ redirect; + rewrite ^(.*)$ /plugins/ redirect; + rewrite ^(.*)$ /templates/ redirect; + rewrite ^(.*)$ /.*.sqlite redirect; + rewrite ^(.*)$ /.*.log redirect; + rewrite ^(.*)$ /(README|VERSION|COPYING) redirect; + rewrite ^(.*)$ /config\.(.*)\.php redirect; + } # Example PHP configuration (remove if not used) location __PATH__/ { From 16f3f2b4e501cae71e2845fd6ca215b05ed118ae Mon Sep 17 00:00:00 2001 From: Robles Rodolphe Date: Thu, 30 Jul 2020 14:33:11 +0200 Subject: [PATCH 207/207] update garradin version and add protected uris in nginx.conf --- conf/app.src | 4 ++-- conf/nginx.conf | 22 ++++++++++++++-------- manifest.json | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/conf/app.src b/conf/app.src index 793816f..a24c59a 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-0.9.6.tar.bz2 -SOURCE_SUM=a0c4dcc6adc25a6f093bc09b0ed4c7efcbfde0726b790431c293112800ccc282 +SOURCE_URL=https://fossil.kd2.org/garradin/uv/garradin-0.9.8.tar.bz2 +SOURCE_SUM=98aa01b86521ff66dcc951ab6f0eb1915e3cee5dada15ba20c96ab72512f1e83 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.bz2 SOURCE_IN_SUBDIR=true diff --git a/conf/nginx.conf b/conf/nginx.conf index efd6ba0..cf253bc 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,13 +1,13 @@ -#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__ { - - # Path to source - alias __FINALPATH__/www/ ; - if ($scheme = http) { +# Path to source +alias __FINALPATH__/www/ ; + +if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } - + + # Protecting sensibles urls location ~ 403 { rewrite ^(.*)$ /include/ redirect; rewrite ^(.*)$ /cache/ redirect; @@ -19,13 +19,17 @@ location __PATH__ { rewrite ^(.*)$ /config\.(.*)\.php redirect; } - try_files $uri $uri/ index.php /_route.php; + # Example PHP configuration (remove if not used) + location __PATH__/ { index index.php /_route.php; + try_files $uri $uri/ index.php /_route.php; + } location ~ [^/]\.php(/|$) { + try_files $uri $uri/ /_route.php; fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; - fastcgi_index index.php; + # fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; fastcgi_param PATH_INFO $fastcgi_path_info; @@ -35,6 +39,8 @@ location __PATH__ { # Increase size limit client_max_body_size 2M; + # PHP configuration end + # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; } diff --git a/manifest.json b/manifest.json index 6a94ac3..58e2823 100644 --- a/manifest.json +++ b/manifest.json @@ -10,7 +10,7 @@ "fr": "Logiciel libre de gestion d'association" }, - "version": "0.9.6~ynh3", + "version": "0.9.8~ynh3", "url": "http://garradin.eu/a-propos/", "license": "GPL-3.0-or-later",