From 8d709f7ce112378ba2997c4b7f8d407004a17dbb Mon Sep 17 00:00:00 2001 From: Arthur Lutz Date: Mon, 24 Feb 2020 16:18:42 +0100 Subject: [PATCH 01/24] [install] s/libav-tools/ffmpeg/ --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 6a961c2..761f987 100644 --- a/scripts/install +++ b/scripts/install @@ -55,7 +55,7 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= ynh_script_progression --message="Installing dependencies..." --weight=25 -ynh_install_app_dependencies libav-tools php-cli +ynh_install_app_dependencies ffmpeg php-cli #================================================= # CREATE A MYSQL DATABASE From 934c021743a5e1bf1b94dfd60106c85f294477e6 Mon Sep 17 00:00:00 2001 From: Arthur Lutz Date: Mon, 24 Feb 2020 16:20:18 +0100 Subject: [PATCH 02/24] [upgrade] s/libav-tools/ffmpeg/ --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index e75754c..ff7ede6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -114,7 +114,7 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Upgrading dependencies..." --weight=5 -ynh_install_app_dependencies libav-tools php-cli +ynh_install_app_dependencies ffmpeg php-cli #================================================= # CREATE DEDICATED USER From 4a8e0d97b9ae27d64b4d123079d9bceddc14fb48 Mon Sep 17 00:00:00 2001 From: Arthur Lutz Date: Mon, 24 Feb 2020 16:20:52 +0100 Subject: [PATCH 03/24] [restore] s/libav-tools/ffmpeg/ --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 1862c08..b386bcf 100644 --- a/scripts/restore +++ b/scripts/restore @@ -79,7 +79,7 @@ ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=30 -ynh_install_app_dependencies libav-tools +ynh_install_app_dependencies ffmpeg #================================================= # RESTORE THE MYSQL DATABASE From 6ed19b3f260c36ef34d771701d54ebb3ff5ac3d8 Mon Sep 17 00:00:00 2001 From: Arthur Lutz Date: Mon, 24 Feb 2020 16:30:32 +0100 Subject: [PATCH 04/24] [_common.sh] php7.3 is buster default --- scripts/_common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index b128cee..5258b61 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -19,7 +19,7 @@ ynh_composer_exec () { # Manage arguments with getopts ynh_handle_getopts_args "$@" workdir="${workdir:-$final_path}" - phpversion="${phpversion:-7.0}" + phpversion="${phpversion:-7.3}" COMPOSER_HOME="$workdir/.composer" \ php${phpversion} "$workdir/composer.phar" $commands \ @@ -39,7 +39,7 @@ ynh_install_composer () { # Manage arguments with getopts ynh_handle_getopts_args "$@" workdir="${workdir:-$final_path}" - phpversion="${phpversion:-7.0}" + phpversion="${phpversion:-7.3}" curl -sS https://getcomposer.org/installer \ | COMPOSER_HOME="$workdir/.composer" \ From 26d06a6758f22729098572c61c6ef9ccac35907e Mon Sep 17 00:00:00 2001 From: Kayou Date: Sat, 21 Mar 2020 01:25:28 +0100 Subject: [PATCH 05/24] Update admin.sql --- conf/admin.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/admin.sql b/conf/admin.sql index 050f1e3..0485295 100644 --- a/conf/admin.sql +++ b/conf/admin.sql @@ -1,4 +1,4 @@ -INSERT INTO user(id,username,fullname,access) VALUES("", "__ADMIN__", "__ADMIN__", "100"); +INSERT INTO user(id,username,fullname,access) VALUES(NULL, "__ADMIN__", "__ADMIN__", "100"); UPDATE `user_preference` SET `value` = 'en_US' WHERE `preference` = 31 ; From 0d6c7369047a31e874e6f734cb51846acacd2486 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 15 Apr 2020 20:19:08 +0200 Subject: [PATCH 06/24] Update scripts/install Co-Authored-By: Alexandre Aubin --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 761f987..fb18371 100644 --- a/scripts/install +++ b/scripts/install @@ -55,7 +55,7 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= ynh_script_progression --message="Installing dependencies..." --weight=25 -ynh_install_app_dependencies ffmpeg php-cli +ynh_install_app_dependencies "libav-tools|ffmpeg" php-cli #================================================= # CREATE A MYSQL DATABASE From 6e1d1ae0aee707172b572e21750e93f39167fb08 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 15 Apr 2020 20:33:03 +0200 Subject: [PATCH 07/24] Apply example_ynh --- manifest.json | 4 ++-- scripts/_common.sh | 7 +++++++ scripts/install | 7 ++++--- scripts/remove | 3 ++- scripts/restore | 8 +++++--- scripts/upgrade | 6 ++++-- 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/manifest.json b/manifest.json index bc171fb..40ade8d 100644 --- a/manifest.json +++ b/manifest.json @@ -13,10 +13,10 @@ "name": "aymhce", "email": "aymhce@gmail.com" }, - "multi_instance": true, "requirements": { - "yunohost": ">= 3.5.0" + "yunohost": ">= 3.5" }, + "multi_instance": true, "services" : [ "nginx", "php7.0-fpm", diff --git a/scripts/_common.sh b/scripts/_common.sh index 5258b61..a43d509 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,5 +1,12 @@ #!/bin/bash +#================================================= +# COMMON VARIABLES +#================================================= + +# dependencies used by the app +pkg_dependencies="libav-tools|ffmpeg php-cli" + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index fb18371..c84817b 100644 --- a/scripts/install +++ b/scripts/install @@ -55,7 +55,7 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= ynh_script_progression --message="Installing dependencies..." --weight=25 -ynh_install_app_dependencies "libav-tools|ffmpeg" php-cli +ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE A MYSQL DATABASE @@ -63,8 +63,9 @@ ynh_install_app_dependencies "libav-tools|ffmpeg" php-cli ynh_script_progression --message="Creating a MySQL database..." db_name=$(ynh_sanitize_dbid --db_name=$app) +db_user=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_mysql_setup_db --db_user=$db_name --db_name=$db_name +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -109,7 +110,7 @@ ynh_script_progression --message="Preconfiguring ampache..." --weight=2 conf_file="$final_path/config/ampache.cfg.php" cp ../conf/ampache.cfg.php "$conf_file" -ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$conf_file" +ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_user" --target_file="$conf_file" ynh_replace_string --match_string="__DBPWD__" --replace_string="$db_pwd" --target_file="$conf_file" ynh_replace_string --match_string="__DBNAME__" --replace_string="$db_name" --target_file="$conf_file" ynh_replace_string --match_string="__PATHTOCHANGE__" --replace_string="$path_url" --target_file="$conf_file" diff --git a/scripts/remove b/scripts/remove index 71899c1..7fd7240 100644 --- a/scripts/remove +++ b/scripts/remove @@ -18,6 +18,7 @@ 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) +db_user=$db_name final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= @@ -28,7 +29,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) ynh_script_progression --message="Removing the MySQL database..." --weight=3 # Remove a database if it exists, along with the associated user -ynh_mysql_remove_db --db_user=$db_name --db_name=$db_name +ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE DEPENDENCIES diff --git a/scripts/restore b/scripts/restore index b386bcf..43720a7 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers #================================================= @@ -25,6 +26,7 @@ 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) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -79,7 +81,7 @@ ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=30 -ynh_install_app_dependencies ffmpeg +ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE MYSQL DATABASE @@ -87,8 +89,8 @@ ynh_install_app_dependencies ffmpeg ynh_script_progression --message="Restoring the MySQL database..." --weight=5 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 +ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index ff7ede6..b3485e8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,6 +20,7 @@ admin_ampache=$(ynh_app_setting_get --app=$app --key=admin) is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) +db_user=$db_name secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) #================================================= @@ -52,6 +53,7 @@ fi 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 + db_user=$db_name fi # If final_path doesn't exist, create it @@ -114,7 +116,7 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Upgrading dependencies..." --weight=5 -ynh_install_app_dependencies ffmpeg php-cli +ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER @@ -145,7 +147,7 @@ then conf_file="$final_path/config/ampache.cfg.php" ynh_backup_if_checksum_is_different --file="$conf_file" - ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_name" --target_file="$conf_file" + ynh_replace_string --match_string="__DBUSER__" --replace_string="$db_user" --target_file="$conf_file" db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) ynh_replace_string --match_string="__DBPWD__" --replace_string="$db_pwd" --target_file="$conf_file" ynh_replace_string --match_string="__DBNAME__" --replace_string="$db_name" --target_file="$conf_file" From aa56c4149325316758e1c034ea960e5b3f7bca19 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 15 Apr 2020 21:39:41 +0200 Subject: [PATCH 08/24] reapply ynh_composer__2 --- scripts/_common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index a43d509..52cf8dd 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -26,7 +26,7 @@ ynh_composer_exec () { # Manage arguments with getopts ynh_handle_getopts_args "$@" workdir="${workdir:-$final_path}" - phpversion="${phpversion:-7.3}" + phpversion="${phpversion:-7.0}" COMPOSER_HOME="$workdir/.composer" \ php${phpversion} "$workdir/composer.phar" $commands \ @@ -46,7 +46,7 @@ ynh_install_composer () { # Manage arguments with getopts ynh_handle_getopts_args "$@" workdir="${workdir:-$final_path}" - phpversion="${phpversion:-7.3}" + phpversion="${phpversion:-7.0}" curl -sS https://getcomposer.org/installer \ | COMPOSER_HOME="$workdir/.composer" \ From 1755bc82f54a95ce878802febda18c37d05a0112 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 16 Apr 2020 00:19:43 +0200 Subject: [PATCH 09/24] upgrade to current master + PHP7.3 --- README.md | 2 +- conf/app.src | 4 +- conf/nginx.conf | 2 +- conf/php-fpm.conf | 4 +- manifest.json | 4 +- scripts/_common.sh | 377 ++++++++++++++++++++++++++++++++++++++++++++- scripts/backup | 2 +- scripts/install | 15 +- scripts/remove | 9 ++ scripts/restore | 15 +- scripts/upgrade | 24 ++- 11 files changed, 441 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 92ca0a9..721fc33 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to streaming application and file manager allowing you to access your music & videos from anywhere, using almost any internet enabled device. -**Shipped version:** 3.9.0 +**Shipped version:** 4.1.1.1 ## Screenshots diff --git a/conf/app.src b/conf/app.src index 1867c90..0d2dafa 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/ampache/ampache/archive/3.9.0.tar.gz -SOURCE_SUM=1e523b52c6402693102dac183d7597d6e0aebf63580167f45661d0f15f57c072 +SOURCE_URL=https://github.com/ampache/ampache/archive/f9ea16e7fc7a36636180241dc79f139b92bc8ff0.tar.gz +SOURCE_SUM=9cee154350b3b747b4ec6d405be768e8a3b0b1f0331a9f373c6a7c54c51f4775 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/nginx.conf b/conf/nginx.conf index 7f2ea52..617ce05 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -17,7 +17,7 @@ location __PATH__/ { try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php7.0-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php7.3-fpm-__NAME__.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index ab5dca9..0b589bb 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -33,7 +33,7 @@ group = __USER__ ; (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/php/php7.0-fpm-__NAMETOCHANGE__.sock +listen = /var/run/php/php7.3-fpm-__NAMETOCHANGE__.sock ; Set listen(2) backlog. ; Default Value: 511 (-1 on FreeBSD and OpenBSD) @@ -229,7 +229,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/7.0/fpm/status.html +; It's available in: /usr/share/php/7.3/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 diff --git a/manifest.json b/manifest.json index 40ade8d..bb15f01 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "A web based audio/video streaming application", "fr": "Une application de streaming audio et vidéo" }, - "version": "3.9.0~ynh2", + "version": "4.1.1.1~ynh1", "url": "http://ampache.org", "license": "AGPL-3.0", "maintainer": { @@ -19,7 +19,7 @@ "multi_instance": true, "services" : [ "nginx", - "php7.0-fpm", + "php7.3-fpm", "mysql" ], "arguments": { diff --git a/scripts/_common.sh b/scripts/_common.sh index 52cf8dd..a1d23dc 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,10 @@ #================================================= # dependencies used by the app -pkg_dependencies="libav-tools|ffmpeg php-cli" +pkg_dependencies="libav-tools|ffmpeg" + +extra_pkg_dependencies="" +# php7.3-gmp php7.3-dom php7.3-pcre php7.3-spl php7.3-simplexml php7.3-ctype php7.3-date php7.3-iconv php7.3-curl php7.3-gd php7.3-mbstring php7.3-libxml php7.3-xmlwriter php7.3-xmlreader #================================================= # EXPERIMENTAL HELPERS @@ -58,6 +61,378 @@ ynh_install_composer () { || ynh_die "Unable to update core dependencies with Composer." } +# 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}" +} + +# Install another version of php. +# +# usage: ynh_install_php --phpversion=phpversion [--package=packages] +# | arg: -v, --phpversion - Version of php to install. Can be one of 7.1, 7.2 or 7.3 +# | 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 php_version into the config of this app + ynh_app_setting_set $app php_version $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\"" 200 --name=extra_php_version + ynh_pin_repo --package="php7.0*" --pin="origin \"packages.sury.org\"" 600 --name=extra_php_version --append + + # INTEGRATE SERVICE IN YUNOHOST + yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log" +} + +ynh_remove_php () { + # Get the version of php used by this app + local phpversion=$(ynh_app_setting_get $app php_version) + + 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 #================================================= diff --git a/scripts/backup b/scripts/backup index 13a0d3e..c1b2822 100644 --- a/scripts/backup +++ b/scripts/backup @@ -48,7 +48,7 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= ynh_script_progression --message="Backing up php-fpm configuration..." -ynh_backup --src_path="/etc/php/7.0/fpm/pool.d/$app.conf" +ynh_backup --src_path="/etc/php/7.3/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE diff --git a/scripts/install b/scripts/install index c84817b..f1d3743 100644 --- a/scripts/install +++ b/scripts/install @@ -50,6 +50,17 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= # STANDARD MODIFICATIONS +#================================================= +# INSTALL PHP7.3 +#================================================= + +if [ "$(lsb_release --codename --short)" = "buster" ]; then + pkg_dependencies="$pkg_dependencies $extra_pkg_dependencies" +else + ynh_print_info --message="Installing PHP7.3..." + ynh_install_php --phpversion="7.3" --package="$extra_pkg_dependencies" +fi + #================================================= # INSTALL DEPENDENCIES #================================================= @@ -135,9 +146,9 @@ ynh_mysql_connect_as --user=$app --password="$db_pwd" --database=$app < "$final_ ynh_script_progression --message="Installing ampache with composer..." --weight=45 # Install composer -ynh_install_composer +ynh_install_composer --phpversion="7.3" --workdir="$final_path" -ynh_exec_warn_less ynh_composer_exec --commands=\"install --prefer-source --no-dev\" +ynh_exec_warn_less ynh_composer_exec --phpversion="7.3" --workdir=$final_path --commands=\"install --prefer-source --no-dev\" #================================================= # INSTALL MULTIMEDIA DIRECTORIES diff --git a/scripts/remove b/scripts/remove index 7fd7240..531b3d4 100644 --- a/scripts/remove +++ b/scripts/remove @@ -31,6 +31,15 @@ ynh_script_progression --message="Removing the MySQL database..." --weight=3 # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name +#================================================= +# REMOVE PHP +#================================================= + +if [ "$(lsb_release --codename --short)" != "buster" ]; then + ynh_print_info --message="Removing php..." + ynh_remove_php +fi + #================================================= # REMOVE DEPENDENCIES #================================================= diff --git a/scripts/restore b/scripts/restore index 43720a7..43fcec2 100644 --- a/scripts/restore +++ b/scripts/restore @@ -72,10 +72,21 @@ chown -R $app: $final_path # RESTORE THE PHP-FPM CONFIGURATION #================================================= -ynh_restore_file --origin_path="/etc/php/7.0/fpm/pool.d/$app.conf" +ynh_restore_file --origin_path="/etc/php/7.3/fpm/pool.d/$app.conf" #================================================= # SPECIFIC RESTORATION +#================================================= +# REINSTALL PHP7.3 +#================================================= + +if [ "$(lsb_release --codename --short)" = "buster" ]; then + pkg_dependencies="$pkg_dependencies $extra_pkg_dependencies" +else + ynh_print_info --message="Reinstalling PHP7.3..." + ynh_install_php --phpversion="7.3" --package="$extra_pkg_dependencies" +fi + #================================================= # REINSTALL DEPENDENCIES #================================================= @@ -99,7 +110,7 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./ #================================================= ynh_script_progression --message="Reloading nginx web server and php-fpm..." -ynh_systemd_action --service_name=php7.0-fpm --action=reload +ynh_systemd_action --service_name=php7.3-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b3485e8..ca2cb18 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -111,6 +111,24 @@ ynh_script_progression --message="Upgrading nginx web server configuration..." - # Create a dedicated nginx config ynh_add_nginx_config +#================================================= +# UPGRADE PHP7.3 +#================================================= + +if [ "$(lsb_release --codename --short)" = "buster" ]; then + pkg_dependencies="$pkg_dependencies $extra_pkg_dependencies" +else + if [ "$(ynh_app_setting_get --app=$app --key=php_version)" != "7.3" ]; then + ynh_print_info --message="Upgrading PHP7.3..." + ynh_remove_fpm_config + ynh_remove_app_dependencies + ynh_remove_php + ynh_install_php --phpversion="7.3" --package="$extra_pkg_dependencies" + else + ynh_install_php --phpversion="7.3" --package="$extra_pkg_dependencies" + fi +fi + #================================================= # UPGRADE DEPENDENCIES #================================================= @@ -164,10 +182,10 @@ then ynh_script_progression --message="Upgrading ampache with composer..." --weight=30 # Install composer - ynh_install_composer + ynh_install_composer --phpversion="7.3" --workdir="$final_path" - ynh_composer_exec --commands="config discard-changes true" - ynh_composer_exec --commands="update --prefer-source --no-interaction --no-dev" + ynh_composer_exec --phpversion="7.3" --workdir=$final_path --commands="config discard-changes true" + ynh_composer_exec --phpversion="7.3" --workdir=$final_path --commands="update --prefer-source --no-interaction --no-dev" fi #================================================= From a61bf18c05a49890951622b823946bbb464ddd42 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 16 Apr 2020 19:57:35 +0200 Subject: [PATCH 10/24] correct services --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index bb15f01..8316766 100644 --- a/manifest.json +++ b/manifest.json @@ -19,7 +19,7 @@ "multi_instance": true, "services" : [ "nginx", - "php7.3-fpm", + "php7.0-fpm", "mysql" ], "arguments": { From 73236293137a12e1d643e0d0dfda687bb636cc58 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 16 Apr 2020 20:22:27 +0200 Subject: [PATCH 11/24] Missing phpversion for ynh_add_fpm_config --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index f1d3743..bbc6e88 100644 --- a/scripts/install +++ b/scripts/install @@ -109,7 +109,7 @@ ynh_system_user_create --username=$app ynh_script_progression --message="Configuring php-fpm..." # Create a dedicated php-fpm config -ynh_add_fpm_config +ynh_add_fpm_config --phpversion="7.3" #================================================= # SPECIFIC SETUP diff --git a/scripts/upgrade b/scripts/upgrade index ca2cb18..dec2b79 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -150,7 +150,7 @@ ynh_system_user_create --username=$app ynh_script_progression --message="Upgrading php-fpm configuration..." --weight=2 # Create a dedicated php-fpm config -ynh_add_fpm_config +ynh_add_fpm_config --phpversion="7.3" #================================================= # SPECIFIC UPGRADE From 08418528d3018e51469a4fc751b3a2cf778647cf Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 16 Apr 2020 20:33:10 +0200 Subject: [PATCH 12/24] fixing prerequisites --- conf/php-fpm.conf | 4 ++-- scripts/_common.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf index 0b589bb..aeb2cc3 100644 --- a/conf/php-fpm.conf +++ b/conf/php-fpm.conf @@ -419,8 +419,8 @@ chdir = __FINALPATH__ ;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_value[upload_max_filesize] = 50M +php_admin_value[post_max_size] = 50M ; php_admin_flag[mail.add_x_header] = Off ; Other common parameters diff --git a/scripts/_common.sh b/scripts/_common.sh index a1d23dc..2cfd710 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,7 +7,7 @@ # dependencies used by the app pkg_dependencies="libav-tools|ffmpeg" -extra_pkg_dependencies="" +extra_pkg_dependencies="php7.3-mysql php7.3-curl php7.3-simplexml php7.3-gd" # php7.3-gmp php7.3-dom php7.3-pcre php7.3-spl php7.3-simplexml php7.3-ctype php7.3-date php7.3-iconv php7.3-curl php7.3-gd php7.3-mbstring php7.3-libxml php7.3-xmlwriter php7.3-xmlreader #================================================= From cef8c2f1f090cd894f5bf533c7758651a92ba820 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 16 Apr 2020 20:33:27 +0200 Subject: [PATCH 13/24] Upgrade to 4.1.1 --- README.md | 2 +- conf/app.src | 4 ++-- manifest.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 721fc33..b8445ad 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to streaming application and file manager allowing you to access your music & videos from anywhere, using almost any internet enabled device. -**Shipped version:** 4.1.1.1 +**Shipped version:** 4.1.1 ## Screenshots diff --git a/conf/app.src b/conf/app.src index 0d2dafa..d7c2324 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/ampache/ampache/archive/f9ea16e7fc7a36636180241dc79f139b92bc8ff0.tar.gz -SOURCE_SUM=9cee154350b3b747b4ec6d405be768e8a3b0b1f0331a9f373c6a7c54c51f4775 +SOURCE_URL=https://github.com/ampache/ampache/archive/4.1.1.tar.gz +SOURCE_SUM=48ff858484194a4949702946ccad542316f1c7c67045193167f8e215ab8a6385 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 8316766..48ae057 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "A web based audio/video streaming application", "fr": "Une application de streaming audio et vidéo" }, - "version": "4.1.1.1~ynh1", + "version": "4.1.1~ynh1", "url": "http://ampache.org", "license": "AGPL-3.0", "maintainer": { From 5f967aa1c24cc072401328abb146112cf193c33e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 16 Apr 2020 21:03:07 +0200 Subject: [PATCH 14/24] Going back to a releases dropbox/dropbox-sdk is not available and has been removed --- README.md | 2 +- conf/app.src | 4 ++-- manifest.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b8445ad..721fc33 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to streaming application and file manager allowing you to access your music & videos from anywhere, using almost any internet enabled device. -**Shipped version:** 4.1.1 +**Shipped version:** 4.1.1.1 ## Screenshots diff --git a/conf/app.src b/conf/app.src index d7c2324..0d2dafa 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/ampache/ampache/archive/4.1.1.tar.gz -SOURCE_SUM=48ff858484194a4949702946ccad542316f1c7c67045193167f8e215ab8a6385 +SOURCE_URL=https://github.com/ampache/ampache/archive/f9ea16e7fc7a36636180241dc79f139b92bc8ff0.tar.gz +SOURCE_SUM=9cee154350b3b747b4ec6d405be768e8a3b0b1f0331a9f373c6a7c54c51f4775 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 48ae057..8316766 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "A web based audio/video streaming application", "fr": "Une application de streaming audio et vidéo" }, - "version": "4.1.1~ynh1", + "version": "4.1.1.1~ynh1", "url": "http://ampache.org", "license": "AGPL-3.0", "maintainer": { From 1c14538608df8891cd75f4a1d53640130c445e4b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 21 Apr 2020 12:39:49 +0200 Subject: [PATCH 15/24] removing not needed parameter --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index dec2b79..0a99fad 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -185,7 +185,7 @@ then ynh_install_composer --phpversion="7.3" --workdir="$final_path" ynh_composer_exec --phpversion="7.3" --workdir=$final_path --commands="config discard-changes true" - ynh_composer_exec --phpversion="7.3" --workdir=$final_path --commands="update --prefer-source --no-interaction --no-dev" + ynh_composer_exec --phpversion="7.3" --workdir=$final_path --commands="update --prefer-source --no-dev" fi #================================================= From 6a9c02b56eb41fcba28d55d2672da3a562c4447e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 25 Apr 2020 19:03:49 +0200 Subject: [PATCH 16/24] Composer cleanup --- scripts/_common.sh | 15 ++++++++++----- scripts/install | 4 +--- scripts/upgrade | 4 +--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 2cfd710..d96115d 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -16,7 +16,8 @@ extra_pkg_dependencies="php7.3-mysql php7.3-curl php7.3-simplexml php7.3-gd" # Execute a command with Composer # -# usage: ynh_composer_exec --phpversion=phpversion [--workdir=$final_path] --commands="commands" +# usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands" +# | arg: -v, --phpversion - PHP version to use with composer # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. # | arg: -c, --commands - Commands to execute. ynh_composer_exec () { @@ -38,18 +39,22 @@ ynh_composer_exec () { # Install and initialize Composer in the given directory # -# usage: ynh_install_composer --phpversion=phpversion [--workdir=$final_path] +# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"] +# | arg: -v, --phpversion - PHP version to use with composer # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. +# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include ynh_install_composer () { # Declare an array to define the options of this helper. - local legacy_args=vw - declare -Ar args_array=( [v]=phpversion= [w]=workdir= ) + local legacy_args=vwa + declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args=) local phpversion local workdir + local install_args # Manage arguments with getopts ynh_handle_getopts_args "$@" workdir="${workdir:-$final_path}" phpversion="${phpversion:-7.0}" + install_args="${install_args:-}" curl -sS https://getcomposer.org/installer \ | COMPOSER_HOME="$workdir/.composer" \ @@ -57,7 +62,7 @@ ynh_install_composer () { || ynh_die "Unable to install Composer." # update dependencies to create composer.lock - ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \ + ynh_composer_exec --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \ || ynh_die "Unable to update core dependencies with Composer." } diff --git a/scripts/install b/scripts/install index bbc6e88..7a4556b 100644 --- a/scripts/install +++ b/scripts/install @@ -146,9 +146,7 @@ ynh_mysql_connect_as --user=$app --password="$db_pwd" --database=$app < "$final_ ynh_script_progression --message="Installing ampache with composer..." --weight=45 # Install composer -ynh_install_composer --phpversion="7.3" --workdir="$final_path" - -ynh_exec_warn_less ynh_composer_exec --phpversion="7.3" --workdir=$final_path --commands=\"install --prefer-source --no-dev\" +ynh_install_composer --phpversion="7.3" --workdir="$final_path" --install_args="--prefer-source --no-dev" #================================================= # INSTALL MULTIMEDIA DIRECTORIES diff --git a/scripts/upgrade b/scripts/upgrade index 0a99fad..e5640f9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -182,10 +182,8 @@ then ynh_script_progression --message="Upgrading ampache with composer..." --weight=30 # Install composer - ynh_install_composer --phpversion="7.3" --workdir="$final_path" - + ynh_install_composer --phpversion="7.3" --workdir="$final_path" --install_args="--prefer-source --no-dev" ynh_composer_exec --phpversion="7.3" --workdir=$final_path --commands="config discard-changes true" - ynh_composer_exec --phpversion="7.3" --workdir=$final_path --commands="update --prefer-source --no-dev" fi #================================================= From ada337e6d18bb3dc7dc4fd36cfc50cfd71c30e54 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 3 May 2020 20:30:28 +0200 Subject: [PATCH 17/24] Update check_process --- check_process | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/check_process b/check_process index cbba2de..decb468 100644 --- a/check_process +++ b/check_process @@ -12,7 +12,8 @@ setup_private=1 setup_public=1 upgrade=1 - upgrade=1 from_commit=11caf9791c48fdcd632193a1c82ea52d4819b328 + # 3.9.0 + upgrade=1 from_commit=95bd803a7fd9670f3ba55afb43d4e942de677e0a backup_restore=1 multi_instance=1 incorrect_path=1 From 9517b7537e05f32a70b0c09d9b961512e4bbe91d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 11 May 2020 23:10:49 +0200 Subject: [PATCH 18/24] Remove upgrade from previous not working version --- check_process | 2 -- 1 file changed, 2 deletions(-) diff --git a/check_process b/check_process index decb468..441ae83 100644 --- a/check_process +++ b/check_process @@ -12,8 +12,6 @@ setup_private=1 setup_public=1 upgrade=1 - # 3.9.0 - upgrade=1 from_commit=95bd803a7fd9670f3ba55afb43d4e942de677e0a backup_restore=1 multi_instance=1 incorrect_path=1 From b72f75e1bf2c9c5b73625983a0adbeb2f5821c9b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 03:24:25 +0200 Subject: [PATCH 19/24] moving to YunoHost 3.8 --- manifest.json | 2 +- scripts/_common.sh | 372 --------------------------------------------- 2 files changed, 1 insertion(+), 373 deletions(-) diff --git a/manifest.json b/manifest.json index 8316766..509b877 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "aymhce@gmail.com" }, "requirements": { - "yunohost": ">= 3.5" + "yunohost": ">= 3.8" }, "multi_instance": true, "services" : [ diff --git a/scripts/_common.sh b/scripts/_common.sh index d96115d..9232f47 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -66,378 +66,6 @@ ynh_install_composer () { || ynh_die "Unable to update core dependencies with Composer." } -# 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}" -} - -# Install another version of php. -# -# usage: ynh_install_php --phpversion=phpversion [--package=packages] -# | arg: -v, --phpversion - Version of php to install. Can be one of 7.1, 7.2 or 7.3 -# | 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 php_version into the config of this app - ynh_app_setting_set $app php_version $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\"" 200 --name=extra_php_version - ynh_pin_repo --package="php7.0*" --pin="origin \"packages.sury.org\"" 600 --name=extra_php_version --append - - # INTEGRATE SERVICE IN YUNOHOST - yunohost service add php${phpversion}-fpm --log "/var/log/php${phpversion}-fpm.log" -} - -ynh_remove_php () { - # Get the version of php used by this app - local phpversion=$(ynh_app_setting_get $app php_version) - - 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 c3486030252b66871b3db95725201e71ee6f5290 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 03:32:42 +0200 Subject: [PATCH 20/24] Update check_process --- check_process | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/check_process b/check_process index 441ae83..ddc484f 100644 --- a/check_process +++ b/check_process @@ -14,9 +14,12 @@ upgrade=1 backup_restore=1 multi_instance=1 - incorrect_path=1 + # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. + # incorrect_path=1 + port_already_use=0 change_url=1 ;;; Levels + # If the level 5 (Package linter) is forced to 1. Please add justifications here. Level 5=auto ;;; Options Email=aymhce@gmail.com From 8f4ddde5277f24d075885ef2e7f63d72e2f40ab4 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 15:56:04 +0200 Subject: [PATCH 21/24] Apply last example_ynh --- scripts/backup | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/backup b/scripts/backup index c1b2822..cd4a549 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +#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 @@ -28,27 +29,27 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= -# STANDARD BACKUP STEPS +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_script_progression --message="Declaring files to be backed up..." + #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_script_progression --message="Backing up the main app directory..." ynh_backup --src_path="$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" #================================================= # BACKUP THE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Backing up php-fpm configuration..." -ynh_backup --src_path="/etc/php/7.3/fpm/pool.d/$app.conf" +ynh_backup --src_path="/etc/php/${YNH_PHP_VERSION}/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE From f137f8213873699a4b53e47dbe378ee17128d476 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 15:58:48 +0200 Subject: [PATCH 22/24] fix upgrade implmenting new helper from 3.8 --- conf/nginx.conf | 3 +- conf/php-fpm.conf | 430 --------------------------------------------- manifest.json | 2 +- scripts/_common.sh | 14 +- scripts/install | 19 +- scripts/remove | 9 - scripts/restore | 23 ++- scripts/upgrade | 31 +--- 8 files changed, 34 insertions(+), 497 deletions(-) delete mode 100644 conf/php-fpm.conf diff --git a/conf/nginx.conf b/conf/nginx.conf index 617ce05..8171468 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -17,7 +17,8 @@ location __PATH__/ { try_files $uri $uri/ index.php; location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php7.3-fpm-__NAME__.sock; + fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; + fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; diff --git a/conf/php-fpm.conf b/conf/php-fpm.conf deleted file mode 100644 index aeb2cc3..0000000 --- a/conf/php-fpm.conf +++ /dev/null @@ -1,430 +0,0 @@ -; Start a new pool named 'www'. -; 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' -; - 'chdir' -; - 'php_values' -; - 'php_admin_values' -; When not set, the global prefix (or /usr) applies instead. -; Note: This directive can also be relative to the global prefix. -; Default Value: none -;prefix = /path/to/pools/$pool - -; Unix user/group of processes -; Note: The user is mandatory. If the group is not set, the default user's group -; will be used. -user = __USER__ -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 -; 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/php/php7.3-fpm-__NAMETOCHANGE__.sock - -; 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 -; 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 -; 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. -; 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 -; accepted from any ip address. -; Default Value: any -;listen.allowed_clients = 127.0.0.1 - -; Specify the nice(2) priority to apply to the pool processes (only if set) -; The value can vary from -19 (highest priority) to 20 (lower priority) -; Note: - It will only work if the FPM master process is launched as root -; - 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 - -; Choose how the process manager will control the number of child processes. -; Possible Values: -; static - a fixed number (pm.max_children) of child processes; -; dynamic - the number of child processes are set dynamically based on the -; following directives. With this process management, there will be -; always at least 1 children. -; pm.max_children - the maximum number of children that can -; be alive at the same time. -; pm.start_servers - the number of children created on startup. -; pm.min_spare_servers - the minimum number of children in 'idle' -; state (waiting to process). If the number -; of 'idle' processes is less than this -; number then some children will be created. -; pm.max_spare_servers - the maximum number of children in 'idle' -; state (waiting to process). If the number -; of 'idle' processes is greater than this -; number then some children will be killed. -; ondemand - no children are created at startup. Children will be forked when -; new requests will connect. The following parameter are used: -; pm.max_children - the maximum number of children that -; can be alive at the same time. -; pm.process_idle_timeout - The number of seconds after which -; an idle process will be killed. -; Note: This value is mandatory. -pm = dynamic - -; The number of child processes to be created when pm is set to 'static' and the -; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. -; This value sets the limit on the number of simultaneous requests that will be -; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. -; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP -; CGI. The below defaults are based on a server without much resources. Don't -; forget to tweak pm.* to fit your needs. -; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' -; Note: This value is mandatory. -pm.max_children = 5 - -; The number of child processes created on startup. -; Note: Used only when pm is set to 'dynamic' -; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 -pm.start_servers = 2 - -; The desired minimum number of idle server processes. -; Note: Used only when pm is set to 'dynamic' -; Note: Mandatory when pm is set to 'dynamic' -pm.min_spare_servers = 1 - -; The desired maximum number of idle server processes. -; Note: Used only when pm is set to 'dynamic' -; Note: Mandatory when pm is set to 'dynamic' -pm.max_spare_servers = 3 - -; The number of seconds after which an idle process will be killed. -; 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. -; Default Value: 0 -;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: -; pool - the name of the pool; -; process manager - static, dynamic or ondemand; -; start time - the date and time FPM has started; -; start since - number of seconds since FPM has started; -; accepted conn - the number of request accepted by the pool; -; listen queue - the number of request in the queue of pending -; connections (see backlog in listen(2)); -; max listen queue - the maximum number of requests in the queue -; of pending connections since FPM has started; -; listen queue len - the size of the socket queue of pending connections; -; idle processes - the number of idle processes; -; active processes - the number of active processes; -; total processes - the number of idle + active processes; -; max active processes - the maximum number of active processes since FPM -; has started; -; max children reached - number of times, the process limit has been reached, -; when pm tries to start more children (works only for -; pm 'dynamic' and 'ondemand'); -; Value are updated in real time. -; Example output: -; pool: www -; process manager: static -; start time: 01/Jul/2011:17:53:49 +0200 -; start since: 62636 -; accepted conn: 190460 -; listen queue: 0 -; max listen queue: 1 -; listen queue len: 42 -; idle processes: 4 -; active processes: 11 -; total processes: 15 -; max active processes: 12 -; max children reached: 0 -; -; By default the status page output is formatted as text/plain. Passing either -; 'html', 'xml' or 'json' in the query string will return the corresponding -; output syntax. Example: -; http://www.foo.bar/status -; http://www.foo.bar/status?json -; http://www.foo.bar/status?html -; http://www.foo.bar/status?xml -; -; By default the status page only outputs short status. Passing 'full' in the -; query string will also return status for each pool process. -; Example: -; http://www.foo.bar/status?full -; http://www.foo.bar/status?json&full -; http://www.foo.bar/status?html&full -; http://www.foo.bar/status?xml&full -; The Full status returns for each process: -; pid - the PID of the process; -; state - the state of the process (Idle, Running, ...); -; start time - the date and time the process has started; -; start since - the number of seconds since the process has started; -; requests - the number of requests the process has served; -; request duration - the duration in µs of the requests; -; request method - the request method (GET, POST, ...); -; request URI - the request URI with the query string; -; content length - the content length of the request (only with POST); -; user - the user (PHP_AUTH_USER) (or '-' if not set); -; script - the main script called (or '-' if not set); -; last request cpu - the %cpu the last request consumed -; it's always 0 if the process is not in Idle state -; because CPU calculation is done when the request -; processing has terminated; -; last request memory - the max amount of memory the last request consumed -; it's always 0 if the process is not in Idle state -; because memory calculation is done when the request -; processing has terminated; -; If the process is in Idle state, then informations are related to the -; last request the process has served. Otherwise informations are related to -; the current request being served. -; Example output: -; ************************ -; pid: 31330 -; state: Running -; start time: 01/Jul/2011:17:53:49 +0200 -; start since: 63087 -; requests: 12808 -; request duration: 1250261 -; request method: GET -; request URI: /test_mem.php?N=10000 -; content length: 0 -; user: - -; script: /home/fat/web/docs/php/test_mem.php -; last request cpu: 0.00 -; last request memory: 0 -; -; Note: There is a real-time FPM status monitoring sample web page available -; It's available in: /usr/share/php/7.3/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 -; may conflict with a real PHP file. -; Default Value: not set -;pm.status_path = /status - -; The ping URI to call the monitoring page of FPM. If this value is not set, no -; URI will be recognized as a ping page. This could be used to test from outside -; that FPM is alive and responding, or to -; - create a graph of FPM availability (rrd or such); -; - remove a server from a group if it is not responding (load balancing); -; - trigger alerts for the operating team (24/7). -; 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 -; may conflict with a real PHP file. -; Default Value: not set -;ping.path = /ping - -; This directive may be used to customize the response of a ping request. The -; response is formatted as text/plain with a 200 response code. -; Default Value: pong -;ping.response = pong - -; The access log file -; Default: not set -;access.log = log/$pool.access.log - -; The access log format. -; The following syntax is allowed -; %%: the '%' character -; %C: %CPU used by the request -; it can accept the following format: -; - %{user}C for user CPU only -; - %{system}C for system CPU only -; - %{total}C for user + system CPU (default) -; %d: time taken to serve the request -; it can accept the following format: -; - %{seconds}d (default) -; - %{miliseconds}d -; - %{mili}d -; - %{microseconds}d -; - %{micro}d -; %e: an environment variable (same as $_ENV or $_SERVER) -; it must be associated with embraces to specify the name of the env -; variable. Some exemples: -; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e -; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e -; %f: script filename -; %l: content-length of the request (for POST request only) -; %m: request method -; %M: peak of memory allocated by PHP -; it can accept the following format: -; - %{bytes}M (default) -; - %{kilobytes}M -; - %{kilo}M -; - %{megabytes}M -; - %{mega}M -; %n: pool name -; %o: output header -; it must be associated with embraces to specify the name of the header: -; - %{Content-Type}o -; - %{X-Powered-By}o -; - %{Transfert-Encoding}o -; - .... -; %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 '?' character if query string exists -; %r: the request URI (without the query string, see %q and %Q) -; %R: remote IP address -; %s: status (response code) -; %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" -;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 = 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 = 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 -; 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 -; possible. However, all PHP paths will be relative to the chroot -; (error_log, sessions.save_path, ...). -; Default Value: not set -;chroot = - -; Chdir to this directory at the start. -; Note: relative path can be used. -; Default Value: current directory or / when chroot -chdir = __FINALPATH__ - -; Redirect worker stdout and stderr into main error log. If not set, stdout and -; stderr will be redirected to /dev/null according to FastCGI specs. -; 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 - -; 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. -; Note: set an empty value to allow all extensions. -; Default Value: .php -;security.limit_extensions = .php .php3 .php4 .php5 .php7 - -; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from -; the current environment. -; Default Value: clean env -;env[HOSTNAME] = $HOSTNAME -;env[PATH] = /usr/local/bin:/usr/bin:/bin -;env[TMP] = /tmp -;env[TMPDIR] = /tmp -;env[TEMP] = /tmp - -; 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: -; php_value/php_flag - you can set classic ini defines which can -; 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. - -; Defining 'extension' will load the corresponding shared extension from -; extension_dir. Defining 'disable_functions' or 'disable_classes' will not -; overwrite previously defined php.ini values, but will append the new value -; instead. - -; Note: path INI options can be relative and will be expanded with the prefix -; (pool, global or /usr) - -; Default Value: nothing is defined by default except the values in php.ini and -; specified at startup with the -d argument -;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com -;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 diff --git a/manifest.json b/manifest.json index 509b877..3638c5b 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "aymhce@gmail.com" }, "requirements": { - "yunohost": ">= 3.8" + "yunohost": ">= 3.8.1" }, "multi_instance": true, "services" : [ diff --git a/scripts/_common.sh b/scripts/_common.sh index 9232f47..c34792c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,8 +7,9 @@ # dependencies used by the app pkg_dependencies="libav-tools|ffmpeg" -extra_pkg_dependencies="php7.3-mysql php7.3-curl php7.3-simplexml php7.3-gd" -# php7.3-gmp php7.3-dom php7.3-pcre php7.3-spl php7.3-simplexml php7.3-ctype php7.3-date php7.3-iconv php7.3-curl php7.3-gd php7.3-mbstring php7.3-libxml php7.3-xmlwriter php7.3-xmlreader +YNH_PHP_VERSION="7.3" + +extra_php_dependencies="php${YNH_PHP_VERSION}mysql php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-simplexml php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-ldap" #================================================= # EXPERIMENTAL HELPERS @@ -16,8 +17,7 @@ extra_pkg_dependencies="php7.3-mysql php7.3-curl php7.3-simplexml php7.3-gd" # Execute a command with Composer # -# usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands" -# | arg: -v, --phpversion - PHP version to use with composer +# usage: ynh_composer_exec --phpversion=phpversion [--workdir=$final_path] --commands="commands" # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. # | arg: -c, --commands - Commands to execute. ynh_composer_exec () { @@ -39,13 +39,12 @@ ynh_composer_exec () { # Install and initialize Composer in the given directory # -# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"] -# | arg: -v, --phpversion - PHP version to use with composer +# usage: ynh_install_composer --phpversion=phpversion [--workdir=$final_path] [--install_args="--optimize-autoloader"] # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. # | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include ynh_install_composer () { # Declare an array to define the options of this helper. - local legacy_args=vwa + local legacy_args=vw declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args=) local phpversion local workdir @@ -54,7 +53,6 @@ ynh_install_composer () { ynh_handle_getopts_args "$@" workdir="${workdir:-$final_path}" phpversion="${phpversion:-7.0}" - install_args="${install_args:-}" curl -sS https://getcomposer.org/installer \ | COMPOSER_HOME="$workdir/.composer" \ diff --git a/scripts/install b/scripts/install index 7a4556b..6d1613b 100644 --- a/scripts/install +++ b/scripts/install @@ -50,17 +50,6 @@ ynh_app_setting_set --app=$app --key=is_public --value=$is_public #================================================= # STANDARD MODIFICATIONS -#================================================= -# INSTALL PHP7.3 -#================================================= - -if [ "$(lsb_release --codename --short)" = "buster" ]; then - pkg_dependencies="$pkg_dependencies $extra_pkg_dependencies" -else - ynh_print_info --message="Installing PHP7.3..." - ynh_install_php --phpversion="7.3" --package="$extra_pkg_dependencies" -fi - #================================================= # INSTALL DEPENDENCIES #================================================= @@ -109,7 +98,7 @@ ynh_system_user_create --username=$app ynh_script_progression --message="Configuring php-fpm..." # Create a dedicated php-fpm config -ynh_add_fpm_config --phpversion="7.3" +ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies" #================================================= # SPECIFIC SETUP @@ -136,6 +125,7 @@ ynh_store_file_checksum --file="$conf_file" #================================================= # LOAD DEFAULT DATABASE #================================================= +ynh_script_progression --message="Loading default database..." # Load default ampache database ynh_mysql_connect_as --user=$app --password="$db_pwd" --database=$app < "$final_path/sql/ampache.sql" @@ -146,11 +136,12 @@ ynh_mysql_connect_as --user=$app --password="$db_pwd" --database=$app < "$final_ ynh_script_progression --message="Installing ampache with composer..." --weight=45 # Install composer -ynh_install_composer --phpversion="7.3" --workdir="$final_path" --install_args="--prefer-source --no-dev" +ynh_install_composer --phpversion="${YNH_PHP_VERSION}" --workdir="$final_path" --install_args="--prefer-source --no-dev" #================================================= # INSTALL MULTIMEDIA DIRECTORIES #================================================= +ynh_script_progression --message="Installing multimedia directories..." --weight=5 ynh_multimedia_build_main_dir @@ -173,6 +164,7 @@ sleep 1 #================================================= # LOAD ADMIN DATABASE #================================================= +ynh_script_progression --message="Loading admin database..." cp ../conf/admin.sql /tmp/ ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin_ampache" --target_file=/tmp/admin.sql @@ -186,6 +178,7 @@ ynh_secure_remove --file=/tmp/admin.sql #================================================= # SECURE FILES AND DIRECTORIES #================================================= +ynh_script_progression --message="Securing files and directories..." # Set permissions to ampache directory chown -R $app: $final_path diff --git a/scripts/remove b/scripts/remove index 531b3d4..7fd7240 100644 --- a/scripts/remove +++ b/scripts/remove @@ -31,15 +31,6 @@ ynh_script_progression --message="Removing the MySQL database..." --weight=3 # Remove a database if it exists, along with the associated user ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name -#================================================= -# REMOVE PHP -#================================================= - -if [ "$(lsb_release --codename --short)" != "buster" ]; then - ynh_print_info --message="Removing php..." - ynh_remove_php -fi - #================================================= # REMOVE DEPENDENCIES #================================================= diff --git a/scripts/restore b/scripts/restore index 43fcec2..79e40e7 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,6 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= +#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 @@ -43,6 +44,7 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= +ynh_script_progression --message="Restoring the nginx configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -64,6 +66,7 @@ ynh_system_user_create --username=$app #================================================= # RESTORE USER RIGHTS #================================================= +ynh_script_progression --message="Restoring user rights..." # Restore permissions on app files chown -R $app: $final_path @@ -71,27 +74,21 @@ chown -R $app: $final_path #================================================= # RESTORE THE PHP-FPM CONFIGURATION #================================================= +ynh_script_progression --message="Restoring PHP-FPM configuration..." -ynh_restore_file --origin_path="/etc/php/7.3/fpm/pool.d/$app.conf" +ynh_restore_file --origin_path="/etc/php/${YNH_PHP_VERSION}/fpm/pool.d/$app.conf" + +# Recreate a dedicated php-fpm config +ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies" #================================================= # SPECIFIC RESTORATION -#================================================= -# REINSTALL PHP7.3 -#================================================= - -if [ "$(lsb_release --codename --short)" = "buster" ]; then - pkg_dependencies="$pkg_dependencies $extra_pkg_dependencies" -else - ynh_print_info --message="Reinstalling PHP7.3..." - ynh_install_php --phpversion="7.3" --package="$extra_pkg_dependencies" -fi - #================================================= # REINSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=30 +# Define and install dependencies ynh_install_app_dependencies $pkg_dependencies #================================================= @@ -110,7 +107,7 @@ ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./ #================================================= ynh_script_progression --message="Reloading nginx web server and php-fpm..." -ynh_systemd_action --service_name=php7.3-fpm --action=reload +ynh_systemd_action --service_name=php${YNH_PHP_VERSION}-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index e5640f9..94244fd 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,5 +1,7 @@ #!/bin/bash +#================================================= +# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -26,6 +28,7 @@ secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) #================================================= # CHECK VERSION #================================================= +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) @@ -111,24 +114,6 @@ ynh_script_progression --message="Upgrading nginx web server configuration..." - # Create a dedicated nginx config ynh_add_nginx_config -#================================================= -# UPGRADE PHP7.3 -#================================================= - -if [ "$(lsb_release --codename --short)" = "buster" ]; then - pkg_dependencies="$pkg_dependencies $extra_pkg_dependencies" -else - if [ "$(ynh_app_setting_get --app=$app --key=php_version)" != "7.3" ]; then - ynh_print_info --message="Upgrading PHP7.3..." - ynh_remove_fpm_config - ynh_remove_app_dependencies - ynh_remove_php - ynh_install_php --phpversion="7.3" --package="$extra_pkg_dependencies" - else - ynh_install_php --phpversion="7.3" --package="$extra_pkg_dependencies" - fi -fi - #================================================= # UPGRADE DEPENDENCIES #================================================= @@ -150,7 +135,7 @@ ynh_system_user_create --username=$app ynh_script_progression --message="Upgrading php-fpm configuration..." --weight=2 # Create a dedicated php-fpm config -ynh_add_fpm_config --phpversion="7.3" +ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies" #================================================= # SPECIFIC UPGRADE @@ -182,13 +167,14 @@ then ynh_script_progression --message="Upgrading ampache with composer..." --weight=30 # Install composer - ynh_install_composer --phpversion="7.3" --workdir="$final_path" --install_args="--prefer-source --no-dev" - ynh_composer_exec --phpversion="7.3" --workdir=$final_path --commands="config discard-changes true" + ynh_install_composer --phpversion="${YNH_PHP_VERSION}" --workdir="$final_path" --install_args="--prefer-source --no-dev" + ynh_composer_exec --phpversion="${YNH_PHP_VERSION}" --workdir="$final_path" --commands="config discard-changes true" fi #================================================= # UPDATE MULTIMEDIA DIRECTORIES #================================================= +ynh_script_progression --message="Updating multimedia directories..." ynh_multimedia_build_main_dir @@ -217,6 +203,7 @@ fi #================================================= # SECURE FILES AND DIRECTORIES #================================================= +ynh_script_progression --message="Securing files and directories..." # Set permissions on app files chown -R $app: $final_path @@ -226,7 +213,7 @@ chown -R $app: $final_path #================================================= ynh_script_progression --message="Upgrading SSOwat configuration..." -# Keep app public if necessary +# Make app public if necessary if [ $is_public -eq 0 ] then ynh_app_setting_delete --app=$app --key=unprotected_uris From af3487cfd2489ccc515549529093d13ecd27fc06 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 27 May 2020 01:43:30 +0200 Subject: [PATCH 23/24] typo --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index c34792c..a4f794a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -9,7 +9,7 @@ pkg_dependencies="libav-tools|ffmpeg" YNH_PHP_VERSION="7.3" -extra_php_dependencies="php${YNH_PHP_VERSION}mysql php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-simplexml php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-ldap" +extra_php_dependencies="php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-simplexml php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-ldap" #================================================= # EXPERIMENTAL HELPERS From 3dfd7fb259d0e0e3a3f6123a6b8853f69246a9fa Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 31 May 2020 00:35:45 +0200 Subject: [PATCH 24/24] Update _common.sh --- scripts/_common.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index a4f794a..248cf5a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -17,7 +17,8 @@ extra_php_dependencies="php${YNH_PHP_VERSION}-mysql php${YNH_PHP_VERSION}-curl p # Execute a command with Composer # -# usage: ynh_composer_exec --phpversion=phpversion [--workdir=$final_path] --commands="commands" +# usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands" +# | arg: -v, --phpversion - PHP version to use with composer # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. # | arg: -c, --commands - Commands to execute. ynh_composer_exec () { @@ -30,7 +31,7 @@ ynh_composer_exec () { # Manage arguments with getopts ynh_handle_getopts_args "$@" workdir="${workdir:-$final_path}" - phpversion="${phpversion:-7.0}" + phpversion="${phpversion:-$YNH_PHP_VERSION}" COMPOSER_HOME="$workdir/.composer" \ php${phpversion} "$workdir/composer.phar" $commands \ @@ -39,12 +40,13 @@ ynh_composer_exec () { # Install and initialize Composer in the given directory # -# usage: ynh_install_composer --phpversion=phpversion [--workdir=$final_path] [--install_args="--optimize-autoloader"] +# usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"] +# | arg: -v, --phpversion - PHP version to use with composer # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. # | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include ynh_install_composer () { # Declare an array to define the options of this helper. - local legacy_args=vw + local legacy_args=vwa declare -Ar args_array=( [v]=phpversion= [w]=workdir= [a]=install_args=) local phpversion local workdir @@ -52,7 +54,8 @@ ynh_install_composer () { # Manage arguments with getopts ynh_handle_getopts_args "$@" workdir="${workdir:-$final_path}" - phpversion="${phpversion:-7.0}" + phpversion="${phpversion:-$YNH_PHP_VERSION}" + install_args="${install_args:-}" curl -sS https://getcomposer.org/installer \ | COMPOSER_HOME="$workdir/.composer" \