From e02441532b2b252061df28855f4bcdaaad904a40 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Tue, 21 May 2019 22:53:57 +0200 Subject: [PATCH 01/26] Proposition for an app changelog --- CHANGELOG.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..6f13327 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,53 @@ +Changelog +========= + +## 1.8.3~ynh7 (2019-03-12) + +https://github.com/YunoHost-Apps/leed_ynh/pull/18 + +- [Normalization from example_ynh](https://github.com/YunoHost-Apps/leed_ynh/commit/1418b13ff9c3d2f1849ad21b5c645609e3bea863) + + +## 1.8.3~ynh6 (2019-02-03) + +https://github.com/YunoHost-Apps/leed_ynh/pull/17 + +- [Add progression bar](https://github.com/YunoHost-Apps/leed_ynh/commit/9085643892836479b8c33bba6f5054512e4d441f) +- [Changelog & html email](https://github.com/YunoHost-Apps/leed_ynh/commit/298f9ebf5767be9c6e163708cc69121a67aca1ed) +- [Update php and nginx conf files to php7](https://github.com/YunoHost-Apps/leed_ynh/commit/1b1b0a4b906edb03a38262f9a63d9d72742480cd) + + +## 1.8.3~ynh5 (2019-01-21) + +https://github.com/YunoHost-Apps/leed_ynh/pull/16 + +- [Advertise config-panel and actions](https://github.com/YunoHost-Apps/leed_ynh/commit/c725a8e6b529d2e595022f860de58bd091390a0b) +- [Update to last standart](https://github.com/YunoHost-Apps/leed_ynh/commit/92d36df30a9ea32a6c9e8a0dfa1f406fe7a49be3) + + +## 1.8.3~ynh4 (2018-09-30) + +https://github.com/YunoHost-Apps/leed_ynh/pull/15 + +- [Add Panel-config and actions](https://github.com/YunoHost-Apps/leed_ynh/commit/83253f60ff31f0ac7a4fe29e80e79c0cebbd3ad1) + + +## 1.8.3~ynh4 (2018-08-05) + +https://github.com/YunoHost-Apps/leed_ynh/pull/14 + +- [Fix fail2ban helper](https://github.com/YunoHost-Apps/leed_ynh/commit/c4b966ff2a977b8c0923d4f8ad403d86454883cb) + + +## 1.8.3~ynh4 (2018-07-16) + +https://github.com/YunoHost-Apps/leed_ynh/pull/13 + +- [Upgrade helpers](https://github.com/YunoHost-Apps/leed_ynh/commit/5cb8744ee1145971518328b242edd68b7ec1310c) + + +## 1.8.3~ynh3 (2018-03-14) + +https://github.com/YunoHost-Apps/leed_ynh/pull/11 + +- [Update helpers](https://github.com/YunoHost-Apps/leed_ynh/commit/1952ec18681135ecd13d32e53ecf86684ad1ff29) From 396f2c4f30c772cf150744bc6ae2588ecd93ca78 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Tue, 21 May 2019 23:11:02 +0200 Subject: [PATCH 02/26] Update CHANGELOG.md --- CHANGELOG.md | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f13327..70dc00b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,53 +1,39 @@ Changelog ========= -## 1.8.3~ynh7 (2019-03-12) - -https://github.com/YunoHost-Apps/leed_ynh/pull/18 +## 1.8.3~ynh7 ([2019-03-12](https://github.com/YunoHost-Apps/leed_ynh/pull/18)) - [Normalization from example_ynh](https://github.com/YunoHost-Apps/leed_ynh/commit/1418b13ff9c3d2f1849ad21b5c645609e3bea863) -## 1.8.3~ynh6 (2019-02-03) - -https://github.com/YunoHost-Apps/leed_ynh/pull/17 +## 1.8.3~ynh6 ([2019-02-03](https://github.com/YunoHost-Apps/leed_ynh/pull/17)) - [Add progression bar](https://github.com/YunoHost-Apps/leed_ynh/commit/9085643892836479b8c33bba6f5054512e4d441f) - [Changelog & html email](https://github.com/YunoHost-Apps/leed_ynh/commit/298f9ebf5767be9c6e163708cc69121a67aca1ed) - [Update php and nginx conf files to php7](https://github.com/YunoHost-Apps/leed_ynh/commit/1b1b0a4b906edb03a38262f9a63d9d72742480cd) -## 1.8.3~ynh5 (2019-01-21) - -https://github.com/YunoHost-Apps/leed_ynh/pull/16 +## 1.8.3~ynh5 ([2019-01-21](https://github.com/YunoHost-Apps/leed_ynh/pull/16)) - [Advertise config-panel and actions](https://github.com/YunoHost-Apps/leed_ynh/commit/c725a8e6b529d2e595022f860de58bd091390a0b) - [Update to last standart](https://github.com/YunoHost-Apps/leed_ynh/commit/92d36df30a9ea32a6c9e8a0dfa1f406fe7a49be3) -## 1.8.3~ynh4 (2018-09-30) - -https://github.com/YunoHost-Apps/leed_ynh/pull/15 +## 1.8.3~ynh4 ([2018-09-30](https://github.com/YunoHost-Apps/leed_ynh/pull/15)) - [Add Panel-config and actions](https://github.com/YunoHost-Apps/leed_ynh/commit/83253f60ff31f0ac7a4fe29e80e79c0cebbd3ad1) -## 1.8.3~ynh4 (2018-08-05) - -https://github.com/YunoHost-Apps/leed_ynh/pull/14 +## 1.8.3~ynh4 ([2018-08-05](https://github.com/YunoHost-Apps/leed_ynh/pull/14)) - [Fix fail2ban helper](https://github.com/YunoHost-Apps/leed_ynh/commit/c4b966ff2a977b8c0923d4f8ad403d86454883cb) -## 1.8.3~ynh4 (2018-07-16) - -https://github.com/YunoHost-Apps/leed_ynh/pull/13 +## 1.8.3~ynh4 ([2018-07-16](https://github.com/YunoHost-Apps/leed_ynh/pull/13)) - [Upgrade helpers](https://github.com/YunoHost-Apps/leed_ynh/commit/5cb8744ee1145971518328b242edd68b7ec1310c) -## 1.8.3~ynh3 (2018-03-14) - -https://github.com/YunoHost-Apps/leed_ynh/pull/11 +## 1.8.3~ynh3 ([2018-03-14](https://github.com/YunoHost-Apps/leed_ynh/pull/11)) - [Update helpers](https://github.com/YunoHost-Apps/leed_ynh/commit/1952ec18681135ecd13d32e53ecf86684ad1ff29) From f828d2381dae7f19495fe589b6553ff6cab90bac Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 22 May 2019 00:05:20 +0200 Subject: [PATCH 03/26] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70dc00b..016f18b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ Changelog ## 1.8.3~ynh6 ([2019-02-03](https://github.com/YunoHost-Apps/leed_ynh/pull/17)) - [Add progression bar](https://github.com/YunoHost-Apps/leed_ynh/commit/9085643892836479b8c33bba6f5054512e4d441f) -- [Changelog & html email](https://github.com/YunoHost-Apps/leed_ynh/commit/298f9ebf5767be9c6e163708cc69121a67aca1ed) +* [Changelog & html email](https://github.com/YunoHost-Apps/leed_ynh/commit/298f9ebf5767be9c6e163708cc69121a67aca1ed) - [Update php and nginx conf files to php7](https://github.com/YunoHost-Apps/leed_ynh/commit/1b1b0a4b906edb03a38262f9a63d9d72742480cd) @@ -21,7 +21,7 @@ Changelog ## 1.8.3~ynh4 ([2018-09-30](https://github.com/YunoHost-Apps/leed_ynh/pull/15)) -- [Add Panel-config and actions](https://github.com/YunoHost-Apps/leed_ynh/commit/83253f60ff31f0ac7a4fe29e80e79c0cebbd3ad1) +* [Add Panel-config and actions](https://github.com/YunoHost-Apps/leed_ynh/commit/83253f60ff31f0ac7a4fe29e80e79c0cebbd3ad1) ## 1.8.3~ynh4 ([2018-08-05](https://github.com/YunoHost-Apps/leed_ynh/pull/14)) From 96e373596181a8974130701086d70d40321701cf Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 2 Jun 2019 19:12:29 +0200 Subject: [PATCH 04/26] New parser for the new changelog --- scripts/_common.sh | 450 ++++++++++++++++++++++++++++++++++----------- scripts/upgrade | 11 +- 2 files changed, 356 insertions(+), 105 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 836436f..14918d9 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,5 +1,9 @@ #!/bin/bash +#================================================= +# PERSONAL HELPERS +#================================================= + #================================================= # BACKUP #================================================= @@ -384,128 +388,366 @@ ynh_maintenance_mode_OFF () { #================================================= -# Download and check integrity of a file from app.src_file +# Create a changelog for an app after an upgrade from the file CHANGELOG.md. # -# The file conf/app.src_file need to contains: +# usage: ynh_send_readme_to_admin [--format=markdown/html/plain] [--output=changelog_file] --changelog=changelog_source] +# | arg: -f --format= - Format in which the changelog will be printed +# markdown: Default format. +# html: Turn urls into html format. +# plain: Plain text changelog +# | arg: -o --output= - Output file for the changelog file (Default ./changelog) +# | arg: -c --changelog= - CHANGELOG.md source (Default ../CHANGELOG.md) # -# FILE_URL=Address to download the file -# FILE_SUM=Control sum -# # (Optional) Program to check the integrity (sha256sum, md5sum...) -# # default: sha256 -# FILE_SUM_PRG=sha256 -# # (Optionnal) Name of the local archive (offline setup support) -# # default: Name of the downloaded file. -# FILENAME=example.deb -# -# usage: ynh_download_file --dest_dir="/destination/directory" [--source_id=myfile] -# | arg: -d, --dest_dir= - Directory where to download the file -# | arg: -s, --source_id= - Name of the source file 'app.src_file' if it isn't '$app' -ynh_download_file () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [d]=dest_dir= [s]=source_id= ) - local dest_dir - local source_id - # Manage arguments with getopts - ynh_handle_getopts_args "$@" +# The changelog is printed into the file ./changelog and ./changelog_lite +ynh_app_changelog () { + # Declare an array to define the options of this helper. + local legacy_args=foc + declare -Ar args_array=( [f]=format= [o]=output= [c]=changelog= ) + local format + local output + local changelog + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + format=${format:-markdown} + output=${output:-changelog} + changelog=${changelog:-../CHANGELOG.md} - source_id=${source_id:-app} # If the argument is not given, source_id equals "$app" + local original_changelog="$changelog" + local temp_changelog="changelog_temp" + local final_changelog="$output" - # Load value from configuration file (see above for a small doc about this file - # format) - local src_file="$YNH_CWD/../conf/${source_id}.src_file" - # If the src_file doesn't exist, use the backup path instead, with a "settings" directory - if [ ! -e "$src_file" ] - then - src_file="$YNH_CWD/../settings/conf/${source_id}.src_file" - fi - local file_url=$(grep 'FILE_URL=' "$src_file" | cut -d= -f2-) - local file_sum=$(grep 'FILE_SUM=' "$src_file" | cut -d= -f2-) - local file_sumprg=$(grep 'FILE_SUM_PRG=' "$src_file" | cut -d= -f2-) - local filename=$(grep 'FILENAME=' "$src_file" | cut -d= -f2-) + if [ ! -n "$original_changelog" ] + then + echo "No changelog available..." > "$final_changelog" + echo "No changelog available..." > "${final_changelog}_lite" + return 0 + fi - # Default value - file_sumprg=${file_sumprg:-sha256sum} - if [ "$filename" = "" ] ; then - filename="$(basename "$file_url")" - fi - local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${filename}" + local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version") + local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version") - if test -e "$local_src" - then # Use the local source file if it is present - cp $local_src $filename - else # If not, download the source - local out=`wget -nv -O $filename $file_url 2>&1` || ynh_print_err $out - fi + # Get the line of the version to update to into the changelog + local update_version_line=$(grep --max-count=1 --line-number "^## $update_version" "$original_changelog" | cut -d':' -f1) + # If there's no entry for this version yet into the changelog + # Get the first available version + if [ -z "$update_version_line" ] + then + update_version_line=$(grep --max-count=1 --line-number "^##" "$original_changelog" | cut -d':' -f1) + fi - # Check the control sum - echo "${file_sum} ${filename}" | ${file_sumprg} -c --status \ - || ynh_die "Corrupt file" + # Get the length of the complete changelog. + local changelog_length=$(wc --lines "$original_changelog" | awk '{print $1}') + # Cut the file before the version to update to. + tail --lines=$(( $changelog_length - $update_version_line + 1 )) "$original_changelog" > "$temp_changelog" - # Create the destination directory, if it's not already. - mkdir -p "$dest_dir" + # Get the length of the troncated changelog. + changelog_length=$(wc --lines "$temp_changelog" | awk '{print $1}') + # Get the line of the current version into the changelog + # Keep only the last line found + local current_version_line=$(grep --line-number "^## $current_version" "$temp_changelog" | cut -d':' -f1 | tail --lines=1) + # If there's no entry for this version into the changelog + # Get the last available version + if [ -z "$current_version_line" ] + then + current_version_line=$(grep --line-number "^##" "$original_changelog" | cut -d':' -f1 | tail --lines=1) + fi + # Cut the file before the current version. + # Then grep the previous version into the changelog to get the line number of the previous version + local previous_version_line=$(tail --lines=$(( $changelog_length - $current_version_line )) \ + "$temp_changelog" | grep --max-count=1 --line-number "^##" | cut -d':' -f1) + # If there's no previous version into the changelog + # Go until the end of the changelog + if [ -z "$previous_version_line" ] + then + previous_version_line=$changelog_length + fi - # Move the file to its destination - mv $filename $dest_dir + # Cut the file after the previous version to keep only the changelog between the current version and the version to update to. + head --lines=$(( $current_version_line + $previous_version_line - 1 )) "$temp_changelog" | tee "$final_changelog" + + if [ "$format" = "html" ] + then + # Replace markdown links by html links + ynh_replace_string --match_string="\[\(.*\)\](\(.*\)))" --replace_string="\1)" --target_file="$final_changelog" + ynh_replace_string --match_string="\[\(.*\)\](\(.*\))" --replace_string="\1" --target_file="$final_changelog" + elif [ "$format" = "plain" ] + then + # Change title format. + ynh_replace_string --match_string="^\(##.* \)(\[\(.*\)\](\(.*\)))" --replace_string="\1- \2 \3" --target_file="$final_changelog" + # Change modifications lines format. + ynh_replace_string --match_string="^\([-*]\).*\[\(.*\)\]\(.*\)" --replace_string="\1 \2 \3" --target_file="$final_changelog" + fi + # else markdown. As the file is already in markdown, nothing to do. + + # Keep only important changes into the changelog + # Remove all minor changes + sed '/^-/d' "$final_changelog" > "${final_changelog}_lite" + # Remove all blank lines (to keep a clear workspace) + sed --in-place '/^$/d' "${final_changelog}_lite" + # Add a blank line at the end + echo "" >> "${final_changelog}_lite" + + # Clean titles if there's no significative changes + local line + local previous_line + while read line <&3 + do + if [ -n "$previous_line" ] + then + # Remove the line if it's a title or a blank line, and the previous one was a title as well. + if ( [ "${line:0:1}" = "#" ] || [ ${#line} -eq 0 ] ) && [ "${previous_line:0:1}" = "#" ] + then + ynh_replace_special_string --match_string="${previous_line//[/.}" --replace_string="" --target_file="${final_changelog}_lite" + fi + fi + previous_line="$line" + done 3< "${final_changelog}_lite" + + # Remove all blank lines again + sed --in-place '/^$/d' "${final_changelog}_lite" + + # Restore changelog format with blank lines + ynh_replace_string --match_string="^##.*" --replace_string="\n\n&\n" --target_file="${final_changelog}_lite" + # Remove the 2 first blank lines + sed --in-place '1,2d' "${final_changelog}_lite" + # Add a blank line at the end + echo "" >> "${final_changelog}_lite" + + # If changelog are empty, add an info + if [ $(wc --words "$final_changelog" | awk '{print $1}') -eq 0 ] + then + echo "No changes from the changelog..." > "$final_changelog" + fi + if [ $(wc --words "${final_changelog}_lite" | awk '{print $1}') -eq 0 ] + then + echo "No significative changes from the changelog..." > "${final_changelog}_lite" + fi } #================================================= -# Create a changelog for an app after an upgrade. +# Check the amount of available RAM # -# The changelog is printed into the file ./changelog for the time of the upgrade. -# -# In order to create a changelog, ynh_app_changelog will get info from /etc/yunohost/apps/$app/status.json -# In order to find the current commit use by the app. -# The remote repository, and the branch. -# The changelog will be only the commits since the current revision. -# -# Because of the need of those info, ynh_app_changelog works only -# with apps that have been installed from a list. -# -# usage: ynh_app_changelog -ynh_app_changelog () { - get_value_from_settings () - { - local value="$1" - # Extract a value from the status.json file of an installed app. +# usage: ynh_check_ram [--required=RAM required in Mb] [--no_swap|--only_swap] [--free_ram] +# | arg: -r, --required= - Amount of RAM required in Mb. The helper will return 0 is there's enough RAM, or 1 otherwise. +# If --required isn't set, the helper will print the amount of RAM, in Mb. +# | arg: -s, --no_swap - Ignore swap +# | arg: -o, --only_swap - Ignore real RAM, consider only swap. +# | arg: -f, --free_ram - Count only free RAM, not the total amount of RAM available. +ynh_check_ram () { + # Declare an array to define the options of this helper. + declare -Ar args_array=( [r]=required= [s]=no_swap [o]=only_swap [f]=free_ram ) + local required + local no_swap + local only_swap + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + required=${required:-} + no_swap=${no_swap:-0} + only_swap=${only_swap:-0} - grep "$value\": \"" /etc/yunohost/apps/$app/status.json | sed "s/.*$value\": \"\([^\"]*\).*/\1/" - } + local total_ram=$(vmstat --stats --unit M | grep "total memory" | awk '{print $1}') + local total_swap=$(vmstat --stats --unit M | grep "total swap" | awk '{print $1}') + local total_ram_swap=$(( total_ram + total_swap )) - local current_revision="$(get_value_from_settings revision)" - local repo="$(get_value_from_settings url)" - local branch="$(get_value_from_settings branch)" - # ynh_app_changelog works only with an app installed from a list. - if [ -z "$current_revision" ] || [ -z "$repo" ] || [ -z "$branch" ] + local free_ram=$(vmstat --stats --unit M | grep "free memory" | awk '{print $1}') + local free_swap=$(vmstat --stats --unit M | grep "free swap" | awk '{print $1}') + local free_ram_swap=$(( free_ram + free_swap )) + + # Use the total amount of ram + local ram=$total_ram_swap + if [ $free_ram -eq 1 ] then - ynh_print_warn "Unable to build the changelog..." - touch changelog - return 0 + # Use the total amount of free ram + ram=$free_ram_swap + if [ $no_swap -eq 1 ] + then + # Use only the amount of free ram + ram=$free_ram + elif [ $only_swap -eq 1 ] + then + # Use only the amount of free swap + ram=$free_swap + fi + else + if [ $no_swap -eq 1 ] + then + # Use only the amount of free ram + ram=$total_ram + elif [ $only_swap -eq 1 ] + then + # Use only the amount of free swap + ram=$total_swap + fi fi - # Fetch the history of the repository, without cloning it - mkdir git_history - (cd git_history - ynh_exec_warn_less git init - ynh_exec_warn_less git remote add -f origin $repo - # Get the line of the current commit of the installed app in the history. - local line_to_head=$(git log origin/$branch --pretty=oneline | grep --line-number "$current_revision" | cut -d':' -f1) - # Cut the history before the current commit, to keep only newer commits. - # Then use sed to reorganise each lines and have a nice list of commits since the last upgrade. - # This list is redirected into the file changelog - git log origin/$branch --pretty=oneline | head --lines=$(($line_to_head-1)) | sed 's/^\([[:alnum:]]*\)\(.*\)/*(\1) -> \2/g' > ../changelog) - # Remove 'Merge pull request' commits - sed -i '/Merge pull request #[[:digit:]]* from/d' changelog - # As well as conflict resolving commits - sed -i '/Merge branch .* into/d' changelog + if [ -n "$required" ] + then + # Return 1 if the amount of ram isn't enough. + if [ $ram -lt $required ] + then + return 1 + else + return 0 + fi - # Get the value of admin_mail_html - admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) - admin_mail_html="${admin_mail_html:-0}" - - # If a html email is required. Apply html to the changelog. - if [ "$admin_mail_html" -eq 1 ] - then - sed -in-place "s@\*(\([[:alnum:]]*\)) -> \(.*\)@* __URL_TAG1__\2__URL_TAG2__${repo}/commit/\1__URL_TAG3__@g" changelog - fi + # If no RAM is required, return the amount of available ram. + else + echo $ram + fi +} + +#================================================= + +# Define the values to configure php-fpm +# +# usage: ynh_get_scalable_phpfpm --usage=usage --footprint=footprint [--print] +# | arg: -f, --footprint - Memory footprint of the service (low/medium/high). +# low - Less than 20Mb of ram by pool. +# medium - Between 20Mb and 40Mb of ram by pool. +# high - More than 40Mb of ram by pool. +# Or specify exactly the footprint, the load of the service as Mb by pool instead of having a standard value. +# To have this value, use the following command and stress the service. +# watch -n0.5 ps -o user,cmd,%cpu,rss -u APP +# +# | arg: -u, --usage - Expected usage of the service (low/medium/high). +# low - Personal usage, behind the sso. +# medium - Low usage, few people or/and publicly accessible. +# high - High usage, frequently visited website. +# +# | arg: -p, --print - Print the result +# +# +# +# The footprint of the service will be used to defined the maximum footprint we can allow, which is half the maximum RAM. +# So it will be used to defined 'pm.max_children' +# A lower value for the footprint will allow more children for 'pm.max_children'. And so for +# 'pm.start_servers', 'pm.min_spare_servers' and 'pm.max_spare_servers' which are defined from the +# value of 'pm.max_children' +# NOTE: 'pm.max_children' can't exceed 4 times the number of processor's cores. +# +# The usage value will defined the way php will handle the children for the pool. +# A value set as 'low' will set the process manager to 'ondemand'. Children will start only if the +# service is used, otherwise no child will stay alive. This config gives the lower footprint when the +# service is idle. But will use more proc since it has to start a child as soon it's used. +# Set as 'medium', the process manager will be at dynamic. If the service is idle, a number of children +# equal to pm.min_spare_servers will stay alive. So the service can be quick to answer to any request. +# The number of children can grow if needed. The footprint can stay low if the service is idle, but +# not null. The impact on the proc is a little bit less than 'ondemand' as there's always a few +# children already available. +# Set as 'high', the process manager will be set at 'static'. There will be always as many children as +# 'pm.max_children', the footprint is important (but will be set as maximum a quarter of the maximum +# RAM) but the impact on the proc is lower. The service will be quick to answer as there's always many +# children ready to answer. +ynh_get_scalable_phpfpm () { + local legacy_args=ufp + # Declare an array to define the options of this helper. + declare -Ar args_array=( [u]=usage= [f]=footprint= [p]=print ) + local usage + local footprint + local print + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + # Set all characters as lowercase + footprint=${footprint,,} + usage=${usage,,} + print=${print:-0} + + if [ "$footprint" = "low" ] + then + footprint=20 + elif [ "$footprint" = "medium" ] + then + footprint=35 + elif [ "$footprint" = "high" ] + then + footprint=50 + fi + + # Define the way the process manager handle child processes. + if [ "$usage" = "low" ] + then + php_pm=ondemand + elif [ "$usage" = "medium" ] + then + php_pm=dynamic + elif [ "$usage" = "high" ] + then + php_pm=static + else + ynh_die --message="Does not recognize '$usage' as an usage value." + fi + + # Get the total of RAM available, except swap. + local max_ram=$(ynh_check_ram --no_swap) + + less0() { + # Do not allow value below 1 + if [ $1 -le 0 ] + then + echo 1 + else + echo $1 + fi + } + + # Define pm.max_children + # The value of pm.max_children is the total amount of ram divide by 2 and divide again by the footprint of a pool for this app. + # So if php-fpm start the maximum of children, it won't exceed half of the ram. + php_max_children=$(( $max_ram / 2 / $footprint )) + # If process manager is set as static, use half less children. + # Used as static, there's always as many children as the value of pm.max_children + if [ "$php_pm" = "static" ] + then + php_max_children=$(( $php_max_children / 2 )) + fi + php_max_children=$(less0 $php_max_children) + + # To not overload the proc, limit the number of children to 4 times the number of cores. + local core_number=$(nproc) + local max_proc=$(( $core_number * 4 )) + if [ $php_max_children -gt $max_proc ] + then + php_max_children=$max_proc + fi + + if [ "$php_pm" = "dynamic" ] + then + # Define pm.start_servers, pm.min_spare_servers and pm.max_spare_servers for a dynamic process manager + php_min_spare_servers=$(( $php_max_children / 8 )) + php_min_spare_servers=$(less0 $php_min_spare_servers) + + php_max_spare_servers=$(( $php_max_children / 2 )) + php_max_spare_servers=$(less0 $php_max_spare_servers) + + php_start_servers=$(( $php_min_spare_servers + ( $php_max_spare_servers - $php_min_spare_servers ) /2 )) + php_start_servers=$(less0 $php_start_servers) + else + php_min_spare_servers=0 + php_max_spare_servers=0 + php_start_servers=0 + fi + + if [ $print -eq 1 ] + then + ynh_debug --message="Footprint=${footprint}Mb by pool." + ynh_debug --message="Process manager=$php_pm" + ynh_debug --message="Max RAM=${max_ram}Mb" + if [ "$php_pm" != "static" ]; then + ynh_debug --message="\nMax estimated footprint=$(( $php_max_children * $footprint ))" + ynh_debug --message="Min estimated footprint=$(( $php_min_spare_servers * $footprint ))" + fi + if [ "$php_pm" = "dynamic" ]; then + ynh_debug --message="Estimated average footprint=$(( $php_max_spare_servers * $footprint ))" + elif [ "$php_pm" = "static" ]; then + ynh_debug --message="Estimated footprint=$(( $php_max_children * $footprint ))" + fi + ynh_debug --message="\nRaw php-fpm values:" + ynh_debug --message="pm.max_children = $php_max_children" + if [ "$php_pm" = "dynamic" ]; then + ynh_debug --message="pm.start_servers = $php_start_servers" + ynh_debug --message="pm.min_spare_servers = $php_min_spare_servers" + ynh_debug --message="pm.max_spare_servers = $php_max_spare_servers" + fi + fi } diff --git a/scripts/upgrade b/scripts/upgrade index 70db485..6454848 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -253,7 +253,16 @@ ynh_maintenance_mode_OFF admin_panel="https://$(grep portal_domain /etc/ssowat/conf.json | cut -d'"' -f4)/yunohost/admin/#/apps/$app" # Build the changelog -ynh_app_changelog || true +# Get the value of admin_mail_html +admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) +admin_mail_html="${admin_mail_html:-0}" +# If a html email is required. Apply html to the changelog. +if [ "$admin_mail_html" -eq 1 ]; then + format=html +else + format=plain +fi +ynh_app_changelog --format=$format echo "You can configure this app easily by using the experimental __URL_TAG1__config-panel feature__URL_TAG2__$admin_panel/config-panel__URL_TAG3__. You can also find some specific actions for this app by using the experimental __URL_TAG1__action feature__URL_TAG2__$admin_panel/actions__URL_TAG3__. From dd2f38cc799db1fb743d313cd32151ea493d3026 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 2 Jun 2019 19:27:00 +0200 Subject: [PATCH 05/26] Fix previous_line --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 14918d9..2621e6d 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -489,7 +489,7 @@ ynh_app_changelog () { # Clean titles if there's no significative changes local line - local previous_line + local previous_line="" while read line <&3 do if [ -n "$previous_line" ] From 8d6b382b9d9c703cca814ad62b5843023805669e Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Tue, 2 Jul 2019 13:18:03 +0200 Subject: [PATCH 06/26] Update changelog parser --- scripts/_common.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 2621e6d..cd39857 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -427,7 +427,7 @@ ynh_app_changelog () { local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version") # Get the line of the version to update to into the changelog - local update_version_line=$(grep --max-count=1 --line-number "^## $update_version" "$original_changelog" | cut -d':' -f1) + local update_version_line=$(grep --max-count=1 --line-number "^## \[$update_version" "$original_changelog" | cut -d':' -f1) # If there's no entry for this version yet into the changelog # Get the first available version if [ -z "$update_version_line" ] @@ -444,7 +444,7 @@ ynh_app_changelog () { changelog_length=$(wc --lines "$temp_changelog" | awk '{print $1}') # Get the line of the current version into the changelog # Keep only the last line found - local current_version_line=$(grep --line-number "^## $current_version" "$temp_changelog" | cut -d':' -f1 | tail --lines=1) + local current_version_line=$(grep --line-number "^## \[$current_version" "$temp_changelog" | cut -d':' -f1 | tail --lines=1) # If there's no entry for this version into the changelog # Get the last available version if [ -z "$current_version_line" ] @@ -454,7 +454,7 @@ ynh_app_changelog () { # Cut the file before the current version. # Then grep the previous version into the changelog to get the line number of the previous version local previous_version_line=$(tail --lines=$(( $changelog_length - $current_version_line )) \ - "$temp_changelog" | grep --max-count=1 --line-number "^##" | cut -d':' -f1) + "$temp_changelog" | grep --max-count=1 --line-number "^## " | cut -d':' -f1) # If there's no previous version into the changelog # Go until the end of the changelog if [ -z "$previous_version_line" ] @@ -473,7 +473,7 @@ ynh_app_changelog () { elif [ "$format" = "plain" ] then # Change title format. - ynh_replace_string --match_string="^\(##.* \)(\[\(.*\)\](\(.*\)))" --replace_string="\1- \2 \3" --target_file="$final_changelog" + ynh_replace_string --match_string="^##.*\[\(.*\)\](\(.*\)) - \(.*\)$" --replace_string="## \1 (\3) - \2" --target_file="$final_changelog" # Change modifications lines format. ynh_replace_string --match_string="^\([-*]\).*\[\(.*\)\]\(.*\)" --replace_string="\1 \2 \3" --target_file="$final_changelog" fi From 58c89c4deed24eac61bb5de4b1984a69b703ee68 Mon Sep 17 00:00:00 2001 From: maniack Date: Sun, 21 Jul 2019 12:58:13 +0200 Subject: [PATCH 07/26] Config-panel tests --- config_panel.json | 75 ------------------------------------ config_panel.toml | 62 ++++++++++++++++++++++++++++++ scripts/config | 50 +++++++++++++++--------- scripts/upgrade | 96 +++++++++++++++++++++++------------------------ 4 files changed, 142 insertions(+), 141 deletions(-) delete mode 100644 config_panel.json create mode 100644 config_panel.toml diff --git a/config_panel.json b/config_panel.json deleted file mode 100644 index e605e61..0000000 --- a/config_panel.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "name": "Leed configuration panel", - "version": "0.1", - "panel": [{ - "name": "Leed configuration", - "id": "main", - "sections": [{ - "name": "Public access", - "id": "is_public", - "options": [{ - "name": "Is it a public app ?", - "id": "is_public", - "type": "bool", - "default": true - }] - }, - { - "name": "Overwriting config files", - "id": "overwrite_files", - "options": [{ - "name": "Overwrite the nginx config file ?", - "help": "If the file is overwritten, a backup will be created.", - "id": "overwrite_nginx", - "type": "bool", - "default": true - }, - { - "name": "Overwrite the php-fpm config file ?", - "help": "If the file is overwritten, a backup will be created.", - "id": "overwrite_phpfpm", - "type": "bool", - "default": true - }] - }, - { - "name": "Global configuration", - "id": "global_config", - "options": [{ - "name": "Send HTML email to admin ?", - "help": "Allow app scripts to send HTML mails instead of plain text.", - "id": "email_type", - "type": "bool", - "default": true - }] - }, - { - "name": "PHP-FPM configuration", - "id": "php_fpm_config", - "options": [{ - "name": "Memory footprint of the service ?", - "help": "low <= 20Mb per pool. medium between 20Mb and 40Mb per pool. high > 40Mb per pool. Use specific to set a value with the following option.\n
We can't use a choices field for now. In the meantime please choose between one of this values:\n
low, medium, high, specific.", - "id": "footprint", - "type": "text", - "//": "\"choices\" : [\"low\", \"medium\", \"high\", \"specific\"]", - "default" : "low" - }, - { - "name": "Memory footprint of the service ?", - "help": "Free field to specify exactly the footprint in Mb if you don't want to use one of the three previous values.", - "id": "free_footprint", - "type": "number", - "default": 0 - }, - { - "name": "Expected usage of the service ?", - "help": "low: Personal usage, behind the sso. No RAM footprint when not used, but the impact on the processor can be high if many users are using the service.\n
medium: Low usage, few people or/and publicly accessible. Low RAM footprint, medium processor footprint when used.\n
high: High usage, frequently visited website. High RAM footprint, but lower on processor usage and quickly responding.\n
We can't use a choices field for now. In the meantime please choose between one of this values:\n
low, medium, high.", - "id": "usage", - "type": "text", - "//": "\"choices\" : [\"low\", \"medium\", \"high\"]", - "default" : "low" - }] - }] - } -] -} diff --git a/config_panel.toml b/config_panel.toml new file mode 100644 index 0000000..575c7a4 --- /dev/null +++ b/config_panel.toml @@ -0,0 +1,62 @@ +version = "0.1" +name = "Leed configuration panel" + +[main] +name = "Leed configuration" + + [main.is_public] + name = "Public access" + + [main.is_public.is_public] + ask = "Is it a public website ?" + type = "boolean" + default = true + help = "A public Leed will be accessible for third party apps.
By turning on 'anonymous readers' in Leed configuration, you can made your feeds public." + + + [main.overwrite_files] + name = "Overwriting config files" + + [main.overwrite_files.overwrite_nginx] + ask = "Overwrite the nginx config file ?" + type = "boolean" + default = true + help = "If the file is overwritten, a backup will be created." + + [main.overwrite_files.overwrite_phpfpm] + ask = "Overwrite the php-fpm config file ?" + type = "boolean" + default = true + help = "If the file is overwritten, a backup will be created." + + + [main.global_config] + name = "Global configuration" + + [main.global_config.email_type] + ask = "Send HTML email to admin ?" + type = "boolean" + default = true + help = "Allow app scripts to send HTML mails instead of plain text." + + + [main.php_fpm_config] + name = "PHP-FPM configuration" + + [main.php_fpm_config.footprint] + ask = "Memory footprint of the service ?" + choices = ["low", "medium", "high", "specific"] + default = "low" + help = "low <= 20Mb per pool. medium between 20Mb and 40Mb per pool. high > 40Mb per pool.
Use specific to set a value with the following option." + + [main.php_fpm_config.free_footprint] + ask = "Memory footprint of the service ?" + type = "number" + default = "0" + help = "Free field to specify exactly the footprint in Mb if you don't want to use one of the three previous values." + + [main.php_fpm_config.usage] + ask = "Expected usage of the service ?" + choices = ["low", "medium", "high"] + default = "low" + help = "low: Personal usage, behind the sso. No RAM footprint when not used, but the impact on the processor can be high if many users are using the service.
medium: Low usage, few people or/and publicly accessible. Low RAM footprint, medium processor footprint when used.
high: High usage, frequently visited website. High RAM footprint, but lower on processor usage and quickly responding." diff --git a/scripts/config b/scripts/config index f0785cc..85949f2 100644 --- a/scripts/config +++ b/scripts/config @@ -29,30 +29,37 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # is_public old_is_public="$(ynh_app_setting_get --app=$app --key=is_public)" -old_is_public=$(bool_to_true_false $old_is_public) +ynh_debug -m "old_is_public=$old_is_public" +# old_is_public=$(bool_to_true_false $old_is_public) +# ynh_debug -m "old_is_public=$old_is_public" is_public="${YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC:-$old_is_public}" - +ynh_debug -m "YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC=$YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC" +ynh_debug -m "is_public=$is_public" # Overwrite nginx configuration old_overwrite_nginx="$(ynh_app_setting_get --app=$app --key=overwrite_nginx)" -old_overwrite_nginx=$(bool_to_true_false $old_overwrite_nginx) +# old_overwrite_nginx=$(bool_to_true_false $old_overwrite_nginx) overwrite_nginx="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX:-$old_overwrite_nginx}" +ynh_debug -m "overwrite_nginx=$overwrite_nginx" # Overwrite php-fpm configuration old_overwrite_phpfpm="$(ynh_app_setting_get --app=$app --key=overwrite_phpfpm)" -old_overwrite_phpfpm=$(bool_to_true_false $old_overwrite_phpfpm) +# old_overwrite_phpfpm=$(bool_to_true_false $old_overwrite_phpfpm) overwrite_phpfpm="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM:-$old_overwrite_phpfpm}" +ynh_debug -m "overwrite_phpfpm=$overwrite_phpfpm" # Type of admin mail configuration old_admin_mail_html="$(ynh_app_setting_get --app=$app --key=admin_mail_html)" -old_admin_mail_html=$(bool_to_true_false $old_admin_mail_html) +# old_admin_mail_html=$(bool_to_true_false $old_admin_mail_html) admin_mail_html="${YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE:-$old_admin_mail_html}" +ynh_debug -m "admin_mail_html=$admin_mail_html" # Footprint for php-fpm old_fpm_footprint="$(ynh_app_setting_get --app=$app --key=fpm_footprint)" fpm_footprint="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FOOTPRINT:-$old_fpm_footprint}" +ynh_debug -m "fpm_footprint=$fpm_footprint" # Free footprint value for php-fpm # Check if fpm_footprint is an integer @@ -64,10 +71,12 @@ else old_free_footprint=0 fi free_footprint="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT:-$old_free_footprint}" +ynh_debug -m "free_footprint=$free_footprint" # Usage for php-fpm old_fpm_usage="$(ynh_app_setting_get --app=$app --key=fpm_usage)" fpm_usage="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE:-$old_fpm_usage}" +ynh_debug -m "fpm_usage=$fpm_usage" #================================================= # SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND @@ -75,18 +84,18 @@ fpm_usage="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE:-$old_fpm_usage}" show_config() { # here you are supposed to read some config file/database/other then print the values - # echo "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value" + # ynh_return "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value" - echo "YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC=$is_public" + ynh_return "YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC=$is_public" - echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx" - echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM=$overwrite_phpfpm" + ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx" + ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM=$overwrite_phpfpm" - echo "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html" + ynh_return "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html" - echo "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FOOTPRINT=$fpm_footprint" - echo "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT=$free_footprint" - echo "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE=$fpm_usage" + ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FOOTPRINT=$fpm_footprint" + ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT=$free_footprint" + ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE=$fpm_usage" } #================================================= @@ -100,7 +109,7 @@ apply_config() { #================================================= # Change public accessibility - if [ "$is_public" = "true" ] + if [ $is_public -eq 1 ] then yunohost app action run $app public_private --args is_public=1 else @@ -112,10 +121,10 @@ apply_config() { #================================================= # Set overwrite_nginx - overwrite_nginx=$(bool_to_01 $overwrite_nginx) +# overwrite_nginx=$(bool_to_01 $overwrite_nginx) ynh_app_setting_set --app=$app --key=overwrite_nginx --value="$overwrite_nginx" # Set overwrite_phpfpm - overwrite_phpfpm=$(bool_to_01 $overwrite_phpfpm) +# overwrite_phpfpm=$(bool_to_01 $overwrite_phpfpm) ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value="$overwrite_phpfpm" #================================================= @@ -123,15 +132,20 @@ apply_config() { #================================================= # Set admin_mail_html - admin_mail_html=$(bool_to_01 $admin_mail_html) +# admin_mail_html=$(bool_to_01 $admin_mail_html) ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html" #================================================= # RECONFIGURE PHP-FPM #================================================= - if [ "$fpm_usage" != "$old_fpm_usage" ] || [ "$fpm_footprint" != "$old_fpm_footprint" ] + if [ "$fpm_usage" != "$old_fpm_usage" ] || [ "$fpm_footprint" != "$old_fpm_footprint" ] || [ "$free_footprint" != "$old_free_footprint" ] then + # If fpm_footprint is set to 'specific', use $free_footprint value. + if [ "$fpm_footprint" = "specific" ] + then + fpm_footprint=$free_footprint + fi ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint fi } diff --git a/scripts/upgrade b/scripts/upgrade index 8e6a0e8..cb9e247 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -45,53 +45,53 @@ ynh_script_progression --message="Ensuring downward compatibility..." # If final_path doesn't exist, create it if [ -z "$final_path" ]; then - final_path=/var/www/$app - ynh_app_setting_set --app=$app --key=final_path --value=$final_path + final_path=/var/www/$app + ynh_app_setting_set --app=$app --key=final_path --value=$final_path fi # If db_name doesn't exist, create it if [ -z "$db_name" ]; then - db_name=$(ynh_sanitize_dbid --db_name=$app) - ynh_app_setting_set --app=$app --key=db_name --value=$db_name + db_name=$(ynh_sanitize_dbid --db_name=$app) + ynh_app_setting_set --app=$app --key=db_name --value=$db_name fi # If is_public doesn't exist, create it if [ -z "$is_public" ]; then - public_check=$(ynh_app_setting_get --app=$app --key=skipped_uris) - # If skipped_uris is empty, that was a public installation. - if [ -z "$public_check" ]; then - is_public=1 - else - is_public=0 - fi - ynh_app_setting_set --app=$app --key=is_public --value=$is_public + public_check=$(ynh_app_setting_get --app=$app --key=skipped_uris) + # If skipped_uris is empty, that was a public installation. + if [ -z "$public_check" ]; then + is_public=1 + else + is_public=0 + fi + ynh_app_setting_set --app=$app --key=is_public --value=$is_public else - # Fix is_public as a boolean - if [ "$is_public" = "Yes" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=1 - is_public=1 - elif [ "$is_public" = "No" ]; then - ynh_app_setting_set --app=$app --key=is_public --value=0 - is_public=0 - fi + # Fix is_public as a boolean + if [ "$is_public" = "Yes" ]; then + ynh_app_setting_set --app=$app --key=is_public --value=1 + is_public=1 + elif [ "$is_public" = "No" ]; then + ynh_app_setting_set --app=$app --key=is_public --value=0 + is_public=0 + fi fi # If overwrite_nginx doesn't exist, create it if [ -z "$overwrite_nginx" ]; then - overwrite_nginx=1 - ynh_app_setting_set --app=$app --key=overwrite_nginx --value=$overwrite_nginx + overwrite_nginx=1 + ynh_app_setting_set --app=$app --key=overwrite_nginx --value=$overwrite_nginx fi # If overwrite_phpfpm doesn't exist, create it if [ -z "$overwrite_phpfpm" ]; then - overwrite_phpfpm=1 - ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value=$overwrite_phpfpm + overwrite_phpfpm=1 + ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value=$overwrite_phpfpm fi # If admin_mail_html doesn't exist, create it if [ -z "$admin_mail_html" ]; then - admin_mail_html=1 - ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html + admin_mail_html=1 + ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html fi #================================================= @@ -102,8 +102,8 @@ ynh_script_progression --message="Backing up the app before upgrading (may take # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup + # restore it if the upgrade fails + ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -130,9 +130,9 @@ ynh_maintenance_mode_ON if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --weight=3 - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_script_progression --message="Upgrading source files..." --weight=3 + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" fi #================================================= @@ -142,9 +142,9 @@ fi # Overwrite the nginx configuration only if it's allowed if [ $overwrite_nginx -eq 1 ] then - ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2 - # Create a dedicated nginx config - ynh_add_nginx_config + ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=2 + # Create a dedicated nginx config + ynh_add_nginx_config fi #================================================= @@ -162,9 +162,9 @@ ynh_system_user_create --username=$app # Overwrite the php-fpm configuration only if it's allowed if [ $overwrite_phpfpm -eq 1 ] then - ynh_script_progression --message="Upgrading php-fpm configuration..." --weight=2 - # Create a dedicated php-fpm config - ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint + ynh_script_progression --message="Upgrading php-fpm configuration..." --weight=2 + # Create a dedicated php-fpm config + ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint fi #================================================= @@ -203,13 +203,13 @@ chown -R $app $final_path/cache $final_path/plugins $final_path/updates if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading Leed with curl..." --weight=4 - # Set the app as temporarily public for curl call - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" - # Regen SSOwat configuration - yunohost app ssowatconf - # Start the upgrade procedure of leed. - ynh_local_curl "/" + ynh_script_progression --message="Upgrading Leed with curl..." --weight=4 + # Set the app as temporarily public for curl call + ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" + # Regen SSOwat configuration + yunohost app ssowatconf + # Start the upgrade procedure of leed. + ynh_local_curl "/" fi #================================================= @@ -230,10 +230,10 @@ ynh_script_progression --message="Upgrading SSOwat configuration..." # Make app private if necessary if [ $is_public -eq 0 ] then - # Remove the public access - ynh_app_setting_delete --app=$app --key=unprotected_uris - # Set the action.php script public for the cron task - ynh_app_setting_set --app=$app --key=skipped_uris --value="/action.php" + # Remove the public access + ynh_app_setting_delete --app=$app --key=unprotected_uris + # Set the action.php script public for the cron task + ynh_app_setting_set --app=$app --key=skipped_uris --value="/action.php" fi #================================================= From 9773112a00f3213eebc34ae51ca9e8b415f7513c Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 23 Sep 2019 18:15:55 +0200 Subject: [PATCH 08/26] Use actions.toml --- actions.json | 20 -------------------- actions.toml | 14 ++++++++++++++ scripts/config | 26 ++++++++------------------ 3 files changed, 22 insertions(+), 38 deletions(-) delete mode 100644 actions.json create mode 100644 actions.toml diff --git a/actions.json b/actions.json deleted file mode 100644 index e506b49..0000000 --- a/actions.json +++ /dev/null @@ -1,20 +0,0 @@ -[{ - "id": "public_private", - "name": "Move to public or private", - "command": "/bin/bash scripts/actions/public_private", - "user": "root", - "accepted_return_codes": [0], - "description": { - "en": "Change the public access of the app." - }, - "arguments": [ - { - "name": "is_public", - "type": "boolean", - "ask": { - "en": "Is it a public app ?" - }, - "default": true - } - ] -}] diff --git a/actions.toml b/actions.toml new file mode 100644 index 0000000..676b926 --- /dev/null +++ b/actions.toml @@ -0,0 +1,14 @@ +[public_private] +name = "Move to public or private" +command = "/bin/bash scripts/actions/public_private" +# user = "root" # optional +# cwd = "/" # optional +# accepted_return_codes = [0, 1, 2, 3] # optional +accepted_return_codes = [0] +description = "Change the public access of the app." + + [public_private.arguments] + [public_private.arguments.is_public] + type = "boolean" + ask = "Is it a public app ?" + default = true diff --git a/scripts/config b/scripts/config index 85949f2..3cc2691 100644 --- a/scripts/config +++ b/scripts/config @@ -29,37 +29,25 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # is_public old_is_public="$(ynh_app_setting_get --app=$app --key=is_public)" -ynh_debug -m "old_is_public=$old_is_public" -# old_is_public=$(bool_to_true_false $old_is_public) -# ynh_debug -m "old_is_public=$old_is_public" is_public="${YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC:-$old_is_public}" -ynh_debug -m "YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC=$YNH_CONFIG_MAIN_IS_PUBLIC_IS_PUBLIC" -ynh_debug -m "is_public=$is_public" # Overwrite nginx configuration old_overwrite_nginx="$(ynh_app_setting_get --app=$app --key=overwrite_nginx)" -# old_overwrite_nginx=$(bool_to_true_false $old_overwrite_nginx) overwrite_nginx="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX:-$old_overwrite_nginx}" -ynh_debug -m "overwrite_nginx=$overwrite_nginx" # Overwrite php-fpm configuration old_overwrite_phpfpm="$(ynh_app_setting_get --app=$app --key=overwrite_phpfpm)" -# old_overwrite_phpfpm=$(bool_to_true_false $old_overwrite_phpfpm) overwrite_phpfpm="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM:-$old_overwrite_phpfpm}" -ynh_debug -m "overwrite_phpfpm=$overwrite_phpfpm" # Type of admin mail configuration old_admin_mail_html="$(ynh_app_setting_get --app=$app --key=admin_mail_html)" -# old_admin_mail_html=$(bool_to_true_false $old_admin_mail_html) admin_mail_html="${YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE:-$old_admin_mail_html}" -ynh_debug -m "admin_mail_html=$admin_mail_html" # Footprint for php-fpm old_fpm_footprint="$(ynh_app_setting_get --app=$app --key=fpm_footprint)" fpm_footprint="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FOOTPRINT:-$old_fpm_footprint}" -ynh_debug -m "fpm_footprint=$fpm_footprint" # Free footprint value for php-fpm # Check if fpm_footprint is an integer @@ -67,16 +55,15 @@ if [ "$fpm_footprint" -eq "$fpm_footprint" ] 2> /dev/null then # If fpm_footprint is an integer, that's a numeric value for the footprint old_free_footprint=$fpm_footprint + fpm_footprint=specific else old_free_footprint=0 fi free_footprint="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT:-$old_free_footprint}" -ynh_debug -m "free_footprint=$free_footprint" # Usage for php-fpm old_fpm_usage="$(ynh_app_setting_get --app=$app --key=fpm_usage)" fpm_usage="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE:-$old_fpm_usage}" -ynh_debug -m "fpm_usage=$fpm_usage" #================================================= # SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND @@ -121,10 +108,8 @@ apply_config() { #================================================= # Set overwrite_nginx -# overwrite_nginx=$(bool_to_01 $overwrite_nginx) ynh_app_setting_set --app=$app --key=overwrite_nginx --value="$overwrite_nginx" # Set overwrite_phpfpm -# overwrite_phpfpm=$(bool_to_01 $overwrite_phpfpm) ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value="$overwrite_phpfpm" #================================================= @@ -132,7 +117,6 @@ apply_config() { #================================================= # Set admin_mail_html -# admin_mail_html=$(bool_to_01 $admin_mail_html) ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html" #================================================= @@ -146,7 +130,13 @@ apply_config() { then fpm_footprint=$free_footprint fi - ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint + + if [ "$fpm_footprint" != "0" ] + then + ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint + else + ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below." + fi fi } From fba5a5ea20dd00d50178b1321063697921617d88 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 23 Sep 2019 19:01:44 +0200 Subject: [PATCH 09/26] Create CHANGELOG.md --- CHANGELOG.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..53fa643 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,53 @@ +Changelog +========= + +## Unreleased +- Nothing for now... + +## [1.8.3~ynh7](https://github.com/YunoHost-Apps/leed_ynh/pull/18) - 2019-03-12 + +#### Changed +- [Normalization from example_ynh](https://github.com/YunoHost-Apps/leed_ynh/commit/1418b13ff9c3d2f1849ad21b5c645609e3bea863) + + +## [1.8.3~ynh6](https://github.com/YunoHost-Apps/leed_ynh/pull/17) - 2019-02-03 + +#### Added +- [Add progression bar](https://github.com/YunoHost-Apps/leed_ynh/commit/9085643892836479b8c33bba6f5054512e4d441f) +* [Changelog & ahtml email](https://github.com/YunoHost-Apps/leed_ynh/commit/298f9ebf5767be9c6e163708cc69121a67aca1ed) + +#### Changed +- [Update php and nginx conf files to php7](https://github.com/YunoHost-Apps/leed_ynh/commit/1b1b0a4b906edb03a38262f9a63d9d72742480cd) + + +## [1.8.3~ynh5](https://github.com/YunoHost-Apps/leed_ynh/pull/16) - 2019-01-21 + +#### Added +- [Advertise config-panel and actions](https://github.com/YunoHost-Apps/leed_ynh/commit/c725a8e6b529d2e595022f860de58bd091390a0b) + +#### Changed +- [Update to last standart](https://github.com/YunoHost-Apps/leed_ynh/commit/92d36df30a9ea32a6c9e8a0dfa1f406fe7a49be3) + + +## [1.8.3~ynh4](https://github.com/YunoHost-Apps/leed_ynh/pull/15) - 2018-09-30 + +#### Added +* [Add Panel-config and actions](https://github.com/YunoHost-Apps/leed_ynh/commit/83253f60ff31f0ac7a4fe29e80e79c0cebbd3ad1) + + +## [1.8.3~ynh4](https://github.com/YunoHost-Apps/leed_ynh/pull/14) - 2018-08-05 + +#### Fixed +- [Fix fail2ban helper](https://github.com/YunoHost-Apps/leed_ynh/commit/c4b966ff2a977b8c0923d4f8ad403d86454883cb) + + +## [1.8.3~ynh4](https://github.com/YunoHost-Apps/leed_ynh/pull/13) - 2018-07-16 + +#### Changed +- [Upgrade helpers](https://github.com/YunoHost-Apps/leed_ynh/commit/5cb8744ee1145971518328b242edd68b7ec1310c) + + +## [1.8.3~ynh3](https://github.com/YunoHost-Apps/leed_ynh/pull/11) - 2018-03-14 + +#### Changed +- [Update helpers](https://github.com/YunoHost-Apps/leed_ynh/commit/1952ec18681135ecd13d32e53ecf86684ad1ff29) From 6c5e69757efb5e73bdd2d292c414a42096288a24 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 23 Sep 2019 19:43:53 +0200 Subject: [PATCH 10/26] Remove the old changelog --- CHANGELOG.md | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 016f18b..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,39 +0,0 @@ -Changelog -========= - -## 1.8.3~ynh7 ([2019-03-12](https://github.com/YunoHost-Apps/leed_ynh/pull/18)) - -- [Normalization from example_ynh](https://github.com/YunoHost-Apps/leed_ynh/commit/1418b13ff9c3d2f1849ad21b5c645609e3bea863) - - -## 1.8.3~ynh6 ([2019-02-03](https://github.com/YunoHost-Apps/leed_ynh/pull/17)) - -- [Add progression bar](https://github.com/YunoHost-Apps/leed_ynh/commit/9085643892836479b8c33bba6f5054512e4d441f) -* [Changelog & html email](https://github.com/YunoHost-Apps/leed_ynh/commit/298f9ebf5767be9c6e163708cc69121a67aca1ed) -- [Update php and nginx conf files to php7](https://github.com/YunoHost-Apps/leed_ynh/commit/1b1b0a4b906edb03a38262f9a63d9d72742480cd) - - -## 1.8.3~ynh5 ([2019-01-21](https://github.com/YunoHost-Apps/leed_ynh/pull/16)) - -- [Advertise config-panel and actions](https://github.com/YunoHost-Apps/leed_ynh/commit/c725a8e6b529d2e595022f860de58bd091390a0b) -- [Update to last standart](https://github.com/YunoHost-Apps/leed_ynh/commit/92d36df30a9ea32a6c9e8a0dfa1f406fe7a49be3) - - -## 1.8.3~ynh4 ([2018-09-30](https://github.com/YunoHost-Apps/leed_ynh/pull/15)) - -* [Add Panel-config and actions](https://github.com/YunoHost-Apps/leed_ynh/commit/83253f60ff31f0ac7a4fe29e80e79c0cebbd3ad1) - - -## 1.8.3~ynh4 ([2018-08-05](https://github.com/YunoHost-Apps/leed_ynh/pull/14)) - -- [Fix fail2ban helper](https://github.com/YunoHost-Apps/leed_ynh/commit/c4b966ff2a977b8c0923d4f8ad403d86454883cb) - - -## 1.8.3~ynh4 ([2018-07-16](https://github.com/YunoHost-Apps/leed_ynh/pull/13)) - -- [Upgrade helpers](https://github.com/YunoHost-Apps/leed_ynh/commit/5cb8744ee1145971518328b242edd68b7ec1310c) - - -## 1.8.3~ynh3 ([2018-03-14](https://github.com/YunoHost-Apps/leed_ynh/pull/11)) - -- [Update helpers](https://github.com/YunoHost-Apps/leed_ynh/commit/1952ec18681135ecd13d32e53ecf86684ad1ff29) From 1bd286398dccdea7512e19ce54e7164895482e74 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 25 Sep 2019 12:03:08 +0200 Subject: [PATCH 11/26] Add the changelog from #30 --- CHANGELOG.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..53fa643 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,53 @@ +Changelog +========= + +## Unreleased +- Nothing for now... + +## [1.8.3~ynh7](https://github.com/YunoHost-Apps/leed_ynh/pull/18) - 2019-03-12 + +#### Changed +- [Normalization from example_ynh](https://github.com/YunoHost-Apps/leed_ynh/commit/1418b13ff9c3d2f1849ad21b5c645609e3bea863) + + +## [1.8.3~ynh6](https://github.com/YunoHost-Apps/leed_ynh/pull/17) - 2019-02-03 + +#### Added +- [Add progression bar](https://github.com/YunoHost-Apps/leed_ynh/commit/9085643892836479b8c33bba6f5054512e4d441f) +* [Changelog & ahtml email](https://github.com/YunoHost-Apps/leed_ynh/commit/298f9ebf5767be9c6e163708cc69121a67aca1ed) + +#### Changed +- [Update php and nginx conf files to php7](https://github.com/YunoHost-Apps/leed_ynh/commit/1b1b0a4b906edb03a38262f9a63d9d72742480cd) + + +## [1.8.3~ynh5](https://github.com/YunoHost-Apps/leed_ynh/pull/16) - 2019-01-21 + +#### Added +- [Advertise config-panel and actions](https://github.com/YunoHost-Apps/leed_ynh/commit/c725a8e6b529d2e595022f860de58bd091390a0b) + +#### Changed +- [Update to last standart](https://github.com/YunoHost-Apps/leed_ynh/commit/92d36df30a9ea32a6c9e8a0dfa1f406fe7a49be3) + + +## [1.8.3~ynh4](https://github.com/YunoHost-Apps/leed_ynh/pull/15) - 2018-09-30 + +#### Added +* [Add Panel-config and actions](https://github.com/YunoHost-Apps/leed_ynh/commit/83253f60ff31f0ac7a4fe29e80e79c0cebbd3ad1) + + +## [1.8.3~ynh4](https://github.com/YunoHost-Apps/leed_ynh/pull/14) - 2018-08-05 + +#### Fixed +- [Fix fail2ban helper](https://github.com/YunoHost-Apps/leed_ynh/commit/c4b966ff2a977b8c0923d4f8ad403d86454883cb) + + +## [1.8.3~ynh4](https://github.com/YunoHost-Apps/leed_ynh/pull/13) - 2018-07-16 + +#### Changed +- [Upgrade helpers](https://github.com/YunoHost-Apps/leed_ynh/commit/5cb8744ee1145971518328b242edd68b7ec1310c) + + +## [1.8.3~ynh3](https://github.com/YunoHost-Apps/leed_ynh/pull/11) - 2018-03-14 + +#### Changed +- [Update helpers](https://github.com/YunoHost-Apps/leed_ynh/commit/1952ec18681135ecd13d32e53ecf86684ad1ff29) From 61f78c8e9ff740a294599ee780d3a598fdf9898d Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sat, 28 Sep 2019 12:38:25 +0200 Subject: [PATCH 12/26] Update scripts/_common.sh Co-Authored-By: Kayou --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index cd39857..1b3120e 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -390,7 +390,7 @@ ynh_maintenance_mode_OFF () { # Create a changelog for an app after an upgrade from the file CHANGELOG.md. # -# usage: ynh_send_readme_to_admin [--format=markdown/html/plain] [--output=changelog_file] --changelog=changelog_source] +# usage: ynh_app_changelog [--format=markdown/html/plain] [--output=changelog_file] --changelog=changelog_source] # | arg: -f --format= - Format in which the changelog will be printed # markdown: Default format. # html: Turn urls into html format. From b1c298f51a920dba4ec150f9b91a528c1eb2f8f0 Mon Sep 17 00:00:00 2001 From: maniack Date: Tue, 3 Mar 2020 19:25:18 +0100 Subject: [PATCH 13/26] Fix cron task --- conf/cron_leed | 2 +- scripts/install | 1 - scripts/upgrade | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/conf/cron_leed b/conf/cron_leed index ab38f60..a338199 100644 --- a/conf/cron_leed +++ b/conf/cron_leed @@ -1,3 +1,3 @@ # Mise a jour de leed toutes les 2 heures. -0 */2 * * * __ADMIN__ wget -q -O - "https://__DOMAIN____PATH__/action.php?action=synchronize&code=__CODESYNC__" > /dev/null 2>&1 +0 */2 * * * root wget -q -O - "https://__DOMAIN____PATH__/action.php?action=synchronize&code=__CODESYNC__" > /dev/null 2>&1 diff --git a/scripts/install b/scripts/install index 5401721..47897b3 100644 --- a/scripts/install +++ b/scripts/install @@ -132,7 +132,6 @@ code_sync=$(mysql -h localhost -u $db_name -p$db_pwd -s $db_name -e 'SELECT valu #================================================= ynh_script_progression --message="Setting up a cron file..." -ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file=../conf/cron_leed ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file=../conf/cron_leed ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file=../conf/cron_leed ynh_replace_string --match_string="__CODESYNC__" --replace_string="$code_sync" --target_file=../conf/cron_leed diff --git a/scripts/upgrade b/scripts/upgrade index feea802..a19bc6d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -191,7 +191,6 @@ code_sync=$(mysql -h localhost -u $db_name -p$db_pwd -s $db_name -e 'SELECT valu # SETUP CRON FILE FOR SYNCHRONISATION #================================================= -ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file=../conf/cron_leed ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file=../conf/cron_leed ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file=../conf/cron_leed ynh_replace_string --match_string="__CODESYNC__" --replace_string="$code_sync" --target_file=../conf/cron_leed From 29ad044421833a4c928329e87f8a7b68d7727c6b Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 19 Mar 2020 18:29:28 +0100 Subject: [PATCH 14/26] Fix php upgrade --- scripts/upgrade | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index cb9e247..91084ff 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -94,6 +94,18 @@ if [ -z "$admin_mail_html" ]; then ynh_app_setting_set --app=$app --key=admin_mail_html --value=$admin_mail_html fi +# If fpm_footprint doesn't exist, create it +if [ -z "$fpm_footprint" ]; then + fpm_footprint=low + ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint +fi + +# If fpm_usage doesn't exist, create it +if [ -z "$fpm_usage" ]; then + fpm_usage=low + ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= From 4dd609acd295ee8c3f1ed972b09e90ae3aa5a7b7 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sat, 28 Mar 2020 20:29:20 +0100 Subject: [PATCH 15/26] Add new badges --- README.md | 2 +- README_fr.md | 2 +- check_process | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 89fa168..59328b5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Leed for YunoHost -[![Integration level](https://dash.yunohost.org/integration/leed.svg)](https://dash.yunohost.org/appci/app/leed) +[![Integration level](https://dash.yunohost.org/integration/leed.svg)](https://dash.yunohost.org/appci/app/leed) ![](https://ci-apps.yunohost.org/ci/badges/leed.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/leed.maintain.svg) [![Install Leed with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=leed) *[Lire ce readme en français.](./README_fr.md)* diff --git a/README_fr.md b/README_fr.md index df3b90d..e14354c 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,6 +1,6 @@ # Leed pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/leed.svg)](https://dash.yunohost.org/appci/app/leed) +[![Niveau d'intégration](https://dash.yunohost.org/integration/leed.svg)](https://dash.yunohost.org/appci/app/leed) ![](https://ci-apps.yunohost.org/ci/badges/leed.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/leed.maintain.svg) [![Installer Leed avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=leed) *[Read this readme in english.](./README.md)* diff --git a/check_process b/check_process index feb3cfc..7db9279 100644 --- a/check_process +++ b/check_process @@ -25,7 +25,7 @@ Level 5=auto ;;; Options Email= -Notification=down +Notification=change ;;; Upgrade options ; commit=8b622d430db9ab860aee156a32086507669243fd name=MAJ 1.8.2 From a0d011b9460d11c2b65c45f5e38eac0f0c37afe4 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 9 Apr 2020 19:17:20 +0200 Subject: [PATCH 16/26] Actions and config_panel tests --- check_process | 12 ++++++++++++ scripts/actions/public_private | 7 +++++++ scripts/config | 17 ++++++++++------- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/check_process b/check_process index feb3cfc..36e8020 100644 --- a/check_process +++ b/check_process @@ -7,6 +7,16 @@ language="fr" market=1 is_public=1 (PUBLIC|public=1|private=0) + ; Actions + is_public=0|1 + ; Config_panel + main.is_public.is_public=0|1 + main.overwrite_files.overwrite_nginx=0|1 + main.overwrite_files.overwrite_phpfpm=0|1 + main.global_config.email_type=0|1 + main.php_fpm_config.footprint=low|medium|high + main.php_fpm_config.free_footprint=20 + main.php_fpm_config.usage=low|medium|high ; Checks pkg_linter=1 setup_sub_dir=1 @@ -21,6 +31,8 @@ incorrect_path=1 port_already_use=0 change_url=1 + actions=1 + config_panel=1 ;;; Levels Level 5=auto ;;; Options diff --git a/scripts/actions/public_private b/scripts/actions/public_private index ebe0cc8..2385e25 100755 --- a/scripts/actions/public_private +++ b/scripts/actions/public_private @@ -9,6 +9,13 @@ source scripts/_common.sh source /usr/share/yunohost/helpers +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # RETRIEVE ARGUMENTS #================================================= diff --git a/scripts/config b/scripts/config index 3cc2691..8e28361 100644 --- a/scripts/config +++ b/scripts/config @@ -95,13 +95,16 @@ apply_config() { # MODIFY PUBLIC ACCESSIBILITY #================================================= - # Change public accessibility - if [ $is_public -eq 1 ] - then - yunohost app action run $app public_private --args is_public=1 - else - yunohost app action run $app public_private --args is_public=0 - fi + # Change public accessibility + if [ "$is_public" != "$old_is_public" ] + then + if [ "$is_public" = "1" ] + then + yunohost app action run $app public_private --args is_public=1 + else + yunohost app action run $app public_private --args is_public=0 + fi + fi #================================================= # MODIFY OVERWRITTING SETTINGS From 6a00ef154da852e330ac0a8d0310994067a54f35 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 23 May 2020 15:23:39 +0200 Subject: [PATCH 17/26] Simpler description --- manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 29a3d27..45f8e86 100644 --- a/manifest.json +++ b/manifest.json @@ -3,8 +3,8 @@ "id": "leed", "packaging_format": 1, "description": { - "en": "Leed is a minimalistic RSS feed aggregator which allows quick and non-intrusive reading of feeds.", - "fr": "Leed est un agrégateur RSS minimaliste qui permet la consultation de flux RSS de manière rapide et non intrusive." + "en": "A minimalistic RSS feed aggregator which allows quick and non-intrusive reading of feeds.", + "fr": "Un agrégateur RSS minimaliste qui permet la consultation de flux RSS de manière rapide et non intrusive." }, "version": "1.8.3~ynh9", "url": "http://leed.idleman.fr/", From 51fcab5500679b80fdb7fec7223448bffe158f1f Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sat, 20 Jun 2020 17:56:40 +0200 Subject: [PATCH 18/26] Give up maintenance... https://github.com/YunoHost/apps/commit/60d3fbcf03a6a07d100dd2f4af0732a25cb83c8a --- manifest.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 45f8e86..6acd85f 100644 --- a/manifest.json +++ b/manifest.json @@ -10,9 +10,13 @@ "url": "http://leed.idleman.fr/", "license": "AGPL-3.0", "maintainer": { + "name": "None...", + "email": "" + }, + "previous_maintainers": [{ "name": "Maniack Crudelis", "email": "maniackc_dev@crudelis.fr" - }, + }], "requirements": { "yunohost": ">= 3.5" }, From c32a9f456228aac18b56fee239fdb1907c324e1d Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 25 Nov 2020 20:55:09 +0100 Subject: [PATCH 19/26] fix --- README.md | 6 +- README_fr.md | 6 +- conf/nginx.conf | 2 +- config_panel.toml | 14 ++-- manifest.json | 8 +-- scripts/_common.sh | 7 +- scripts/_ynh_add_fpm_config | 132 ------------------------------------ scripts/backup | 21 +++--- scripts/change_url | 4 +- scripts/config | 1 - scripts/install | 16 ++--- scripts/remove | 6 +- scripts/restore | 5 +- scripts/upgrade | 8 +-- 14 files changed, 49 insertions(+), 187 deletions(-) delete mode 100644 scripts/_ynh_add_fpm_config diff --git a/README.md b/README.md index 59328b5..f98fbe8 100644 --- a/README.md +++ b/README.md @@ -39,9 +39,8 @@ Not supported. #### Supported architectures -* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/leed%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/leed/) +* x86-64 - [![](https://ci-apps.yunohost.org/ci/logs/leed%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/leed/) * ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/leed%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/leed/) -* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/leed%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/leed/) ## Limitations @@ -56,8 +55,7 @@ Not supported. --- -Developers infos ----------------- +## Developers infos Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/leed_ynh/tree/testing). diff --git a/README_fr.md b/README_fr.md index e14354c..a96e271 100644 --- a/README_fr.md +++ b/README_fr.md @@ -39,9 +39,8 @@ Non supportée. #### Architectures supportées. -* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/leed%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/leed/) +* x86-64 - [![](https://ci-apps.yunohost.org/ci/logs/leed%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/leed/) * ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/leed%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/leed/) -* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/leed%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/leed/) ## Informations additionnelles @@ -54,8 +53,7 @@ Non supportée. --- -Informations à l'intention des développeurs ----------------- +## Informations à l'intention des développeurs Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/leed_ynh/tree/testing). diff --git a/conf/nginx.conf b/conf/nginx.conf index 55ef64e..b554f21 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -14,7 +14,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/php__PHPVERSION__-fpm-__NAME__.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; diff --git a/config_panel.toml b/config_panel.toml index 575c7a4..fdd7623 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -8,7 +8,7 @@ name = "Leed configuration" name = "Public access" [main.is_public.is_public] - ask = "Is it a public website ?" + ask = "Is it a public website?" type = "boolean" default = true help = "A public Leed will be accessible for third party apps.
By turning on 'anonymous readers' in Leed configuration, you can made your feeds public." @@ -18,13 +18,13 @@ name = "Leed configuration" name = "Overwriting config files" [main.overwrite_files.overwrite_nginx] - ask = "Overwrite the nginx config file ?" + ask = "Overwrite the nginx config file?" type = "boolean" default = true help = "If the file is overwritten, a backup will be created." [main.overwrite_files.overwrite_phpfpm] - ask = "Overwrite the php-fpm config file ?" + ask = "Overwrite the php-fpm config file?" type = "boolean" default = true help = "If the file is overwritten, a backup will be created." @@ -34,7 +34,7 @@ name = "Leed configuration" name = "Global configuration" [main.global_config.email_type] - ask = "Send HTML email to admin ?" + ask = "Send HTML email to admin?" type = "boolean" default = true help = "Allow app scripts to send HTML mails instead of plain text." @@ -44,19 +44,19 @@ name = "Leed configuration" name = "PHP-FPM configuration" [main.php_fpm_config.footprint] - ask = "Memory footprint of the service ?" + ask = "Memory footprint of the service?" choices = ["low", "medium", "high", "specific"] default = "low" help = "low <= 20Mb per pool. medium between 20Mb and 40Mb per pool. high > 40Mb per pool.
Use specific to set a value with the following option." [main.php_fpm_config.free_footprint] - ask = "Memory footprint of the service ?" + ask = "Memory footprint of the service?" type = "number" default = "0" help = "Free field to specify exactly the footprint in Mb if you don't want to use one of the three previous values." [main.php_fpm_config.usage] - ask = "Expected usage of the service ?" + ask = "Expected usage of the service?" choices = ["low", "medium", "high"] default = "low" help = "low: Personal usage, behind the sso. No RAM footprint when not used, but the impact on the processor can be high if many users are using the service.
medium: Low usage, few people or/and publicly accessible. Low RAM footprint, medium processor footprint when used.
high: High usage, frequently visited website. High RAM footprint, but lower on processor usage and quickly responding." diff --git a/manifest.json b/manifest.json index 6acd85f..b3b098b 100644 --- a/manifest.json +++ b/manifest.json @@ -3,8 +3,8 @@ "id": "leed", "packaging_format": 1, "description": { - "en": "A minimalistic RSS feed aggregator which allows quick and non-intrusive reading of feeds.", - "fr": "Un agrégateur RSS minimaliste qui permet la consultation de flux RSS de manière rapide et non intrusive." + "en": "Minimalistic RSS feed aggregator which allows quick and non-intrusive reading of feeds.", + "fr": "Agrégateur RSS minimaliste qui permet la consultation de flux RSS de manière rapide et non intrusive." }, "version": "1.8.3~ynh9", "url": "http://leed.idleman.fr/", @@ -18,7 +18,7 @@ "email": "maniackc_dev@crudelis.fr" }], "requirements": { - "yunohost": ">= 3.5" + "yunohost": ">= 3.8.1" }, "multi_instance": true, "services": [ @@ -79,7 +79,7 @@ "name": "is_public", "type": "boolean", "ask": { - "en": "Is it a public website ?", + "en": "Is it a public website?", "fr": "Est-ce un site public ?" }, "default": false, diff --git a/scripts/_common.sh b/scripts/_common.sh index 1b3120e..13f83ed 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,9 +1,12 @@ #!/bin/bash #================================================= -# PERSONAL HELPERS +# COMMON VARIABLES #================================================= +YNH_PHP_VERSION="7.3" + + #================================================= # BACKUP #================================================= @@ -69,7 +72,7 @@ ynh_multimedia_build_main_dir () { local checksum="806a827ba1902d6911095602a9221181" # Download yunohost.multimedia scripts - wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz + wget -nv https://github.com/YunoHost-Apps/yunohost.multimedia/archive/${ynh_media_release}.tar.gz 2>&1 # Check the control sum echo "${checksum} ${ynh_media_release}.tar.gz" | md5sum -c --status \ diff --git a/scripts/_ynh_add_fpm_config b/scripts/_ynh_add_fpm_config deleted file mode 100644 index 8d36834..0000000 --- a/scripts/_ynh_add_fpm_config +++ /dev/null @@ -1,132 +0,0 @@ -#!/bin/bash - -# Create a dedicated php-fpm config -# -# usage 1: ynh_add_fpm_config [--phpversion=7.X] [--use_template] -# | arg: -v, --phpversion - Version of php to use. -# | arg: -t, --use_template - Use this helper in template mode. -# -# ----------------------------------------------------------------------------- -# -# usage 2: ynh_add_fpm_config [--phpversion=7.X] --usage=usage --footprint=footprint -# | arg: -v, --phpversion - Version of php to use.# -# | arg: -f, --footprint - Memory footprint of the service (low/medium/high). -# low - Less than 20Mb of ram by pool. -# medium - Between 20Mb and 40Mb of ram by pool. -# high - More than 40Mb of ram by pool. -# Or specify exactly the footprint, the load of the service as Mb by pool instead of having a standard value. -# To have this value, use the following command and stress the service. -# watch -n0.5 ps -o user,cmd,%cpu,rss -u APP -# -# | arg: -u, --usage - Expected usage of the service (low/medium/high). -# low - Personal usage, behind the sso. -# medium - Low usage, few people or/and publicly accessible. -# high - High usage, frequently visited website. -# -# Requires YunoHost version 2.7.2 or higher. -ynh_add_fpm_config () { - # Declare an array to define the options of this helper. - local legacy_args=vtuf - declare -Ar args_array=( [v]=phpversion= [t]=use_template [u]=usage= [f]=footprint= ) - local phpversion - local use_template - local usage - local footprint - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - # The default behaviour is to use the template. - use_template="${use_template:-1}" - usage="${usage:-}" - footprint="${footprint:-}" - if [ -n "$usage" ] || [ -n "$footprint" ]; then - use_template=0 - fi - - # Configure PHP-FPM 7.0 by default - phpversion="${phpversion:-7.0}" - - local fpm_config_dir="/etc/php/$phpversion/fpm" - local fpm_service="php${phpversion}-fpm" - # Configure PHP-FPM 5 on Debian Jessie - if [ "$(ynh_get_debian_release)" == "jessie" ]; then - fpm_config_dir="/etc/php5/fpm" - fpm_service="php5-fpm" - fi - ynh_app_setting_set --app=$app --key=fpm_config_dir --value="$fpm_config_dir" - ynh_app_setting_set --app=$app --key=fpm_service --value="$fpm_service" - finalphpconf="$fpm_config_dir/pool.d/$app.conf" - ynh_backup_if_checksum_is_different --file="$finalphpconf" - - if [ $use_template -eq 1 ] - then - # Usage 1, use the template in ../conf/php-fpm.conf - sudo cp ../conf/php-fpm.conf "$finalphpconf" - ynh_replace_string --match_string="__NAMETOCHANGE__" --replace_string="$app" --target_file="$finalphpconf" - ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$finalphpconf" - ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="$finalphpconf" - ynh_replace_string --match_string="__PHPVERSION__" --replace_string="$phpversion" --target_file="$finalphpconf" - - else - # Store settings - ynh_app_setting_set --app=$app --key=fpm_footprint --value=$footprint - ynh_app_setting_set --app=$app --key=fpm_usage --value=$usage - - # Usage 2, generate a php-fpm config file with ynh_get_scalable_phpfpm - ynh_get_scalable_phpfpm --usage=$usage --footprint=$footprint - - # Copy the default file - sudo cp "$fpm_config_dir/pool.d/www.conf" "$finalphpconf" - - # Replace standard variables into the default file - ynh_replace_string --match_string="^\[www\]" --replace_string="[$app]" --target_file="$finalphpconf" - ynh_replace_string --match_string=".*listen = .*" --replace_string="listen = /var/run/php/php7.0-fpm-$app.sock" --target_file="$finalphpconf" - ynh_replace_string --match_string="^user = .*" --replace_string="user = $app" --target_file="$finalphpconf" - ynh_replace_string --match_string="^group = .*" --replace_string="group = $app" --target_file="$finalphpconf" - ynh_replace_string --match_string=".*chdir = .*" --replace_string="chdir = $final_path" --target_file="$finalphpconf" - - # Configure fpm children - ynh_replace_string --match_string=".*pm = .*" --replace_string="pm = $php_pm" --target_file="$finalphpconf" - ynh_replace_string --match_string=".*pm.max_children = .*" --replace_string="pm.max_children = $php_max_children" --target_file="$finalphpconf" - ynh_replace_string --match_string=".*pm.max_requests = .*" --replace_string="pm.max_requests = 500" --target_file="$finalphpconf" - ynh_replace_string --match_string=".*request_terminate_timeout = .*" --replace_string="request_terminate_timeout = 1d" --target_file="$finalphpconf" - if [ "$php_pm" = "dynamic" ] - then - ynh_replace_string --match_string=".*pm.start_servers = .*" --replace_string="pm.start_servers = $php_start_servers" --target_file="$finalphpconf" - ynh_replace_string --match_string=".*pm.min_spare_servers = .*" --replace_string="pm.min_spare_servers = $php_min_spare_servers" --target_file="$finalphpconf" - ynh_replace_string --match_string=".*pm.max_spare_servers = .*" --replace_string="pm.max_spare_servers = $php_max_spare_servers" --target_file="$finalphpconf" - elif [ "$php_pm" = "ondemand" ] - then - ynh_replace_string --match_string=".*pm.process_idle_timeout = .*" --replace_string="pm.process_idle_timeout = 10s" --target_file="$finalphpconf" - fi - - # Comment unused parameters - if [ "$php_pm" != "dynamic" ] - then - ynh_replace_string --match_string=".*\(pm.start_servers = .*\)" --replace_string=";\1" --target_file="$finalphpconf" - ynh_replace_string --match_string=".*\(pm.min_spare_servers = .*\)" --replace_string=";\1" --target_file="$finalphpconf" - ynh_replace_string --match_string=".*\(pm.max_spare_servers = .*\)" --replace_string=";\1" --target_file="$finalphpconf" - fi - if [ "$php_pm" != "ondemand" ] - then - ynh_replace_string --match_string=".*\(pm.process_idle_timeout = .*\)" --replace_string=";\1" --target_file="$finalphpconf" - fi - - # Concatene the extra config. - if [ -e ../conf/extra_php-fpm.conf ]; then - cat ../conf/extra_php-fpm.conf >> "$finalphpconf" - fi - fi - sudo chown root: "$finalphpconf" - ynh_store_file_checksum --file="$finalphpconf" - - if [ -e "../conf/php-fpm.ini" ] - then - echo "Packagers ! Please do not use a separate php ini file, merge your directives in the pool file instead." >&2 - finalphpini="$fpm_config_dir/conf.d/20-$app.ini" - ynh_backup_if_checksum_is_different "$finalphpini" - sudo cp ../conf/php-fpm.ini "$finalphpini" - sudo chown root: "$finalphpini" - ynh_store_file_checksum "$finalphpini" - fi - ynh_systemd_action --service_name=$fpm_service --action=reload -} diff --git a/scripts/backup b/scripts/backup index 92c98ac..2844c17 100644 --- a/scripts/backup +++ b/scripts/backup @@ -19,50 +19,46 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= -# STANDARD BACKUP STEPS +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_script_progression --message="Backing up the main app directory..." -CHECK_SIZE "$final_path" ynh_backup --src_path="$final_path" #================================================= # BACKUP 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 PHP-FPM CONFIGURATION #================================================= -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/$phpversion/fpm/pool.d/$app.conf" #================================================= # BACKUP THE MYSQL DATABASE #================================================= -ynh_script_progression --message="Backing up the MySQL database..." --weight=2 ynh_mysql_dump_db --database="$db_name" > db.sql -CHECK_SIZE "db.sql" #================================================= # BACKUP FAIL2BAN CONFIGURATION #================================================= -ynh_script_progression --message="Backing up fail2ban configuration" ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" @@ -72,7 +68,6 @@ ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" #================================================= # BACKUP THE CRON FILE #================================================= -ynh_script_progression --message="Backing up cron file" ynh_backup --src_path="/etc/cron.d/$app" @@ -80,4 +75,4 @@ ynh_backup --src_path="/etc/cron.d/$app" # END OF SCRIPT #================================================= -ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index 18780af..e3f6fc2 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -65,7 +65,7 @@ ynh_abort_if_errors #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating nginx web server configuration..." --weight=2 +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2 nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -121,7 +121,7 @@ ynh_mysql_execute_as_root --sql="UPDATE leed_configuration SET value='$domain_pa #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/config b/scripts/config index 8e28361..1298891 100644 --- a/scripts/config +++ b/scripts/config @@ -8,7 +8,6 @@ source _common.sh source /usr/share/yunohost/helpers -source _ynh_add_fpm_config #================================================= # RETRIEVE ARGUMENTS diff --git a/scripts/install b/scripts/install index 47897b3..e3d7f38 100644 --- a/scripts/install +++ b/scripts/install @@ -8,7 +8,6 @@ source _common.sh source /usr/share/yunohost/helpers -source _ynh_add_fpm_config #================================================= # MANAGE FAILURE OF THE SCRIPT @@ -77,9 +76,9 @@ ynh_setup_source --dest_dir="$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." --weight=2 +ynh_script_progression --message="Configuring NGINX web server..." --weight=2 -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= @@ -93,17 +92,18 @@ ynh_system_user_create --username=$app #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring php-fpm..." --weight=2 +ynh_script_progression --message="Configuring PHP-FPM..." --weight=2 -# Create a dedicated php-fpm config +# Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=low --footprint=low +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # SPECIFIC SETUP #================================================= # SETTING UP WITH CURL #================================================= -ynh_script_progression --message="Installing Leed with Curl..." --weight=5 +ynh_script_progression --message="Installing Leed with cURL..." --weight=5 # Set right permissions for curl install chown -R $app: $final_path @@ -152,7 +152,7 @@ chown -R $app $final_path/cache $final_path/plugins $final_path/updates #================================================= # SETUP FAIL2BAN #================================================= -ynh_script_progression --message="Configuring fail2ban..." --weight=9 +ynh_script_progression --message="Configuring Fail2Ban..." --weight=9 # Create a dedicated fail2ban config ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="PHP message: Leed: wrong login for .* client: " --max_retry=5 @@ -175,7 +175,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=3 +ynh_script_progression --message="Reloading NGINX web server..." --weight=3 ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/remove b/scripts/remove index 9536285..1d5b879 100644 --- a/scripts/remove +++ b/scripts/remove @@ -49,15 +49,15 @@ ynh_remove_nginx_config #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Removing php-fpm configuration..." +ynh_script_progression --message="Removing PHP-FPM configuration..." -# Remove the dedicated php-fpm config +# Remove the dedicated PHP-FPM config ynh_remove_fpm_config #================================================= # REMOVE FAIL2BAN CONFIGURATION #================================================= -ynh_script_progression --message="Removing fail2ban configuration..." --weight=5 +ynh_script_progression --message="Removing Fail2Ban configuration..." --weight=5 # Remove the dedicated fail2ban config ynh_remove_fail2ban_config diff --git a/scripts/restore b/scripts/restore index 49ffc06..ed832c7 100644 --- a/scripts/restore +++ b/scripts/restore @@ -28,6 +28,7 @@ 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) admin=$(ynh_app_setting_get --app=$app --key=admin) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -82,7 +83,7 @@ ynh_system_user_create --username=$app # 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/$phpversion/fpm/pool.d/$app.conf" #================================================= # RESTORE FAIL2BAN CONFIGURATION @@ -114,7 +115,7 @@ chown -R $app $final_path/cache $final_path/plugins $final_path/updates #================================================= 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=php${phpversion}-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index ae644c3..7b71359 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -8,7 +8,6 @@ source _common.sh source /usr/share/yunohost/helpers -source _ynh_add_fpm_config #================================================= # LOAD SETTINGS @@ -31,6 +30,7 @@ admin_mail_html=$(ynh_app_setting_get --app=$app --key=admin_mail_html) fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage) +phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # CHECK VERSION @@ -186,7 +186,7 @@ ynh_system_user_create --username=$app # Overwrite the php-fpm configuration only if it's allowed if [ $overwrite_phpfpm -eq 1 ] then - ynh_script_progression --message="Upgrading php-fpm configuration..." --weight=2 + ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=2 # Create a dedicated php-fpm config ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint fi @@ -226,7 +226,7 @@ chown -R $app $final_path/cache $final_path/plugins $final_path/updates if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading Leed with curl..." --weight=4 + ynh_script_progression --message="Upgrading Leed with cURL..." --weight=4 # Set the app as temporarily public for curl call ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" # Regen SSOwat configuration @@ -240,7 +240,7 @@ fi #================================================= # UPGRADE FAIL2BAN #================================================= -ynh_script_progression --message="Reconfiguring fail2ban..." --weight=8 +ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=8 # Create a dedicated fail2ban config ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="PHP message: Leed: wrong login for .* client: " --max_retry=5 From 1a34c25797cddd2314236e245b4e3347dd6b0b6d Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 25 Nov 2020 21:07:33 +0100 Subject: [PATCH 20/26] Fix --- README.md | 2 +- README_fr.md | 14 +++++++------- scripts/backup | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f98fbe8..33b48c2 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Use the admin panel of your Leed to configure this app. ## YunoHost specific features -* Login secured by fail2ban +* Login secured by Fail2Ban #### Multi-users support diff --git a/README_fr.md b/README_fr.md index a96e271..0328af2 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,7 +11,7 @@ Si vous n'avez pas YunoHost, merci de regarder [ici](https://yunohost.org/#/inst ## Résumé Leed (contraction de Light Feed) est un agrégateur RSS/ATOM minimaliste qui permet la consultation de flux RSS de manière rapide et non intrusive. -**Version embarquée:** 1.8.3 +**Version embarquée :** 1.8.3 ## Captures d'écran @@ -27,11 +27,11 @@ Utiliser le panneau d'administration de votre Jenkins pour configurer cette appl ## Documentation - * Documentation YunoHost: Il n'y a pas d'autre documentation, n'hésitez pas à contribuer. + * Documentation YunoHost : Il n'y a pas d'autre documentation, n'hésitez pas à contribuer. ## Fonctionnalités spécifiques à YunoHost -* Login sécurisé par fail2ban +* Login sécurisé par Fail2Ban #### Support multi-utilisateurs @@ -46,10 +46,10 @@ Non supportée. ## Liens - * Reporter un bug: https://github.com/YunoHost-Apps/leed_ynh/issues - * Site de Leed: http://leed.idleman.fr/ - * Dépôt de Leed: http://git.idleman.fr/LeedRSS/Leed - * Site de YunoHost: https://yunohost.org/ + * Reporter un bug : https://github.com/YunoHost-Apps/leed_ynh/issues + * Site de Leed : http://leed.idleman.fr/ + * Dépôt de Leed : http://git.idleman.fr/LeedRSS/Leed + * Site de YunoHost : https://yunohost.org/ --- diff --git a/scripts/backup b/scripts/backup index 2844c17..ebed36f 100644 --- a/scripts/backup +++ b/scripts/backup @@ -26,6 +26,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get --app=$app --key=final_path) domain=$(ynh_app_setting_get --app=$app --key=domain) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # DECLARE DATA AND CONF FILES TO BACKUP From 1087db6518af4d4569b60b8c9b6630e408025524 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Wed, 25 Nov 2020 21:09:16 +0100 Subject: [PATCH 21/26] Update _common.sh --- scripts/_common.sh | 179 --------------------------------------------- 1 file changed, 179 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 13f83ed..48e4ad8 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -286,30 +286,6 @@ __PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/service #================================================= -ynh_debian_release () { - lsb_release --codename --short -} - -is_stretch () { - if [ "$(ynh_debian_release)" == "stretch" ] - then - return 0 - else - return 1 - fi -} - -is_jessie () { - if [ "$(ynh_debian_release)" == "jessie" ] - then - return 0 - else - return 1 - fi -} - -#================================================= - ynh_maintenance_mode_ON () { # Load value of $path_url and $domain from the config if their not set if [ -z $path_url ]; then @@ -599,158 +575,3 @@ ynh_check_ram () { echo $ram fi } - -#================================================= - -# Define the values to configure php-fpm -# -# usage: ynh_get_scalable_phpfpm --usage=usage --footprint=footprint [--print] -# | arg: -f, --footprint - Memory footprint of the service (low/medium/high). -# low - Less than 20Mb of ram by pool. -# medium - Between 20Mb and 40Mb of ram by pool. -# high - More than 40Mb of ram by pool. -# Or specify exactly the footprint, the load of the service as Mb by pool instead of having a standard value. -# To have this value, use the following command and stress the service. -# watch -n0.5 ps -o user,cmd,%cpu,rss -u APP -# -# | arg: -u, --usage - Expected usage of the service (low/medium/high). -# low - Personal usage, behind the sso. -# medium - Low usage, few people or/and publicly accessible. -# high - High usage, frequently visited website. -# -# | arg: -p, --print - Print the result -# -# -# -# The footprint of the service will be used to defined the maximum footprint we can allow, which is half the maximum RAM. -# So it will be used to defined 'pm.max_children' -# A lower value for the footprint will allow more children for 'pm.max_children'. And so for -# 'pm.start_servers', 'pm.min_spare_servers' and 'pm.max_spare_servers' which are defined from the -# value of 'pm.max_children' -# NOTE: 'pm.max_children' can't exceed 4 times the number of processor's cores. -# -# The usage value will defined the way php will handle the children for the pool. -# A value set as 'low' will set the process manager to 'ondemand'. Children will start only if the -# service is used, otherwise no child will stay alive. This config gives the lower footprint when the -# service is idle. But will use more proc since it has to start a child as soon it's used. -# Set as 'medium', the process manager will be at dynamic. If the service is idle, a number of children -# equal to pm.min_spare_servers will stay alive. So the service can be quick to answer to any request. -# The number of children can grow if needed. The footprint can stay low if the service is idle, but -# not null. The impact on the proc is a little bit less than 'ondemand' as there's always a few -# children already available. -# Set as 'high', the process manager will be set at 'static'. There will be always as many children as -# 'pm.max_children', the footprint is important (but will be set as maximum a quarter of the maximum -# RAM) but the impact on the proc is lower. The service will be quick to answer as there's always many -# children ready to answer. -ynh_get_scalable_phpfpm () { - local legacy_args=ufp - # Declare an array to define the options of this helper. - declare -Ar args_array=( [u]=usage= [f]=footprint= [p]=print ) - local usage - local footprint - local print - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - # Set all characters as lowercase - footprint=${footprint,,} - usage=${usage,,} - print=${print:-0} - - if [ "$footprint" = "low" ] - then - footprint=20 - elif [ "$footprint" = "medium" ] - then - footprint=35 - elif [ "$footprint" = "high" ] - then - footprint=50 - fi - - # Define the way the process manager handle child processes. - if [ "$usage" = "low" ] - then - php_pm=ondemand - elif [ "$usage" = "medium" ] - then - php_pm=dynamic - elif [ "$usage" = "high" ] - then - php_pm=static - else - ynh_die --message="Does not recognize '$usage' as an usage value." - fi - - # Get the total of RAM available, except swap. - local max_ram=$(ynh_check_ram --no_swap) - - less0() { - # Do not allow value below 1 - if [ $1 -le 0 ] - then - echo 1 - else - echo $1 - fi - } - - # Define pm.max_children - # The value of pm.max_children is the total amount of ram divide by 2 and divide again by the footprint of a pool for this app. - # So if php-fpm start the maximum of children, it won't exceed half of the ram. - php_max_children=$(( $max_ram / 2 / $footprint )) - # If process manager is set as static, use half less children. - # Used as static, there's always as many children as the value of pm.max_children - if [ "$php_pm" = "static" ] - then - php_max_children=$(( $php_max_children / 2 )) - fi - php_max_children=$(less0 $php_max_children) - - # To not overload the proc, limit the number of children to 4 times the number of cores. - local core_number=$(nproc) - local max_proc=$(( $core_number * 4 )) - if [ $php_max_children -gt $max_proc ] - then - php_max_children=$max_proc - fi - - if [ "$php_pm" = "dynamic" ] - then - # Define pm.start_servers, pm.min_spare_servers and pm.max_spare_servers for a dynamic process manager - php_min_spare_servers=$(( $php_max_children / 8 )) - php_min_spare_servers=$(less0 $php_min_spare_servers) - - php_max_spare_servers=$(( $php_max_children / 2 )) - php_max_spare_servers=$(less0 $php_max_spare_servers) - - php_start_servers=$(( $php_min_spare_servers + ( $php_max_spare_servers - $php_min_spare_servers ) /2 )) - php_start_servers=$(less0 $php_start_servers) - else - php_min_spare_servers=0 - php_max_spare_servers=0 - php_start_servers=0 - fi - - if [ $print -eq 1 ] - then - ynh_debug --message="Footprint=${footprint}Mb by pool." - ynh_debug --message="Process manager=$php_pm" - ynh_debug --message="Max RAM=${max_ram}Mb" - if [ "$php_pm" != "static" ]; then - ynh_debug --message="\nMax estimated footprint=$(( $php_max_children * $footprint ))" - ynh_debug --message="Min estimated footprint=$(( $php_min_spare_servers * $footprint ))" - fi - if [ "$php_pm" = "dynamic" ]; then - ynh_debug --message="Estimated average footprint=$(( $php_max_spare_servers * $footprint ))" - elif [ "$php_pm" = "static" ]; then - ynh_debug --message="Estimated footprint=$(( $php_max_children * $footprint ))" - fi - ynh_debug --message="\nRaw php-fpm values:" - ynh_debug --message="pm.max_children = $php_max_children" - if [ "$php_pm" = "dynamic" ]; then - ynh_debug --message="pm.start_servers = $php_start_servers" - ynh_debug --message="pm.min_spare_servers = $php_min_spare_servers" - ynh_debug --message="pm.max_spare_servers = $php_max_spare_servers" - fi - fi -} From f367f1e1e46ddb5012d45834a5f564e99ba38489 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 8 Dec 2020 10:03:31 +0100 Subject: [PATCH 22/26] Fix --- check_process | 3 --- conf/app.src | 4 ++-- scripts/upgrade | 7 ------- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/check_process b/check_process index 98ced26..fa02326 100644 --- a/check_process +++ b/check_process @@ -28,13 +28,10 @@ upgrade=1 from_commit=8b622d430db9ab860aee156a32086507669243fd backup_restore=1 multi_instance=1 - incorrect_path=1 port_already_use=0 change_url=1 actions=1 config_panel=1 -;;; Levels - Level 5=auto ;;; Options Email= Notification=change diff --git a/conf/app.src b/conf/app.src index e99d6c0..b6c2d9f 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,6 +1,6 @@ SOURCE_URL=https://github.com/LeedRSS/Leed/archive/v1.8.3.tar.gz -SOURCE_SUM=4fb46124695dfc8e6a3bfa5e48850547 -SOURCE_SUM_PRG=md5sum +SOURCE_SUM=792215b9a4429c66ac52b4619fbda4b664c83ef03543a62a8b58e2c631874001 +SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true SOURCE_FILENAME= diff --git a/scripts/upgrade b/scripts/upgrade index 7b71359..80e3ab7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -132,13 +132,6 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors -#================================================= -# CHECK THE PATH -#================================================= - -# Normalize the URL path syntax -path_url=$(ynh_normalize_url_path --path_url=$path_url) - #================================================= # ACTIVATE MAINTENANCE MODE #================================================= From bdb0190c0cc5410354be43ae37a6544244037911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 20 Dec 2020 09:44:28 +0100 Subject: [PATCH 23/26] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 33b48c2..67d703e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Leed for YunoHost [![Integration level](https://dash.yunohost.org/integration/leed.svg)](https://dash.yunohost.org/appci/app/leed) ![](https://ci-apps.yunohost.org/ci/badges/leed.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/leed.maintain.svg) -[![Install Leed with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=leed) +[![Install Leed with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=leed) *[Lire ce readme en français.](./README_fr.md)* From d4e7ca0097fb0e4910f913e44e0a47a1a44d7cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 20 Dec 2020 09:44:58 +0100 Subject: [PATCH 24/26] Update README_fr.md --- README_fr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_fr.md b/README_fr.md index 0328af2..9ba302b 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,7 +1,7 @@ # Leed pour YunoHost [![Niveau d'intégration](https://dash.yunohost.org/integration/leed.svg)](https://dash.yunohost.org/appci/app/leed) ![](https://ci-apps.yunohost.org/ci/badges/leed.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/leed.maintain.svg) -[![Installer Leed avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=leed) +[![Installer Leed avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=leed) *[Read this readme in english.](./README.md)* From 3afa115aec2c00e42f18cd76b6c9f90cec7760db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Fri, 8 Jan 2021 10:48:51 +0100 Subject: [PATCH 25/26] Version change --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index b3b098b..e72ccb7 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Minimalistic RSS feed aggregator which allows quick and non-intrusive reading of feeds.", "fr": "Agrégateur RSS minimaliste qui permet la consultation de flux RSS de manière rapide et non intrusive." }, - "version": "1.8.3~ynh9", + "version": "1.8.3~ynh10", "url": "http://leed.idleman.fr/", "license": "AGPL-3.0", "maintainer": { From c0b5ef64711abf9784e007d9ea6c6009c1f1f437 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 8 Jan 2021 10:58:15 +0100 Subject: [PATCH 26/26] Small fixes --- README.md | 2 +- README_fr.md | 4 ++-- conf/cron_leed | 2 +- scripts/_common.sh | 23 ----------------------- 4 files changed, 4 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 67d703e..95c765f 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ *[Lire ce readme en français.](./README_fr.md)* -> *This package allow you to install leed quickly and simply on a YunoHost server. +> *This package allow you to install Leed quickly and simply on a YunoHost server. If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* ## Overview diff --git a/README_fr.md b/README_fr.md index 9ba302b..27dda6a 100644 --- a/README_fr.md +++ b/README_fr.md @@ -5,7 +5,7 @@ *[Read this readme in english.](./README.md)* -> *Ce package vous permet d'installer leed rapidement et simplement sur un serveur YunoHost. +> *Ce package vous permet d'installer Leed rapidement et simplement sur un serveur YunoHost. Si vous n'avez pas YunoHost, merci de regarder [ici](https://yunohost.org/#/install_fr) pour savoir comment l'installer et en profiter.* ## Résumé @@ -23,7 +23,7 @@ Aucune démo pour cette application. ## Configuration -Utiliser le panneau d'administration de votre Jenkins pour configurer cette application. +Utiliser le panneau d'administration de votre Leed pour configurer cette application. ## Documentation diff --git a/conf/cron_leed b/conf/cron_leed index a338199..dc66ef7 100644 --- a/conf/cron_leed +++ b/conf/cron_leed @@ -1,3 +1,3 @@ -# Mise a jour de leed toutes les 2 heures. +# Mise a jour de Leed toutes les 2 heures. 0 */2 * * * root wget -q -O - "https://__DOMAIN____PATH__/action.php?action=synchronize&code=__CODESYNC__" > /dev/null 2>&1 diff --git a/scripts/_common.sh b/scripts/_common.sh index 48e4ad8..a7ea7cb 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,29 +6,6 @@ YNH_PHP_VERSION="7.3" - -#================================================= -# BACKUP -#================================================= - -HUMAN_SIZE () { # Transforme une taille en Ko en une taille lisible pour un humain - human=$(numfmt --to=iec --from-unit=1K $1) - echo $human -} - -CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant - file_to_analyse=$1 - backup_size=$(du --summarize "$file_to_analyse" | cut -f1) - free_space=$(df --output=avail "/home/yunohost.backup" | sed 1d) - - if [ $free_space -le $backup_size ] - then - ynh_print_err "Espace insuffisant pour sauvegarder $file_to_analyse." - ynh_print_err "Espace disponible: $(HUMAN_SIZE $free_space)" - ynh_die "Espace nécessaire: $(HUMAN_SIZE $backup_size)" - fi -} - #================================================= # PACKAGE CHECK BYPASSING... #=================================================