From c70dc07af9da7d97c9ea8bfab89dd5ffa8882112 Mon Sep 17 00:00:00 2001 From: maniack Date: Mon, 9 Dec 2019 18:09:01 +0100 Subject: [PATCH 01/24] Update to last standard --- check_process | 2 -- scripts/remove | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/check_process b/check_process index 1149ba5..db8b294 100644 --- a/check_process +++ b/check_process @@ -12,7 +12,6 @@ upgrade=1 from_commit=2c107b09144c9829be5cc94b202d0f766b2a0db4 backup_restore=1 multi_instance=0 - incorrect_path=0 port_already_use=1 (48200) change_url=0 ;; Test paquet backports @@ -27,7 +26,6 @@ upgrade=1 backup_restore=0 multi_instance=0 - incorrect_path=0 port_already_use=0 change_url=0 ;;; Levels diff --git a/scripts/remove b/scripts/remove index 942e5ab..bc1f48e 100755 --- a/scripts/remove +++ b/scripts/remove @@ -25,7 +25,7 @@ port=$(ynh_app_setting_get $app port) #================================================= # Check if the service is declared in YunoHost -if yunohost service status | grep -q minidlna +if ynh_exec_fully_quiet yunohost service status minidlna then ynh_print_info "Remove minidlna service" >&2 yunohost service remove minidlna From 6ce3fed427c315e81a37c595a5a68de326f8ccf2 Mon Sep 17 00:00:00 2001 From: maniack Date: Sat, 14 Mar 2020 20:25:45 +0100 Subject: [PATCH 02/24] Add changelog --- CHANGELOG.md | 29 +++++++++ scripts/_common.sh | 143 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 162 insertions(+), 10 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..146762e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,29 @@ +Changelog +========= + +## Unreleased +- Nothing for now... + +## [1.0~ynh5](https://github.com/YunoHost-Apps/minidlna_ynh/pull/14) - 2019-02-03 + +#### Added +- [Add progression bar](https://github.com/YunoHost-Apps/minidlna_ynh/pull/14/commits/be7ea84d8ffd37175b424d040918c458047fecf9) +* [Changelog & html email](https://github.com/YunoHost-Apps/minidlna_ynh/pull/14/commits/ad18af04b853609f0d5c6089a035671ce2e0d96f) + + +## [1.0~ynh4](https://github.com/YunoHost-Apps/minidlna_ynh/pull/13) - 2019-01-21 + +#### Changed +- [Update to last standart](https://github.com/YunoHost-Apps/minidlna_ynh/pull/13/commits/c51297661c89a304f585d973fa5caa24c275036b) + + +## [1.0~ynh3](https://github.com/YunoHost-Apps/minidlna_ynh/pull/12) - 2018-09-30 + +#### Added +- [Panel-config + actions fully tested](https://github.com/YunoHost-Apps/minidlna_ynh/pull/12/commits/945664af7e4215c099d7b623d74a57207bdf7dae) + + +## [1.0~ynh3](https://github.com/YunoHost-Apps/minidlna_ynh/pull/01) - 2018-07-16 + +#### Changed +- [Upgrade helpers](https://github.com/YunoHost-Apps/minidlna_ynh/pull/11/commits/e344e99aef40915c63f97d6f82fe50c5ff07af0d) diff --git a/scripts/_common.sh b/scripts/_common.sh index e74bc0f..f2837b0 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -730,18 +730,141 @@ 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_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. +# 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 +# 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} + + local original_changelog="$changelog" + local temp_changelog="changelog_temp" + local final_changelog="$output" + + if [ ! -n "$original_changelog" ] + then + echo "No changelog available..." > "$final_changelog" + echo "No changelog available..." > "${final_changelog}_lite" + return 0 + fi + + 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") + + # 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 + + # 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" + + # 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 + + # 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 (\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 + # 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 +} # # usage: ynh_download_file --dest_dir="/destination/directory" [--source_id=myfile] # | arg: -d, --dest_dir= - Directory where to download the file From bf41e7cf740153569d65df0187f222579c4404c8 Mon Sep 17 00:00:00 2001 From: maniack Date: Sat, 14 Mar 2020 20:26:24 +0100 Subject: [PATCH 03/24] Use toml for actions and config-panel --- actions.json | 25 ------------------------ actions.toml | 12 ++++++++++++ config_panel.json | 49 ----------------------------------------------- config_panel.toml | 39 +++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 74 deletions(-) delete mode 100644 actions.json create mode 100644 actions.toml delete mode 100644 config_panel.json create mode 100644 config_panel.toml diff --git a/actions.json b/actions.json deleted file mode 100644 index 721047f..0000000 --- a/actions.json +++ /dev/null @@ -1,25 +0,0 @@ -[{ - "id": "install_standard", - "name": "Install the version from stable repository", - "command": "/bin/bash scripts/actions/install_standard", - "user": "root", - "accepted_return_codes": [0] -}, -{ - "id": "install_backports", - "name": "Install the version from backports repository", - "command": "/bin/bash scripts/actions/install_backports", - "user": "root", - "accepted_return_codes": [0] -}, -{ - "id": "reset_db", - "name": "Reinitialise the database", - "command": "/bin/bash scripts/actions/reset_db", - "user": "root", - "accepted_return_codes": [0], - "description": { - "en": "Remove the database and force Minidlna to create a new one.", - "fr": "Supprime la base de donnée et force Minidlna a en recréer une nouvelle." - } -}] diff --git a/actions.toml b/actions.toml new file mode 100644 index 0000000..b5f7183 --- /dev/null +++ b/actions.toml @@ -0,0 +1,12 @@ +[install_standard] +name = "Install the version from stable repository" +command = "/bin/bash scripts/actions/install_standard" + +[install_backports] +name = "Install the version from backports repository" +command = "/bin/bash scripts/actions/install_backports" + +[reset_db] +name = "Reinitialise the database" +command = "/bin/bash scripts/actions/reset_db" +description = "Remove the database and force Minidlna to create a new one." diff --git a/config_panel.json b/config_panel.json deleted file mode 100644 index af55156..0000000 --- a/config_panel.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "name": "Minidlna configuration panel", - "version": "0.1", - "panel": [{ - "name": "Minidlna configuration", - "id": "main", - "sections": [{ - "name": "Minidlna configuration", - "id": "minidlna_configuration", - "options": [{ - "name": "Type of directory shown to the clients ?", - "help": "We can't use a choices field for now. In the meantime please choose between one of this values:
Standard container, Browse Directory, Music, Pictures or Video.", - "id": "root_container", - "type": "text", - "//": "\"choices\" : [\"Standard container\", \"Browse Directory\", \"Music\", \"Pictures\", \"Video\"]", - "default" : "Browse Directory" - }, - { - "name": "Name of DLNA server shown to clients ?", - "id": "friendly_name", - "type": "text", - "default": "Yunohost DLNA" - }] - }, - { - "name": "Overwriting config files", - "id": "overwrite_files", - "options": [{ - "name": "Overwrite the config file minidlna.conf ?", - "help": "If the file is overwritten, a backup will be created.", - "id": "overwrite_settings", - "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 - }] - }] - } -] -} diff --git a/config_panel.toml b/config_panel.toml new file mode 100644 index 0000000..7695e53 --- /dev/null +++ b/config_panel.toml @@ -0,0 +1,39 @@ +version = "0.1" +name = "Minidlna configuration panel" + + +[main] +name = "Minidlna configuration" + + [main.minidlna_configuration] + name = "Minidlna configuration" + + [main.minidlna_configuration.root_container] + ask = "Type of directory shown to the clients ?" + choices = ["Standard container", "Browse Directory", "Music", "Pictures", "Video"] + default = "Browse Directory" + + [main.minidlna_configuration.friendly_name] + ask = "Name of DLNA server shown to clients ?" + type = "text" + default = "Yunohost DLNA" + + + [main.overwrite_files] + name = "Overwriting config files" + + [main.overwrite_files.overwrite_settings] + ask = "Overwrite the config file minidlna.conf ?" + 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." From 438fbf903eec1ebe3fde7e7554d3a6c11360dc42 Mon Sep 17 00:00:00 2001 From: maniack Date: Sat, 14 Mar 2020 20:27:03 +0100 Subject: [PATCH 04/24] Update helpers --- scripts/_common.sh | 692 +++++++++++++++------------------------------ 1 file changed, 231 insertions(+), 461 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index f2837b0..3770c0f 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,5 +1,9 @@ #!/bin/bash +#================================================= +# PERSONAL HELPERS +#================================================= + #================================================= # BACKUP #================================================= @@ -27,25 +31,12 @@ CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant #================================================= IS_PACKAGE_CHECK () { - return $(env | grep -c container=lxc) -} - -#================================================= -# BOOLEAN CONVERTER -#================================================= - -bool_to_01 () { - local var="$1" - [ "$var" = "true" ] && var=1 - [ "$var" = "false" ] && var=0 - echo "$var" -} - -bool_to_true_false () { - local var="$1" - [ "$var" = "1" ] && var=true - [ "$var" = "0" ] && var=false - echo "$var" + if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ] + then + return 0 + else + return 1 + fi } #================================================= @@ -129,359 +120,6 @@ ynh_multimedia_addaccess () { usermod -a -G multimedia $user_name } -#================================================= - -# Create a dedicated fail2ban config (jail and filter conf files) -# -# usage: ynh_add_fail2ban_config log_file filter [max_retry [ports]] -# | arg: -l, --logpath= - Log file to be checked by fail2ban -# | arg: -r, --failregex= - Failregex to be looked for by fail2ban -# | arg: -m, --max_retry= - Maximum number of retries allowed before banning IP address - default: 3 -# | arg: -p, --ports= - Ports blocked for a banned IP address - default: http,https -ynh_add_fail2ban_config () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [l]=logpath= [r]=failregex= [m]=max_retry= [p]=ports= ) - local logpath - local failregex - local max_retry - local ports - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - max_retry=${max_retry:-3} - ports=${ports:-http,https} - - test -n "$logpath" || ynh_die "ynh_add_fail2ban_config expects a logfile path as first argument and received nothing." - test -n "$failregex" || ynh_die "ynh_add_fail2ban_config expects a failure regex as second argument and received nothing." - - finalfail2banjailconf="/etc/fail2ban/jail.d/$app.conf" - finalfail2banfilterconf="/etc/fail2ban/filter.d/$app.conf" - ynh_backup_if_checksum_is_different "$finalfail2banjailconf" 1 - ynh_backup_if_checksum_is_different "$finalfail2banfilterconf" 1 - - tee $finalfail2banjailconf <&2 - echo "WARNING${fail2ban_error#*WARNING}" >&2 - fi -} - -# Remove the dedicated fail2ban config (jail and filter conf files) -# -# usage: ynh_remove_fail2ban_config -ynh_remove_fail2ban_config () { - ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf" - ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf" - if [ "$(lsb_release --codename --short)" != "jessie" ]; then - systemctl reload fail2ban - else - systemctl restart fail2ban - fi -} - -#================================================= - -# Read the value of a key in a ynh manifest file -# -# usage: ynh_read_manifest manifest key -# | arg: -m, --manifest= - Path of the manifest to read -# | arg: -k, --key= - Name of the key to find -ynh_read_manifest () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [m]=manifest= [k]=manifest_key= ) - local manifest - local manifest_key - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$manifest_key'])" -} - -# Read the upstream version from the manifest -# The version number in the manifest is defined by ~ynh -# For example : 4.3-2~ynh3 -# This include the number before ~ynh -# In the last example it return 4.3-2 -# -# usage: ynh_app_upstream_version [-m manifest] -# | arg: -m, --manifest= - Path of the manifest to read -ynh_app_upstream_version () { - declare -Ar args_array=( [m]=manifest= ) - local manifest - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - manifest="${manifest:-../manifest.json}" - if [ ! -e "$manifest" ]; then - manifest="../settings/manifest.json" # Into the restore script, the manifest is not at the same place - fi - version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version") - echo "${version_key/~ynh*/}" -} - -# Read package version from the manifest -# The version number in the manifest is defined by ~ynh -# For example : 4.3-2~ynh3 -# This include the number after ~ynh -# In the last example it return 3 -# -# usage: ynh_app_package_version [-m manifest] -# | arg: -m, --manifest= - Path of the manifest to read -ynh_app_package_version () { - declare -Ar args_array=( [m]=manifest= ) - local manifest - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - manifest="${manifest:-../manifest.json}" - if [ ! -e "$manifest" ]; then - manifest="../settings/manifest.json" # Into the restore script, the manifest is not at the same place - fi - version_key=$(ynh_read_manifest --manifest="$manifest" --manifest_key="version") - echo "${version_key/*~ynh/}" -} - -# Checks the app version to upgrade with the existing app version and returns: -# - UPGRADE_APP if the upstream app version has changed -# - UPGRADE_PACKAGE if only the YunoHost package has changed -# -## It stops the current script without error if the package is up-to-date -# -# This helper should be used to avoid an upgrade of an app, or the upstream part -# of it, when it's not needed -# -# To force an upgrade, even if the package is up to date, -# you have to set the variable YNH_FORCE_UPGRADE before. -# example: sudo YNH_FORCE_UPGRADE=1 yunohost app upgrade MyApp -# -# usage: ynh_check_app_version_changed -ynh_check_app_version_changed () { - local force_upgrade=${YNH_FORCE_UPGRADE:-0} - local package_check=${PACKAGE_CHECK_EXEC:-0} - - # By default, upstream app version has changed - local return_value="UPGRADE_APP" - - local current_version=$(ynh_read_manifest --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json" --manifest_key="version" || echo 1.0) - local current_upstream_version="$(ynh_app_upstream_version --manifest="/etc/yunohost/apps/$YNH_APP_INSTANCE_NAME/manifest.json")" - local update_version=$(ynh_read_manifest --manifest="../manifest.json" --manifest_key="version" || echo 1.0) - local update_upstream_version="$(ynh_app_upstream_version)" - - if [ "$current_version" == "$update_version" ] ; then - # Complete versions are the same - if [ "$force_upgrade" != "0" ] - then - echo "Upgrade forced by YNH_FORCE_UPGRADE." >&2 - unset YNH_FORCE_UPGRADE - elif [ "$package_check" != "0" ] - then - echo "Upgrade forced for package check." >&2 - else - ynh_die "Up-to-date, nothing to do" 0 - fi - elif [ "$current_upstream_version" == "$update_upstream_version" ] ; then - # Upstream versions are the same, only YunoHost package versions differ - return_value="UPGRADE_PACKAGE" - fi - echo $return_value -} - -#================================================= - -# Start (or other actions) a service, print a log in case of failure and optionnaly wait until the service is completely started -# -# usage: ynh_systemd_action [-n service_name] [-a action] [ [-l "line to match"] [-p log_path] [-t timeout] [-e length] ] -# | arg: -n, --service_name= - Name of the service to reload. Default : $app -# | arg: -a, --action= - Action to perform with systemctl. Default: start -# | arg: -l, --line_match= - Line to match - The line to find in the log to attest the service have finished to boot. -# If not defined it don't wait until the service is completely started. -# | arg: -p, --log_path= - Log file - Path to the log file. Default : /var/log/$app/$app.log -# | arg: -t, --timeout= - Timeout - The maximum time to wait before ending the watching. Default : 300 seconds. -# | arg: -e, --length= - Length of the error log : Default : 20 -ynh_systemd_action() { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [n]=service_name= [a]=action= [l]=line_match= [p]=log_path= [t]=timeout= [e]=length= ) - local service_name - local action - local line_match - local length - local log_path - local timeout - - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - local service_name="${service_name:-$app}" - local action=${action:-start} - local log_path="${log_path:-/var/log/$service_name/$service_name.log}" - local length=${length:-20} - local timeout=${timeout:-300} - - # Start to read the log - if [[ -n "${line_match:-}" ]] - then - local templog="$(mktemp)" - # Following the starting of the app in its log - if [ "$log_path" == "systemd" ] ; then - # Read the systemd journal - journalctl -u $service_name -f --since=-45 > "$templog" & - else - # Read the specified log file - tail -F -n0 "$log_path" > "$templog" & - fi - # Get the PID of the tail command - local pid_tail=$! - fi - - echo "${action^} the service $service_name" >&2 - systemctl $action $service_name \ - || ( journalctl --lines=$length -u $service_name >&2 \ - ; test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 \ - ; false ) - - # Start the timeout and try to find line_match - if [[ -n "${line_match:-}" ]] - then - local i=0 - for i in $(seq 1 $timeout) - do - # Read the log until the sentence is found, that means the app finished to start. Or run until the timeout - if grep --quiet "$line_match" "$templog" - then - echo "The service $service_name has correctly started." >&2 - break - fi - echo -n "." >&2 - sleep 1 - done - if [ $i -eq $timeout ] - then - echo "The service $service_name didn't fully started before the timeout." >&2 - echo "Please find here an extract of the end of the log of the service $service_name:" - journalctl --lines=$length -u $service_name >&2 - test -n "$log_path" && echo "--" && tail --lines=$length "$log_path" >&2 - fi - - echo "" - ynh_clean_check_starting - fi -} - -# Clean temporary process and file used by ynh_check_starting -# (usually used in ynh_clean_setup scripts) -# -# usage: ynh_clean_check_starting -ynh_clean_check_starting () { - # Stop the execution of tail. - kill -s 15 $pid_tail 2>&1 - ynh_secure_remove "$templog" 2>&1 -} - -#================================================= - -# Print a message as INFO and show progression during an app script -# -# usage: ynh_script_progression --message=message [--weight=weight] [--time] -# | arg: -m, --message= - The text to print -# | arg: -w, --weight= - The weight for this progression. This value is 1 by default. Use a bigger value for a longer part of the script. -# | arg: -t, --time= - Print the execution time since the last call to this helper. Especially usefull to define weights. -# | arg: -l, --last= - Use for the last call of the helper, to fill te progression bar. -increment_progression=0 -previous_weight=0 -# Define base_time when the file is sourced -base_time=$(date +%s) -ynh_script_progression () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [m]=message= [w]=weight= [t]=time [l]=last ) - local message - local weight - local time - local last - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - weight=${weight:-1} - time=${time:-0} - last=${last:-0} - - # Get execution time since the last $base_time - local exec_time=$(( $(date +%s) - $base_time )) - base_time=$(date +%s) - - # Get the number of occurrences of 'ynh_script_progression' in the script. Except those are commented. - local helper_calls="$(grep --count "^[^#]*ynh_script_progression" $0)" - # Get the number of call with a weight value - local weight_calls=$(grep --perl-regexp --count "^[^#]*ynh_script_progression.*(--weight|-w )" $0) - - # Get the weight of each occurrences of 'ynh_script_progression' in the script using --weight - local weight_valuesA="$(grep --perl-regexp "^[^#]*ynh_script_progression.*--weight" $0 | sed 's/.*--weight[= ]\([[:digit:]].*\)/\1/g')" - # Get the weight of each occurrences of 'ynh_script_progression' in the script using -w - local weight_valuesB="$(grep --perl-regexp "^[^#]*ynh_script_progression.*-w " $0 | sed 's/.*-w[= ]\([[:digit:]].*\)/\1/g')" - # Each value will be on a different line. - # Remove each 'end of line' and replace it by a '+' to sum the values. - local weight_values=$(( $(echo "$weight_valuesA" | tr '\n' '+') + $(echo "$weight_valuesB" | tr '\n' '+') 0 )) - - # max_progression is a total number of calls to this helper. - # Less the number of calls with a weight value. - # Plus the total of weight values - local max_progression=$(( $helper_calls - $weight_calls + $weight_values )) - - # Increment each execution of ynh_script_progression in this script by the weight of the previous call. - increment_progression=$(( $increment_progression + $previous_weight )) - # Store the weight of the current call in $previous_weight for next call - previous_weight=$weight - - # Set the scale of the progression bar - local scale=20 - # progress_string(1,2) should have the size of the scale. - local progress_string1="####################" - local progress_string0="...................." - - # Reduce $increment_progression to the size of the scale - if [ $last -eq 0 ] - then - local effective_progression=$(( $increment_progression * $scale / $max_progression )) - # If last is specified, fill immediately the progression_bar - else - local effective_progression=$scale - fi - - # Build $progression_bar from progress_string(1,2) according to $effective_progression - local progression_bar="${progress_string1:0:$effective_progression}${progress_string0:0:$(( $scale - $effective_progression ))}" - - local print_exec_time="" - if [ $time -eq 1 ] - then - print_exec_time=" [$(date +%Hh%Mm,%Ss --date="0 + $exec_time sec")]" - fi - - ynh_print_info "[$progression_bar] > ${message}${print_exec_time}" -} - #================================================= # EXPERIMENTAL HELPERS #================================================= @@ -660,6 +298,8 @@ ynh_maintenance_mode_ON () { domain=$(ynh_app_setting_get $app domain) fi + mkdir -p /var/www/html/ + # Create an html to serve as maintenance notice echo " @@ -865,116 +505,246 @@ ynh_app_changelog () { echo "No significative changes from the changelog..." > "${final_changelog}_lite" fi } + +#================================================= + +# Check the amount of available RAM # -# 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 () { +# 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=( [d]=dest_dir= [s]=source_id= ) - local dest_dir - local source_id + 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} - source_id=${source_id:-app} # If the argument is not given, source_id equals "$app" + 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 )) - # 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" ] + 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 - 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-) - - # 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}" - - 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 + # 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 - # Check the control sum - echo "${file_sum} ${filename}" | ${file_sumprg} -c --status \ - || ynh_die "Corrupt file" + 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 - # Create the destination directory, if it's not already. - mkdir -p "$dest_dir" - - # Move the file to its destination - mv $filename $dest_dir + # If no RAM is required, return the amount of available ram. + else + echo $ram + fi } #================================================= -# Create a changelog for an app after an upgrade. +# Define the values to configure php-fpm # -# The changelog is printed into the file ./changelog for the time of the upgrade. +# 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 # -# 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. +# | 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. # -# Because of the need of those info, ynh_app_changelog works only -# with apps that have been installed from a list. +# | arg: -p, --print - Print the result # -# 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. +# +# +# 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} - grep "$value\": \"" /etc/yunohost/apps/$app/status.json | sed "s/.*$value\": \"\([^\"]*\).*/\1/" - } + if [ "$footprint" = "low" ] + then + footprint=20 + elif [ "$footprint" = "medium" ] + then + footprint=35 + elif [ "$footprint" = "high" ] + then + footprint=50 + fi - 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" ] - then - ynh_print_warn "Unable to build the changelog..." - touch changelog - return 0 - 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 - # 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 + # Get the total of RAM available, except swap. + local max_ram=$(ynh_check_ram --no_swap) - # 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}" + less0() { + # Do not allow value below 1 + if [ $1 -le 0 ] + then + echo 1 + else + echo $1 + fi + } - # 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 + # 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 +} + +#================================================= + +# Execute a command as another user +# usage: exec_as USER COMMAND [ARG ...] +exec_as() { + local USER=$1 + shift 1 + + if [[ $USER = $(whoami) ]]; then + eval "$@" + else + sudo -u "$USER" "$@" + fi } From a6b7cb708c2da245b5f2c0de4d8f81ab94a07155 Mon Sep 17 00:00:00 2001 From: maniack Date: Sat, 14 Mar 2020 20:28:04 +0100 Subject: [PATCH 05/24] Update to last standard --- README.md | 8 ++--- README_fr.md | 8 ++--- app_minidlna.md | 8 ++--- app_minidlna_fr.md | 4 +-- check_process | 10 ------ manifest.json | 4 +-- scripts/actions/install_backports | 9 +++-- scripts/actions/install_standard | 6 ++-- scripts/actions/reset_db | 5 ++- scripts/backup | 18 +++++----- scripts/config | 28 +++++++-------- scripts/install | 57 ++++++++++++++++--------------- scripts/remove | 22 ++++++------ scripts/restore | 33 +++++++++--------- scripts/upgrade | 55 ++++++++++++++--------------- 15 files changed, 131 insertions(+), 144 deletions(-) diff --git a/README.md b/README.md index 07a8ee1..7574763 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to MiniDLNA is a simple media server software, with the aim of being fully compliant with DLNA/UPnP-AV clients. -**Shipped version:** Debian repositories versions. Currently 1.1.2 and 1.1.6 +**Shipped version:** Debian repositories versions. Currently 1.1.6 and 1.2.1 ## Screenshots @@ -39,9 +39,9 @@ Not relevant. #### Supported architectures -* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/minidlna%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/minidlna/) -* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/minidlna%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/minidlna/) -* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/minidlna%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/minidlna/) +* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/minidlna/) +* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/minidlna/) +* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/minidlna/) ## Limitations diff --git a/README_fr.md b/README_fr.md index cc23a73..34ae5a3 100644 --- a/README_fr.md +++ b/README_fr.md @@ -12,7 +12,7 @@ Si vous n'avez pas YunoHost, merci de regarder [ici](https://yunohost.org/#/inst MiniDLNA est un simple serveur multimédia, dont le but est d'être entièrement compatible avec les clients DLNA/UPnP-AV. -**Version embarquée:** Versions des dépôts Debian. Actuellement 1.1.2 et 1.1.6 +**Version embarquée:** Versions des dépôts Debian. Actuellement 1.1.6 et 1.2.1 ## Captures d'écran @@ -39,9 +39,9 @@ Non applicable. #### Architectures supportées. -* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/minidlna%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/minidlna/) -* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/minidlna%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/minidlna/) -* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/minidlna%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/minidlna/) +* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/minidlna/) +* ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/minidlna/) +* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/minidlna/) ## Limitations diff --git a/app_minidlna.md b/app_minidlna.md index ff6ea67..ad8f366 100644 --- a/app_minidlna.md +++ b/app_minidlna.md @@ -6,10 +6,10 @@ It allows to easily share multimedia files with any compatible devices present o Minidlna does not have a graphical interface, but does not require any special configuration. ### What multimedia files are shared? -Minidlna sharing the folder /home/yunohost.multimedia/share, which is common to each user in /home/$USER/Multimedia/Share. -[More information about multimedia files here.](Https://github.com/maniackcrudelis/yunohost.multimedia) +Minidlna is sharing the folder /home/yunohost.multimedia/share, which is common to each user in /home/$USER/Multimedia/Share. +[More information about multimedia files here.](https://github.com/YunoHost-Apps/yunohost.multimedia) -If [transmission](https://github.com/Kloadut/transmission_ynh) is installed, the downloaded media will be available in dlna. +If [transmission](https://github.com/YunoHost-Apps/transmission_ynh) is installed, the downloaded media will be available in dlna. ### How to view and play media files shared by minidlna? To view and play media files, all you need is a compatible client DLNA/UPNP. @@ -17,7 +17,7 @@ To view and play media files, all you need is a compatible client DLNA/UPNP. The majority of set-top boxes provided by ISPs are DLNA compatible, simply look for sources of external media. This is also true for the latest generation game consoles connected to internet. -Some TV and blu-ray player is also DLNA compatible. +Some TV and blu-ray player are also DLNA compatible. In any case, it is generally sufficient to seek external sources, USB etc, to find the DLNA server, displayed under the name **Yunohost DLNA**. diff --git a/app_minidlna_fr.md b/app_minidlna_fr.md index f48a73d..aa04874 100644 --- a/app_minidlna_fr.md +++ b/app_minidlna_fr.md @@ -7,9 +7,9 @@ Minidlna ne dispose pas d'une interface graphique, mais ne nécessite pas de con ### Quels fichiers multimédias sont partagés? Minidlna partage le dossier /home/yunohost.multimedia/share, qui est commun à chaque utilisateur dans le dossier /home/$USER/Multimedia/Share. -[Plus d'informations sur les dossiers multimedia ici.](https://github.com/maniackcrudelis/yunohost.multimedia) +[Plus d'informations sur les dossiers multimedia ici.](https://github.com/YunoHost-Apps/yunohost.multimedia) -Si [transmission](https://github.com/Kloadut/transmission_ynh) est installé, les médias téléchargés seront disponible en dlna. +Si [transmission](https://github.com/YunoHost-Apps/transmission_ynh) est installé, les médias téléchargés seront disponible en dlna. ### Comment consulter et lire les fichiers multimédias partagés par minidlna? Pour voir et lire les fichiers multimédias, il suffit de disposer d'un client compatible DLNA/UPNP. diff --git a/check_process b/check_process index db8b294..8daa3b8 100644 --- a/check_process +++ b/check_process @@ -29,17 +29,7 @@ port_already_use=0 change_url=0 ;;; Levels - Level 1=auto - Level 2=auto - Level 3=auto -# Level 4: Pas de gestion des utilisateurs - Level 4=na Level 5=auto - Level 6=auto - Level 7=auto - Level 8=0 - Level 9=0 - Level 10=0 ;;; Options Email= Notification=down diff --git a/manifest.json b/manifest.json index 505e146..3d86281 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Light DLNA server to share media files over the LAN", "fr": "Serveur DLNA léger pour partager les fichiers multimédia sur le réseau local" }, - "version": "1.0~ynh5", + "version": "1.0~ynh6", "url": "http://minidlna.sourceforge.net/", "license": "GPL-2.0", "maintainer": { @@ -14,7 +14,7 @@ "email": "maniackc_dev@crudelis.fr" }, "requirements": { - "yunohost": ">= 3.4" + "yunohost": ">= 3.5" }, "multi_instance": false, "services": [], diff --git a/scripts/actions/install_backports b/scripts/actions/install_backports index f30c2bf..bfaabd1 100755 --- a/scripts/actions/install_backports +++ b/scripts/actions/install_backports @@ -12,7 +12,6 @@ source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= -ynh_script_progression --message="Retrieve arguments from the manifest" app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} @@ -26,7 +25,7 @@ app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} if [ -e /etc/apt/sources.list.d/minidlna.list ] then - ynh_die "You are already using the version from backports repository." 0 + ynh_die --message="You are already using the version from backports repository." --ret_code=0 fi #================================================= @@ -34,16 +33,16 @@ fi #================================================= # RE-INSTALL MINIDLNA FROM BACKPORTS #================================================= -ynh_script_progression --message="Re-install minidlna from backports" --weight=9 +ynh_script_progression --message="Re-installing minidlna from backports..." --weight=9 # Remove the current version of minidlna ynh_package_remove minidlna # Then install the version from backports codename=$(ynh_debian_release) -test -z "$codename" && (ynh_die "codename empty") +test -z "$codename" && (ynh_die --message="codename empty") -ynh_replace_string "__CODENAME__" "$codename" /etc/yunohost/apps/$app/conf/minidlna.list +ynh_replace_string --match_string="__CODENAME__" --replace_string="$codename" --target_file=/etc/yunohost/apps/$app/conf/minidlna.list cp -a /etc/yunohost/apps/$app/conf/minidlna.list /etc/apt/sources.list.d/ ynh_apt update ynh_package_install -t $codename-backports minidlna diff --git a/scripts/actions/install_standard b/scripts/actions/install_standard index a361a31..ddaca6e 100755 --- a/scripts/actions/install_standard +++ b/scripts/actions/install_standard @@ -23,7 +23,7 @@ source /usr/share/yunohost/helpers if [ ! -e /etc/apt/sources.list.d/minidlna.list ] then - ynh_die "You are already using the version from the stable repository." 0 + ynh_die --message="You are already using the version from the stable repository." --ret_code=0 fi #================================================= @@ -31,11 +31,11 @@ fi #================================================= # RE-INSTALL MINIDLNA FROM STABLE #================================================= -ynh_script_progression --message="Re-install minidlna from stable" --weight=9 +ynh_script_progression --message="Re-installing minidlna from stable..." --weight=9 # Remove the current version of minidlna ynh_package_remove minidlna -ynh_secure_remove "/etc/apt/sources.list.d/minidlna.list" +ynh_secure_remove --file="/etc/apt/sources.list.d/minidlna.list" ynh_apt update ynh_package_install minidlna diff --git a/scripts/actions/reset_db b/scripts/actions/reset_db index 2e608aa..fb43cd2 100755 --- a/scripts/actions/reset_db +++ b/scripts/actions/reset_db @@ -12,7 +12,6 @@ source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS #================================================= -ynh_script_progression --message="Retrieve arguments from the manifest" app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} @@ -29,13 +28,13 @@ app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} #================================================= # RESET THE DATABASE #================================================= -ynh_script_progression --message="Reset the database" --weight=9 +ynh_script_progression --message="Resetting the database..." --weight=9 # Get the last value for `db_dir` in the config file of minidlna db_directory=$(tac /etc/minidlna.conf | grep --max-count=1 "db_dir=" | cut -d'=' -f 2) ynh_systemd_action --action=stop --service_name=minidlna -ynh_secure_remove "$db_directory/files.db" +ynh_secure_remove --file="$db_directory/files.db" ynh_systemd_action --action=start --service_name=minidlna #================================================= diff --git a/scripts/backup b/scripts/backup index cd1d53f..0a22646 100644 --- a/scripts/backup +++ b/scripts/backup @@ -19,11 +19,11 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Load settings" +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -version=$(ynh_app_setting_get $app version) +version=$(ynh_app_setting_get --app=$app --key=version) #================================================= # SPECIFIC BACKUP @@ -33,26 +33,26 @@ version=$(ynh_app_setting_get $app version) if [ $version = "B" ] then - ynh_script_progression --message="Backup of the APT source" - ynh_backup "/etc/apt/sources.list.d/minidlna.list" + ynh_script_progression --message="Backing up the APT source file..." + ynh_backup --src_path="/etc/apt/sources.list.d/minidlna.list" fi #================================================= # BACKUP OF INOTIFY'S CONFIG #================================================= -ynh_script_progression --message="Backup of inotify's config" +ynh_script_progression --message="Backing up inotify's config..." -ynh_backup "/etc/sysctl.d/90-inotify_minidlna.conf" +ynh_backup --src_path="/etc/sysctl.d/90-inotify_minidlna.conf" #================================================= # BACKUP OF MINIDLNA CONFIGURATION #================================================= -ynh_script_progression --message="Backup of minidlna configuration" +ynh_script_progression --message="Backing up minidlna configuration..." -ynh_backup "/etc/minidlna.conf" +ynh_backup --src_path="/etc/minidlna.conf" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Backup completed" --last +ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last diff --git a/scripts/config b/scripts/config index 504dbf7..1056658 100644 --- a/scripts/config +++ b/scripts/config @@ -47,13 +47,11 @@ old_friendly_name="$(get_config_value friendly_name)" friendly_name="${YNH_CONFIG_MAIN_MINIDLNA_CONFIGURATION_FRIENDLY_NAME:-$old_friendly_name}" # Overwrite settings.json file -old_overwrite_settings="$(ynh_app_setting_get $app overwrite_settings)" -old_overwrite_settings=$(bool_to_true_false $old_overwrite_settings) +old_overwrite_settings="$(ynh_app_setting_get --app=$app --key=overwrite_settings)" overwrite_settings="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS:-$old_overwrite_settings}" # Type of admin mail configuration -old_admin_mail_html="$(ynh_app_setting_get $app admin_mail_html)" -old_admin_mail_html=$(bool_to_true_false $old_admin_mail_html) +old_admin_mail_html="$(ynh_app_setting_get --app=$app --key=admin_mail_html)" admin_mail_html="${YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE:-$old_admin_mail_html}" #================================================= @@ -75,12 +73,12 @@ show_config() { elif [ "$root_container" = "V" ]; then root_container="Video" fi - echo "YNH_CONFIG_MAIN_MINIDLNA_CONFIGURATION_ROOT_CONTAINER=$root_container" - echo "YNH_CONFIG_MAIN_MINIDLNA_CONFIGURATION_FRIENDLY_NAME=$friendly_name" + ynh_return "YNH_CONFIG_MAIN_MINIDLNA_CONFIGURATION_ROOT_CONTAINER=$root_container" + ynh_return "YNH_CONFIG_MAIN_MINIDLNA_CONFIGURATION_FRIENDLY_NAME=$friendly_name" - echo "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS=$overwrite_settings" + ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETTINGS=$overwrite_settings" - echo "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html" + ynh_return "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html" } #================================================= @@ -105,16 +103,16 @@ apply_config() { fi if [ "$root_container" != "$old_root_container" ] then - ynh_replace_string "root_container=.*" "root_container=$root_container" "$config_file" - ynh_app_setting_set $app root_container "$root_container" + ynh_replace_string --match_string="root_container=.*" --replace_string="root_container=$root_container" --target_file="$config_file" + ynh_app_setting_set --app=$app --key=root_container --value="$root_container" restart_minidlna=1 fi # friendly_name if [ "$friendly_name" != "$old_friendly_name" ] then - ynh_replace_string "friendly_name=.*" "friendly_name=$friendly_name" "$config_file" - ynh_app_setting_set $app friendly_name "$friendly_name" + ynh_replace_string --match_string="friendly_name=.*" --replace_string="friendly_name=$friendly_name" --target_file="$config_file" + ynh_app_setting_set --app=$app --key=friendly_name --value="$friendly_name" restart_minidlna=1 fi @@ -124,12 +122,10 @@ apply_config() { fi # Set overwrite_settings - overwrite_settings=$(bool_to_01 $overwrite_settings) - ynh_app_setting_set $app overwrite_settings "$overwrite_settings" + ynh_app_setting_set --app=$app --key=overwrite_settings --value="$overwrite_settings" # Set admin_mail_html - admin_mail_html=$(bool_to_01 $admin_mail_html) - ynh_app_setting_set $app admin_mail_html "$admin_mail_html" + ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html" } #================================================= diff --git a/scripts/install b/scripts/install index 1b8344c..2ebc3c6 100644 --- a/scripts/install +++ b/scripts/install @@ -19,49 +19,49 @@ ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -ynh_script_progression --message="Retrieve arguments from the manifest" version="$YNH_APP_ARG_VERSION" + app=$YNH_APP_INSTANCE_NAME #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Store settings from manifest" --weight=2 +ynh_script_progression --message="Storing installation settings..." --weight=2 -ynh_app_setting_set $app version ${version:0:1} +ynh_app_setting_set --app=$app --key=version --value=${version:0:1} -ynh_app_setting_set $app overwrite_settings "1" -ynh_app_setting_set $app admin_mail_html "1" +ynh_app_setting_set --app=$app --key=overwrite_settings --value=1 +ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 #================================================= # CHECK DEBIAN'S CODENAME #================================================= -ynh_script_progression --message="Check debian's codename" +ynh_script_progression --message="Checking debian's codename..." codename=$(ynh_debian_release) -test -z "$codename" && (ynh_die "codename empty") +test -z "$codename" && (ynh_die --message="codename empty") #================================================= # STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Find and open a port" --weight=15 +ynh_script_progression --message="Configuring firewall..." --weight=15 # Find a free port -port=$(ynh_find_port 48200) +port=$(ynh_find_port --port=48200) # Open ports ynh_exec_fully_quiet yunohost firewall allow --no-upnp TCP $port # Discovery Protocol SSDP for UPNP. ynh_exec_fully_quiet yunohost firewall allow --no-upnp UDP 1900 -ynh_app_setting_set $app port $port +ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # CREATE YUNOHOST.MULTIMEDIA DIRECTORY #================================================= -ynh_script_progression --message="Create yunohost.multimedia directory" --weight=8 +ynh_script_progression --message="Creating yunohost.multimedia directory..." --weight=8 ynh_multimedia_build_main_dir @@ -70,12 +70,12 @@ ynh_multimedia_build_main_dir #================================================= # INSTALL MINIDLNA #================================================= -ynh_script_progression --message="Install minidlna" --weight=45 +ynh_script_progression --message="Installing minidlna..." --weight=45 if [ ${version:0:1} = "B" ] then # Install the backport version. (If you have issues with the standard version from the stable repository) - ynh_replace_string "__CODENAME__" "$codename" ../conf/minidlna.list + ynh_replace_string --match_string="__CODENAME__" --replace_string="$codename" --target_file=../conf/minidlna.list cp -a ../conf/minidlna.list /etc/apt/sources.list.d/ ynh_apt update ynh_package_install -t $codename-backports minidlna @@ -84,17 +84,18 @@ else ynh_apt update ynh_package_install minidlna fi -ynh_app_setting_set $app version ${version:0:1} +ynh_app_setting_set --app=$app --key=version --value=${version:0:1} #================================================= # INCREASE INOTIFY'S LIMITS #================================================= -ynh_script_progression --message="Increase inotify's limits" +ynh_script_progression --message="Increasing inotify's limits..." # Increase the maximum number of files inotify can monitor. cp -a ../conf/90-inotify_minidlna.conf /etc/sysctl.d/ # Then, reload the kernel configuration. -if ! IS_PACKAGE_CHECK; then +if ! IS_PACKAGE_CHECK # LXC doesn't allow sysctl to play with kernel options. +then sysctl -p /etc/sysctl.d/90-inotify_minidlna.conf fi @@ -107,25 +108,25 @@ yunohost service add minidlna --log "/var/log/minidlna.log" #================================================= # CONFIGURE MINIDLNA #================================================= -ynh_script_progression --message="Configure MiniDLNA" --weight=2 +ynh_script_progression --message="Configuring MiniDLNA..." --weight=2 -ynh_replace_string "^#*media_dir=.*" "media_dir=/home/yunohost.multimedia/share" /etc/minidlna.conf -ynh_replace_string "^#*port=.*" "port=$port" /etc/minidlna.conf +ynh_replace_string --match_string="^#*media_dir=.*" --replace_string="media_dir=/home/yunohost.multimedia/share" --target_file=/etc/minidlna.conf +ynh_replace_string --match_string="^#*port=.*" --replace_string="port=$port" --target_file=/etc/minidlna.conf friendly_name="Yunohost DLNA" -ynh_app_setting_set $app friendly_name "$friendly_name" -ynh_replace_string "^#*friendly_name=.*" "friendly_name=$friendly_name" /etc/minidlna.conf +ynh_app_setting_set --app=$app --key=friendly_name --value="$friendly_name" +ynh_replace_string --match_string="^#*friendly_name=.*" --replace_string="friendly_name=$friendly_name" --target_file=/etc/minidlna.conf root_container="B" -ynh_replace_string "^#*root_container=.*" "root_container=$root_container" /etc/minidlna.conf -ynh_app_setting_set $app root_container "$root_container" -ynh_replace_string "^#wide_links=.*" "wide_links=yes" /etc/minidlna.conf +ynh_replace_string --match_string="^#*root_container=.*" --replace_string="root_container=$root_container" --target_file=/etc/minidlna.conf +ynh_app_setting_set --app=$app --key=root_container --value="$root_container" +ynh_replace_string --match_string="^#wide_links=.*" --replace_string="wide_links=yes" --target_file=/etc/minidlna.conf # Calculate and store the config file checksum into the app settings -ynh_store_file_checksum "/etc/minidlna.conf" +ynh_store_file_checksum --file="/etc/minidlna.conf" #================================================= # RESTART MINIDLNA #================================================= -ynh_script_progression --message="Restart MiniDLNA" --weight=4 +ynh_script_progression --message="Restarting MiniDLNA..." --weight=4 ynh_systemd_action --action=restart --service_name=minidlna @@ -147,10 +148,10 @@ You can also find some specific actions for this app by using the experimental _ If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/minidlna_ynh__URL_TAG3__." > mail_to_send -ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type="install" +ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=install #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation completed" --last +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index bc1f48e..153301e 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,11 +12,11 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Load settings" --weight=2 +ynh_script_progression --message="Loading installation settings..." --weight=2 app=$YNH_APP_INSTANCE_NAME -port=$(ynh_app_setting_get $app port) +port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # STANDARD REMOVE @@ -27,14 +27,14 @@ port=$(ynh_app_setting_get $app port) # Check if the service is declared in YunoHost if ynh_exec_fully_quiet yunohost service status minidlna then - ynh_print_info "Remove minidlna service" >&2 + ynh_script_progression --message="Removing $app service..." yunohost service remove minidlna fi #================================================= # CLOSE PORTS #================================================= -ynh_script_progression --message="Close ports" --weight=15 +ynh_script_progression --message="Closing ports $port and 1900..." --weight=15 ynh_exec_fully_quiet yunohost firewall disallow TCP $port ynh_exec_fully_quiet yunohost firewall disallow UDP 1900 @@ -44,21 +44,21 @@ ynh_exec_fully_quiet yunohost firewall disallow UDP 1900 #================================================= # REMOVE MINIDNLA #================================================= -ynh_script_progression --message="Remove MiniDLNA" --weight=6 +ynh_script_progression --message="Removing MiniDLNA..." --weight=6 ynh_apt purge minidlna -ynh_secure_remove "/etc/apt/sources.list.d/minidlna.list" +ynh_secure_remove --file="/etc/apt/sources.list.d/minidlna.list" #================================================= # REMOVE INOTIFY'S CONFIG #================================================= -ynh_script_progression --message="Remove inotify's config" +ynh_script_progression --message="Removing inotify's config..." if [ -e "/etc/sysctl.d/90-inotify_minidlna.conf" ]; then - ynh_print_info "Delete kernel config" >&2 - ynh_secure_remove "/etc/sysctl.d/90-inotify_minidlna.conf" + ynh_secure_remove --file="/etc/sysctl.d/90-inotify_minidlna.conf" # Reload the kernel configuration. - if ! IS_PACKAGE_CHECK; then + if ! IS_PACKAGE_CHECK # LXC doesn't allow sysctl to play with kernel options. + then sysctl -p /etc/sysctl.d/90-inotify_minidlna.conf fi fi @@ -67,4 +67,4 @@ fi # END OF SCRIPT #================================================= -ynh_script_progression --message="Deletion completed" --last +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index fb97f4a..73f8ad3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -19,19 +19,19 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Load settings" +ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME -version=$(ynh_app_setting_get $app version) -port=$(ynh_app_setting_get $app port) +version=$(ynh_app_setting_get --app=$app --key=version) +port=$(ynh_app_setting_get --app=$app --key=port) #================================================= # SPECIFIC RESTORE #================================================= # OPEN PORTS #================================================= -ynh_script_progression --message="Open ports" --weight=15 +ynh_script_progression --message="Configuring firewall..." --weight=15 ynh_exec_fully_quiet yunohost firewall allow --no-upnp TCP $port # Discovery Protocol SSDP for UPNP. @@ -40,21 +40,21 @@ ynh_exec_fully_quiet yunohost firewall allow --no-upnp UDP 1900 #================================================= # CREATE YUNOHOST.MULTIMEDIA DIRECTORY #================================================= -ynh_script_progression --message="Create yunohost.multimedia directory" --weight=6 +ynh_script_progression --message="Creating yunohost.multimedia directory..." --weight=6 ynh_multimedia_build_main_dir #================================================= # INSTALL MINIDLNA #================================================= -ynh_script_progression --message="Install minidlna" --weight=45 +ynh_script_progression --message="Installing minidlna" --weight=45 if [ ${version:0:1} = "B" ] then # Install the backport version. (If you have issues with the standard version from the stable repository) codename=$(ynh_debian_release) - ynh_restore_file "/etc/apt/sources.list.d/minidlna.list" - ynh_replace_string " [a-z]*-backports" " $codename-backports" /etc/apt/sources.list.d/minidlna.list + ynh_restore_file --origin_path="/etc/apt/sources.list.d/minidlna.list" + ynh_replace_string --match_string=" [a-z]*-backports" --replace_string=" $codename-backports" --target_file=/etc/apt/sources.list.d/minidlna.list ynh_apt update ynh_package_install -t $codename-backports minidlna else @@ -66,21 +66,22 @@ fi #================================================= # RESTORE INOTIFY'S CONFIG #================================================= -ynh_script_progression --message="Restore inotify's config" +ynh_script_progression --message="Restoring inotify's config..." -ynh_restore_file "/etc/sysctl.d/90-inotify_minidlna.conf" -if ! IS_PACKAGE_CHECK; then +ynh_restore_file --origin_path="/etc/sysctl.d/90-inotify_minidlna.conf" +if ! IS_PACKAGE_CHECK # LXC doesn't allow sysctl to play with kernel options. +then sysctl -p /etc/sysctl.d/90-inotify_minidlna.conf fi #================================================= # RESTORE MINIDLNA CONFIGURATION #================================================= -ynh_script_progression --message="Restore MiniDLNA configuration" --weight=7 +ynh_script_progression --message="Restoring MiniDLNA configuration..." --weight=7 # Delete the current config of minidlna, in order to replace it by the version from the backup -ynh_secure_remove "/etc/minidlna.conf" -ynh_restore_file "/etc/minidlna.conf" +ynh_secure_remove --file="/etc/minidlna.conf" +ynh_restore_file --origin_path="/etc/minidlna.conf" ynh_systemd_action --action=restart --service_name=minidlna #================================================= @@ -107,10 +108,10 @@ You can also find some specific actions for this app by using the experimental _ If you're facing an issue or want to improve this app, please open a new issue in this __URL_TAG1__project__URL_TAG2__https://github.com/YunoHost-Apps/minidlna_ynh__URL_TAG3__." > mail_to_send -ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type="restore" +ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=restore #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed" --last +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index 04f45aa..f6a0b20 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,15 +12,15 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Load settings" --weight=2 +ynh_script_progression --message="Loading installation settings..." --weight=2 app=$YNH_APP_INSTANCE_NAME -version=$(ynh_app_setting_get $app version) -port=$(ynh_app_setting_get $app port) -overwrite_settings=$(ynh_app_setting_get $app overwrite_settings) -root_container=$(ynh_app_setting_get $app root_container) -friendly_name=$(ynh_app_setting_get $app friendly_name) +version=$(ynh_app_setting_get --app=$app --key=version) +port=$(ynh_app_setting_get --app=$app --key=port) +overwrite_settings=$(ynh_app_setting_get --app=$app --key=overwrite_settings) +root_container=$(ynh_app_setting_get --app=$app --key=root_container) +friendly_name=$(ynh_app_setting_get --app=$app --key=friendly_name) #================================================= # CHECK VERSION @@ -31,30 +31,30 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensure downward compatibility" +ynh_script_progression --message="Ensuring downward compatibility..." # If overwrite_settings doesn't exist, create it if [ -z "$overwrite_settings" ]; then overwrite_settings=1 - ynh_app_setting_set $app overwrite_settings $overwrite_settings + ynh_app_setting_set --app=$app --key=overwrite_settings --value=$overwrite_settings fi # If root_container doesn't exist, create it if [ -z "$root_container" ]; then root_container="B" - ynh_app_setting_set $app root_container $root_container + ynh_app_setting_set --app=$app --key=root_container --value=$root_container fi # If friendly_name doesn't exist, create it if [ -z "$friendly_name" ]; then friendly_name="Yunohost DLNA" - ynh_app_setting_set $app friendly_name $friendly_name + ynh_app_setting_set --app=$app --key=friendly_name --value=$friendly_name fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backup the app before upgrading" --weight=2 +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=2 # Backup the current version of the app ynh_backup_before_upgrade @@ -68,20 +68,20 @@ ynh_abort_if_errors #================================================= # UPGRADE THE YUNOHOST.MULTIMEDIA DIRECTORY #================================================= -ynh_script_progression --message="Upgrade the yunohost.multimedia directory" --weight=3 +ynh_script_progression --message="Upgrading the yunohost.multimedia directory..." --weight=3 ynh_multimedia_build_main_dir #================================================= # UPGRADE MINIDLNA #================================================= -ynh_script_progression --message="Upgrade MiniDLNA" --weight=3 +ynh_script_progression --message="Upgrading MiniDLNA..." --weight=3 if [ $version = "B" ] then # Install the backport version. (If you have issues with the standard version from the stable repository) codename=$(ynh_debian_release) - ynh_replace_string "__CODENAME__" "$codename" ../conf/minidlna.list + ynh_replace_string --match_string="__CODENAME__" --replace_string="$codename" --target_file=../conf/minidlna.list cp -a ../conf/minidlna.list /etc/apt/sources.list.d/ ynh_apt update ynh_package_install -t $codename-backports minidlna @@ -94,12 +94,13 @@ fi #================================================= # INCREASE INOTIFY'S LIMITS #================================================= -ynh_script_progression --message="Increase inotify's limits" --weight=2 +ynh_script_progression --message="Increasing inotify's limits..." --weight=2 # Increase the maximum number of files inotify can monitor. cp -a ../conf/90-inotify_minidlna.conf /etc/sysctl.d/ # Then, reload the kernel configuration. -if ! IS_PACKAGE_CHECK; then +if ! IS_PACKAGE_CHECK # LXC doesn't allow sysctl to play with kernel options. +then sysctl -p /etc/sysctl.d/90-inotify_minidlna.conf fi @@ -112,28 +113,28 @@ yunohost service add minidlna --log "/var/log/minidlna.log" #================================================= # CONFIGURE MINIDLNA #================================================= -ynh_script_progression --message="Reconfigure MiniDLNA" --weight=2 +ynh_script_progression --message="Reconfiguring MiniDLNA..." --weight=2 # Overwrite the settings config file only if it's allowed if [ $overwrite_settings -eq 1 ] then # Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. - ynh_backup_if_checksum_is_different "/etc/minidlna.conf" + ynh_backup_if_checksum_is_different --file="/etc/minidlna.conf" - ynh_replace_string "^#*media_dir=.*" "media_dir=/home/yunohost.multimedia/share" /etc/minidlna.conf - ynh_replace_string "^#*port=.*" "port=$port" /etc/minidlna.conf - ynh_replace_string "^#*friendly_name=.*" "friendly_name=$friendly_name" /etc/minidlna.conf - ynh_replace_string "^#*root_container=.*" "root_container=$root_container" /etc/minidlna.conf - ynh_replace_string "^#wide_links=.*" "wide_links=yes" /etc/minidlna.conf + ynh_replace_string --match_string="^#*media_dir=.*" --replace_string="media_dir=/home/yunohost.multimedia/share" --target_file=/etc/minidlna.conf + ynh_replace_string --match_string="^#*port=.*" --replace_string="port=$port" --target_file=/etc/minidlna.conf + ynh_replace_string --match_string="^#*friendly_name=.*" --replace_string="friendly_name=$friendly_name" --target_file=/etc/minidlna.conf + ynh_replace_string --match_string="^#*root_container=.*" --replace_string="root_container=$root_container" --target_file=/etc/minidlna.conf + ynh_replace_string --match_string="^#wide_links=.*" --replace_string="wide_links=yes" --target_file=/etc/minidlna.conf # Calculate and store the config file checksum into the app settings - ynh_store_file_checksum "/etc/minidlna.conf" + ynh_store_file_checksum --file="/etc/minidlna.conf" fi #================================================= # RESTART MINIDLNA'S SERVICE #================================================= -ynh_script_progression --message="Restart MiniDLNA" --weight=7 +ynh_script_progression --message="Restarting MiniDLNA..." --weight=7 ynh_systemd_action --action=restart --service_name=minidlna @@ -163,10 +164,10 @@ If you're facing an issue or want to improve this app, please open a new issue i Changelog since your last upgrade: $(cat changelog)" > mail_to_send -ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type="upgrade" +ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type=upgrade #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade completed" --last +ynh_script_progression --message="Upgrade of $app completed" --last From 0a5790966f4775213796e4151caa71c144c2447b Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Tue, 29 Sep 2020 14:09:39 +0200 Subject: [PATCH 06/24] Small typos --- README.md | 10 ++++------ README_fr.md | 22 ++++++++++------------ app_minidlna.md | 16 ++++++++-------- app_minidlna_fr.md | 14 +++++++------- manifest.json | 4 ++-- scripts/actions/install_backports | 2 +- scripts/actions/install_standard | 2 +- scripts/backup | 12 ++++++------ scripts/install | 6 +++--- scripts/remove | 4 ++-- scripts/restore | 4 ++-- scripts/upgrade | 2 +- 12 files changed, 47 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 7574763..fd56407 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MiniDLNA for YunoHost -[![Integration level](https://dash.yunohost.org/integration/minidlna.svg)](https://dash.yunohost.org/appci/app/minidlna) +[![Integration level](https://dash.yunohost.org/integration/minidlna.svg)](https://dash.yunohost.org/appci/app/minidlna) ![](https://ci-apps.yunohost.org/ci/badges/minidlna.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/minidlna.maintain.svg) [![Install MiniDLNA with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=minidlna) *[Lire ce readme en français.](./README_fr.md)* @@ -31,7 +31,7 @@ Edit the file `/etc/minidlna.conf` to adjust the configuration of MiniDLNA. ## YunoHost specific features * Use shared Multimedia Directories -* Linked to transmission, nextcloud and all other app which use Multimedia Directories. +* Linked to transmission, Nextcloud and all other app which use Multimedia Directories. #### Multi-users support @@ -39,9 +39,8 @@ Not relevant. #### Supported architectures -* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/minidlna/) +* x86-64 - [![](https://ci-apps.yunohost.org/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/minidlna/) * ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/minidlna/) -* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/minidlna/) ## Limitations @@ -55,8 +54,7 @@ Not relevant. --- -Developers infos ----------------- +## Developers infos Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/minidlna_ynh/tree/testing). diff --git a/README_fr.md b/README_fr.md index 34ae5a3..f048bd1 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,6 +1,6 @@ # MiniDLNA pour YunoHost -[![Niveau d'intégration](https://dash.yunohost.org/integration/minidlna.svg)](https://dash.yunohost.org/appci/app/minidlna) +[![Niveau d'intégration](https://dash.yunohost.org/integration/minidlna.svg)](https://dash.yunohost.org/appci/app/minidlna) ![](https://ci-apps.yunohost.org/ci/badges/minidlna.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/minidlna.maintain.svg) [![Installer MiniDLNA avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=minidlna) *[Read this readme in english.](./README.md)* @@ -12,7 +12,7 @@ Si vous n'avez pas YunoHost, merci de regarder [ici](https://yunohost.org/#/inst MiniDLNA est un simple serveur multimédia, dont le but est d'être entièrement compatible avec les clients DLNA/UPnP-AV. -**Version embarquée:** Versions des dépôts Debian. Actuellement 1.1.6 et 1.2.1 +**Version embarquée :** Versions des dépôts Debian. Actuellement 1.1.6 et 1.2.1 ## Captures d'écran @@ -22,16 +22,16 @@ Aucune démo pour cette application. ## Configuration -Editez le fichier `/etc/minidlna.conf` pour ajuster la configuration de MiniDLNA. +Éditez le fichier `/etc/minidlna.conf` pour ajuster la configuration de MiniDLNA. ## Documentation - * Documentation YunoHost: https://yunohost.org/#/app_minidlna + * Documentation YunoHost : https://yunohost.org/#/app_minidlna ## Fonctionnalités spécifiques à YunoHost * Utilise les répertoires multimédia partagés. -* Lié à transmission, nextcloud et toute autre application qui utilise les répertoires multimédia. +* Lié à transmission, Nextcloud et toute autre application qui utilise les répertoires multimédia. #### Support multi-utilisateurs @@ -39,9 +39,8 @@ Non applicable. #### Architectures supportées. -* x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/minidlna/) +* x86-64 - [![](https://ci-apps.yunohost.org/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/minidlna/) * ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/minidlna/) -* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/minidlna/) ## Limitations @@ -49,14 +48,13 @@ Non applicable. ## Liens - * Reporter un bug: https://github.com/YunoHost-Apps/minidlna_ynh/issues - * Site de MiniDLNA: http://minidlna.sourceforge.net/ - * Site de YunoHost: https://yunohost.org/ + * Reporter un bug : https://github.com/YunoHost-Apps/minidlna_ynh/issues + * Site de MiniDLNA : http://minidlna.sourceforge.net/ + * Site de YunoHost : https://yunohost.org/ --- -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/minidlna_ynh/tree/testing). diff --git a/app_minidlna.md b/app_minidlna.md index ad8f366..adcdf0a 100644 --- a/app_minidlna.md +++ b/app_minidlna.md @@ -1,25 +1,25 @@ -# Minidlna +# MiniDLNA -Minidlna is a lightweight [dlna](https://fr.wikipedia.org/wiki/Digital_Living_Network_Alliance) server. +MiniDLNA is a lightweight [DLNA](https://fr.wikipedia.org/wiki/Digital_Living_Network_Alliance) server. It allows to easily share multimedia files with any compatible devices present on the LAN. -Minidlna does not have a graphical interface, but does not require any special configuration. +MiniDLNA does not have a graphical interface, but does not require any special configuration. ### What multimedia files are shared? -Minidlna is sharing the folder /home/yunohost.multimedia/share, which is common to each user in /home/$USER/Multimedia/Share. +MiniDLNA is sharing the folder `/home/yunohost.multimedia/share`, which is common to each user in `/home/$USER/Multimedia/Share`. [More information about multimedia files here.](https://github.com/YunoHost-Apps/yunohost.multimedia) -If [transmission](https://github.com/YunoHost-Apps/transmission_ynh) is installed, the downloaded media will be available in dlna. +If [Transmission](https://github.com/YunoHost-Apps/transmission_ynh) is installed, the downloaded media will be available in DLNA. -### How to view and play media files shared by minidlna? +### How to view and play media files shared by miniDLNA? To view and play media files, all you need is a compatible client DLNA/UPNP. The majority of set-top boxes provided by ISPs are DLNA compatible, simply look for sources of external media. This is also true for the latest generation game consoles connected to internet. -Some TV and blu-ray player are also DLNA compatible. +Some TV and Blu-ray player are also DLNA compatible. -In any case, it is generally sufficient to seek external sources, USB etc, to find the DLNA server, displayed under the name **Yunohost DLNA**. +In any case, it is generally sufficient to seek external sources, USB etc., to find the DLNA server, displayed under the name **YunoHost DLNA**. There are a multitude of DLNA client for all platforms, including the following [not exhaustive list](https://en.wikipedia.org/wiki/List_of_UPnP_AV_media_servers_and_clients#UPnP_AV_clients). In general, a DLNA client does not require any special configuration to access the media sharing. diff --git a/app_minidlna_fr.md b/app_minidlna_fr.md index aa04874..433cc3f 100644 --- a/app_minidlna_fr.md +++ b/app_minidlna_fr.md @@ -1,25 +1,25 @@ -# Minidlna +# MiniDLNA -Minidlna est un serveur [dlna](https://fr.wikipedia.org/wiki/Digital_Living_Network_Alliance) ultra léger. +MiniDLNA est un serveur [DLNA](https://fr.wikipedia.org/wiki/Digital_Living_Network_Alliance) ultra léger. Il permet de partager très simplement les fichiers multimédias avec tout les appareils compatibles présent sur le réseau local. Minidlna ne dispose pas d'une interface graphique, mais ne nécessite pas de configuration particulière. ### Quels fichiers multimédias sont partagés? -Minidlna partage le dossier /home/yunohost.multimedia/share, qui est commun à chaque utilisateur dans le dossier /home/$USER/Multimedia/Share. +Minidlna partage le dossier `/home/yunohost.multimedia/share`, qui est commun à chaque utilisateur dans le dossier `/home/$USER/Multimedia/Share`. [Plus d'informations sur les dossiers multimedia ici.](https://github.com/YunoHost-Apps/yunohost.multimedia) -Si [transmission](https://github.com/YunoHost-Apps/transmission_ynh) est installé, les médias téléchargés seront disponible en dlna. +Si [Transmission](https://github.com/YunoHost-Apps/transmission_ynh) est installé, les médias téléchargés seront disponible en DLNA. -### Comment consulter et lire les fichiers multimédias partagés par minidlna? +### Comment consulter et lire les fichiers multimédias partagés par miniDLNA? Pour voir et lire les fichiers multimédias, il suffit de disposer d'un client compatible DLNA/UPNP. La majorité des décodeurs TV fourni par les FAI sont compatible DLNA, il suffit de chercher les sources de médias externe. C'est le cas également pour les consoles de jeux dernière génération connectée à internet. -Certaines TV et lecteur blu-ray sont également compatibles DLNA. +Certaines TV et lecteur Blu-ray sont également compatibles DLNA. -Dans tout les cas, il suffit en général d'aller chercher les sources externes, USB etc, pour trouver le serveur DLNA, affiché sous le nom **Yunohost DLNA**. +Dans tout les cas, il suffit en général d'aller chercher les sources externes, USB etc., pour trouver le serveur DLNA, affiché sous le nom **Yunohost DLNA**. Il existe une multitude de client DLNA pour toutes les plateformes, dont voici une [liste non exhaustive](https://en.wikipedia.org/wiki/List_of_UPnP_AV_media_servers_and_clients#UPnP_AV_clients). De manière générale, un client DLNA ne nécessite pas de configuration particulière pour accéder au partage de fichiers multimédias. diff --git a/manifest.json b/manifest.json index 08f4046..2680500 100644 --- a/manifest.json +++ b/manifest.json @@ -27,8 +27,8 @@ { "name": "version", "ask": { - "en": "Select the minidlna version to install", - "fr": "Choix de la version de minidlna à installer" + "en": "Select the MiniDLNA version to install", + "fr": "Choix de la version de MiniDLNA à installer" }, "choices": ["A. Version of the Debian repositories - recommended", "B. Latest version available for Debian"], "default": "A. Version of the Debian repositories - recommended" diff --git a/scripts/actions/install_backports b/scripts/actions/install_backports index bfaabd1..5bab82e 100755 --- a/scripts/actions/install_backports +++ b/scripts/actions/install_backports @@ -33,7 +33,7 @@ fi #================================================= # RE-INSTALL MINIDLNA FROM BACKPORTS #================================================= -ynh_script_progression --message="Re-installing minidlna from backports..." --weight=9 +ynh_script_progression --message="Re-installing MiniDLNA from backports..." --weight=9 # Remove the current version of minidlna ynh_package_remove minidlna diff --git a/scripts/actions/install_standard b/scripts/actions/install_standard index ddaca6e..76f34e6 100755 --- a/scripts/actions/install_standard +++ b/scripts/actions/install_standard @@ -31,7 +31,7 @@ fi #================================================= # RE-INSTALL MINIDLNA FROM STABLE #================================================= -ynh_script_progression --message="Re-installing minidlna from stable..." --weight=9 +ynh_script_progression --message="Re-installing MiniDLNA from stable..." --weight=9 # Remove the current version of minidlna ynh_package_remove minidlna diff --git a/scripts/backup b/scripts/backup index 0a22646..fc4e649 100644 --- a/scripts/backup +++ b/scripts/backup @@ -19,35 +19,35 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME version=$(ynh_app_setting_get --app=$app --key=version) #================================================= -# SPECIFIC BACKUP +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + #================================================= # BACKUP OF THE APT SOURCE #================================================= if [ $version = "B" ] then - ynh_script_progression --message="Backing up the APT source file..." ynh_backup --src_path="/etc/apt/sources.list.d/minidlna.list" fi #================================================= # BACKUP OF INOTIFY'S CONFIG #================================================= -ynh_script_progression --message="Backing up inotify's config..." ynh_backup --src_path="/etc/sysctl.d/90-inotify_minidlna.conf" #================================================= # BACKUP OF MINIDLNA CONFIGURATION #================================================= -ynh_script_progression --message="Backing up minidlna configuration..." ynh_backup --src_path="/etc/minidlna.conf" @@ -55,4 +55,4 @@ ynh_backup --src_path="/etc/minidlna.conf" # 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/install b/scripts/install index 2ebc3c6..13f7dca 100644 --- a/scripts/install +++ b/scripts/install @@ -37,7 +37,7 @@ ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 #================================================= # CHECK DEBIAN'S CODENAME #================================================= -ynh_script_progression --message="Checking debian's codename..." +ynh_script_progression --message="Checking Debian's codename..." codename=$(ynh_debian_release) test -z "$codename" && (ynh_die --message="codename empty") @@ -70,7 +70,7 @@ ynh_multimedia_build_main_dir #================================================= # INSTALL MINIDLNA #================================================= -ynh_script_progression --message="Installing minidlna..." --weight=45 +ynh_script_progression --message="Installing MiniDLNA..." --weight=45 if [ ${version:0:1} = "B" ] then @@ -154,4 +154,4 @@ ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression --message="Installation of MiniDLNA completed" --last diff --git a/scripts/remove b/scripts/remove index 153301e..83788a3 100755 --- a/scripts/remove +++ b/scripts/remove @@ -27,7 +27,7 @@ port=$(ynh_app_setting_get --app=$app --key=port) # Check if the service is declared in YunoHost if ynh_exec_fully_quiet yunohost service status minidlna then - ynh_script_progression --message="Removing $app service..." + ynh_script_progression --message="Removing MiniDLNA service..." yunohost service remove minidlna fi @@ -67,4 +67,4 @@ fi # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression --message="Removal of MiniDLNA completed" --last diff --git a/scripts/restore b/scripts/restore index 73f8ad3..3803f87 100644 --- a/scripts/restore +++ b/scripts/restore @@ -47,7 +47,7 @@ ynh_multimedia_build_main_dir #================================================= # INSTALL MINIDLNA #================================================= -ynh_script_progression --message="Installing minidlna" --weight=45 +ynh_script_progression --message="Installing MiniDLNA" --weight=45 if [ ${version:0:1} = "B" ] then @@ -114,4 +114,4 @@ ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression --message="Restoration completed for MiniDLNA" --last diff --git a/scripts/upgrade b/scripts/upgrade index f6a0b20..50ae197 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -170,4 +170,4 @@ ynh_send_readme_to_admin --app_message="mail_to_send" --recipients="root" --type # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression --message="Upgrade of MiniDLNA completed" --last From 21b587e2f61223db99f049d00e434f79dbd02c2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 4 Oct 2020 10:30:37 +0200 Subject: [PATCH 07/24] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 7574763..757df9c 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,6 @@ Not relevant. * x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/minidlna/) * ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/minidlna/) -* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/minidlna/) ## Limitations From cb5e9b45648f683f99a28999ed497d719e252428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 4 Oct 2020 10:30:55 +0200 Subject: [PATCH 08/24] Update README_fr.md --- README_fr.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README_fr.md b/README_fr.md index 34ae5a3..2d4dbae 100644 --- a/README_fr.md +++ b/README_fr.md @@ -41,7 +41,6 @@ Non applicable. * x86-64b - [![](https://ci-apps.yunohost.org/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/minidlna/) * ARMv8-A - [![](https://ci-apps-arm.yunohost.org/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/minidlna/) -* Jessie x86-64b - [![](https://ci-stretch.nohost.me/ci/logs/minidlna%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/minidlna/) ## Limitations From cad803dc0468ad05e08db0cccb03e909721d17cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 4 Oct 2020 10:31:05 +0200 Subject: [PATCH 09/24] Update app_minidlna_fr.md --- app_minidlna_fr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app_minidlna_fr.md b/app_minidlna_fr.md index aa04874..8785279 100644 --- a/app_minidlna_fr.md +++ b/app_minidlna_fr.md @@ -11,7 +11,7 @@ Minidlna partage le dossier /home/yunohost.multimedia/share, qui est commun à c Si [transmission](https://github.com/YunoHost-Apps/transmission_ynh) est installé, les médias téléchargés seront disponible en dlna. -### Comment consulter et lire les fichiers multimédias partagés par minidlna? +### Comment consulter et lire les fichiers multimédias partagés par MiniDLNA? Pour voir et lire les fichiers multimédias, il suffit de disposer d'un client compatible DLNA/UPNP. La majorité des décodeurs TV fourni par les FAI sont compatible DLNA, il suffit de chercher les sources de médias externe. From c472a807b20971cee76272d937b177773a1378bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 4 Oct 2020 10:31:21 +0200 Subject: [PATCH 10/24] Update scripts/actions/install_backports --- scripts/actions/install_backports | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/actions/install_backports b/scripts/actions/install_backports index bfaabd1..5bab82e 100755 --- a/scripts/actions/install_backports +++ b/scripts/actions/install_backports @@ -33,7 +33,7 @@ fi #================================================= # RE-INSTALL MINIDLNA FROM BACKPORTS #================================================= -ynh_script_progression --message="Re-installing minidlna from backports..." --weight=9 +ynh_script_progression --message="Re-installing MiniDLNA from backports..." --weight=9 # Remove the current version of minidlna ynh_package_remove minidlna From 902c9e1bf1dfd78050021f71acbbd0d49c2dad7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 4 Oct 2020 10:31:33 +0200 Subject: [PATCH 11/24] Update scripts/actions/install_standard --- scripts/actions/install_standard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/actions/install_standard b/scripts/actions/install_standard index ddaca6e..76f34e6 100755 --- a/scripts/actions/install_standard +++ b/scripts/actions/install_standard @@ -31,7 +31,7 @@ fi #================================================= # RE-INSTALL MINIDLNA FROM STABLE #================================================= -ynh_script_progression --message="Re-installing minidlna from stable..." --weight=9 +ynh_script_progression --message="Re-installing MiniDLNA from stable..." --weight=9 # Remove the current version of minidlna ynh_package_remove minidlna From 64c9b62b5604ba2fa691c1620a6d39fd278432ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 4 Oct 2020 10:31:49 +0200 Subject: [PATCH 12/24] Update scripts/backup --- scripts/backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/backup b/scripts/backup index 0a22646..628da6c 100644 --- a/scripts/backup +++ b/scripts/backup @@ -47,7 +47,7 @@ ynh_backup --src_path="/etc/sysctl.d/90-inotify_minidlna.conf" #================================================= # BACKUP OF MINIDLNA CONFIGURATION #================================================= -ynh_script_progression --message="Backing up minidlna configuration..." +ynh_script_progression --message="Backing up MiniDLNA configuration..." ynh_backup --src_path="/etc/minidlna.conf" From cf5110432be654fdec11924d08908cd9db555009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 4 Oct 2020 10:32:05 +0200 Subject: [PATCH 13/24] Update app_minidlna_fr.md --- app_minidlna_fr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app_minidlna_fr.md b/app_minidlna_fr.md index 8785279..5192161 100644 --- a/app_minidlna_fr.md +++ b/app_minidlna_fr.md @@ -6,7 +6,7 @@ Il permet de partager très simplement les fichiers multimédias avec tout les a Minidlna ne dispose pas d'une interface graphique, mais ne nécessite pas de configuration particulière. ### Quels fichiers multimédias sont partagés? -Minidlna partage le dossier /home/yunohost.multimedia/share, qui est commun à chaque utilisateur dans le dossier /home/$USER/Multimedia/Share. +MiniDLNA partage le dossier `/home/yunohost.multimedia/share`, qui est commun à chaque utilisateur dans le dossier `/home/$USER/Multimedia/Share`. [Plus d'informations sur les dossiers multimedia ici.](https://github.com/YunoHost-Apps/yunohost.multimedia) Si [transmission](https://github.com/YunoHost-Apps/transmission_ynh) est installé, les médias téléchargés seront disponible en dlna. From 45ffbce1c2c574aadd7034ae564133672d82e620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 4 Oct 2020 10:32:15 +0200 Subject: [PATCH 14/24] Update app_minidlna.md --- app_minidlna.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app_minidlna.md b/app_minidlna.md index ad8f366..b574cd3 100644 --- a/app_minidlna.md +++ b/app_minidlna.md @@ -19,7 +19,7 @@ This is also true for the latest generation game consoles connected to internet. Some TV and blu-ray player are also DLNA compatible. -In any case, it is generally sufficient to seek external sources, USB etc, to find the DLNA server, displayed under the name **Yunohost DLNA**. +In any case, it is generally sufficient to seek external sources, USB etc., to find the DLNA server, displayed under the name **YunoHost DLNA**. There are a multitude of DLNA client for all platforms, including the following [not exhaustive list](https://en.wikipedia.org/wiki/List_of_UPnP_AV_media_servers_and_clients#UPnP_AV_clients). In general, a DLNA client does not require any special configuration to access the media sharing. From 36fbb1defdd999cb2fb9c4ca48a236783c728f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 4 Oct 2020 10:32:27 +0200 Subject: [PATCH 15/24] Update app_minidlna.md --- app_minidlna.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app_minidlna.md b/app_minidlna.md index b574cd3..17a13a1 100644 --- a/app_minidlna.md +++ b/app_minidlna.md @@ -11,7 +11,7 @@ Minidlna is sharing the folder /home/yunohost.multimedia/share, which is common If [transmission](https://github.com/YunoHost-Apps/transmission_ynh) is installed, the downloaded media will be available in dlna. -### How to view and play media files shared by minidlna? +### How to view and play media files shared by MiniDLNA? To view and play media files, all you need is a compatible client DLNA/UPNP. The majority of set-top boxes provided by ISPs are DLNA compatible, simply look for sources of external media. From 50a8364e98847654912d6060a8fe74cb373032cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 4 Oct 2020 10:32:40 +0200 Subject: [PATCH 16/24] Update app_minidlna.md --- app_minidlna.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app_minidlna.md b/app_minidlna.md index 17a13a1..b503aec 100644 --- a/app_minidlna.md +++ b/app_minidlna.md @@ -9,7 +9,7 @@ Minidlna does not have a graphical interface, but does not require any special c Minidlna is sharing the folder /home/yunohost.multimedia/share, which is common to each user in /home/$USER/Multimedia/Share. [More information about multimedia files here.](https://github.com/YunoHost-Apps/yunohost.multimedia) -If [transmission](https://github.com/YunoHost-Apps/transmission_ynh) is installed, the downloaded media will be available in dlna. +If [Transmission](https://github.com/YunoHost-Apps/transmission_ynh) is installed, the downloaded media will be available in DLNA. ### How to view and play media files shared by MiniDLNA? To view and play media files, all you need is a compatible client DLNA/UPNP. From 649cae4c4c58607cd296a3d7fed874021db2c33a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 4 Oct 2020 10:32:49 +0200 Subject: [PATCH 17/24] Update app_minidlna.md --- app_minidlna.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app_minidlna.md b/app_minidlna.md index b503aec..b7515af 100644 --- a/app_minidlna.md +++ b/app_minidlna.md @@ -6,7 +6,7 @@ It allows to easily share multimedia files with any compatible devices present o Minidlna does not have a graphical interface, but does not require any special configuration. ### What multimedia files are shared? -Minidlna is sharing the folder /home/yunohost.multimedia/share, which is common to each user in /home/$USER/Multimedia/Share. +MiniDLNA is sharing the folder `/home/yunohost.multimedia/share`, which is common to each user in `/home/$USER/Multimedia/Share`. [More information about multimedia files here.](https://github.com/YunoHost-Apps/yunohost.multimedia) If [Transmission](https://github.com/YunoHost-Apps/transmission_ynh) is installed, the downloaded media will be available in DLNA. From cb154470a6274a615e6dadc72b76ce592befa1b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 4 Oct 2020 10:33:02 +0200 Subject: [PATCH 18/24] Update app_minidlna.md --- app_minidlna.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app_minidlna.md b/app_minidlna.md index b7515af..0f13211 100644 --- a/app_minidlna.md +++ b/app_minidlna.md @@ -3,7 +3,7 @@ Minidlna is a lightweight [dlna](https://fr.wikipedia.org/wiki/Digital_Living_Network_Alliance) server. It allows to easily share multimedia files with any compatible devices present on the LAN. -Minidlna does not have a graphical interface, but does not require any special configuration. +MiniDLNA does not have a graphical interface, but does not require any special configuration. ### What multimedia files are shared? MiniDLNA is sharing the folder `/home/yunohost.multimedia/share`, which is common to each user in `/home/$USER/Multimedia/Share`. From 0b3a195a755ae091cf243edbec80c4824d9fecd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 4 Oct 2020 10:33:15 +0200 Subject: [PATCH 19/24] Update scripts/install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 2ebc3c6..ffbe857 100644 --- a/scripts/install +++ b/scripts/install @@ -70,7 +70,7 @@ ynh_multimedia_build_main_dir #================================================= # INSTALL MINIDLNA #================================================= -ynh_script_progression --message="Installing minidlna..." --weight=45 +ynh_script_progression --message="Installing MiniDLNA..." --weight=45 if [ ${version:0:1} = "B" ] then From 57a619bae39a7f099ecb7990bddf3a344ad018b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 4 Oct 2020 10:33:28 +0200 Subject: [PATCH 20/24] Update scripts/restore --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 73f8ad3..4649c1d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -47,7 +47,7 @@ ynh_multimedia_build_main_dir #================================================= # INSTALL MINIDLNA #================================================= -ynh_script_progression --message="Installing minidlna" --weight=45 +ynh_script_progression --message="Installing MiniDLNA" --weight=45 if [ ${version:0:1} = "B" ] then From 8c52c44bc09111b9e4983a7c482f66728461ed93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 4 Oct 2020 10:33:46 +0200 Subject: [PATCH 21/24] Update scripts/remove --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 153301e..b82ecd1 100755 --- a/scripts/remove +++ b/scripts/remove @@ -67,4 +67,4 @@ fi # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression --message="Removal of MiniDLNA completed" --last From 913099f77867766eb174ec55d76f6b6591287986 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 3 Nov 2020 15:45:20 +0100 Subject: [PATCH 22/24] Remove unused helpers --- scripts/_common.sh | 333 ------------------------------ scripts/actions/install_backports | 2 +- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 5 files changed, 4 insertions(+), 337 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 3770c0f..c9529ba 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -265,111 +265,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 - path_url=$(ynh_app_setting_get $app path) - fi - if [ -z $domain ]; then - domain=$(ynh_app_setting_get $app domain) - fi - - mkdir -p /var/www/html/ - - # Create an html to serve as maintenance notice - echo " - - - -Your app $app is currently under maintenance! - - - -

Your app $app is currently under maintenance!

-

This app has been put under maintenance by your administrator at $(date)

-

Please wait until the maintenance operation is done. This page will be reloaded as soon as your app will be back.

- - -" > "/var/www/html/maintenance.$app.html" - - # Create a new nginx config file to redirect all access to the app to the maintenance notice instead. - echo "# All request to the app will be redirected to ${path_url}_maintenance and fall on the maintenance notice -rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/? redirect; -# Use another location, to not be in conflict with the original config file -location ${path_url}_maintenance/ { -alias /var/www/html/ ; - -try_files maintenance.$app.html =503; - -# Include SSOWAT user panel. -include conf.d/yunohost_panel.conf.inc; -}" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" - - # The current config file will redirect all requests to the root of the app. - # To keep the full path, we can use the following rewrite rule: - # rewrite ^${path_url}/(.*)$ ${path_url}_maintenance/\$1? redirect; - # The difference will be in the $1 at the end, which keep the following queries. - # But, if it works perfectly for a html request, there's an issue with any php files. - # This files are treated as simple files, and will be downloaded by the browser. - # Would be really be nice to be able to fix that issue. So that, when the page is reloaded after the maintenance, the user will be redirected to the real page he was. - - systemctl reload nginx -} - -ynh_maintenance_mode_OFF () { - # Load value of $path_url and $domain from the config if their not set - if [ -z $path_url ]; then - path_url=$(ynh_app_setting_get $app path) - fi - if [ -z $domain ]; then - domain=$(ynh_app_setting_get $app domain) - fi - - # Rewrite the nginx config file to redirect from ${path_url}_maintenance to the real url of the app. - echo "rewrite ^${path_url}_maintenance/(.*)$ ${path_url}/\$1 redirect;" > "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" - systemctl reload nginx - - # Sleep 4 seconds to let the browser reload the pages and redirect the user to the app. - sleep 4 - - # Then remove the temporary files used for the maintenance. - rm "/var/www/html/maintenance.$app.html" - rm "/etc/nginx/conf.d/$domain.d/maintenance.$app.conf" - - systemctl reload nginx -} - -#================================================= - # Create a changelog for an app after an upgrade from the file CHANGELOG.md. # # usage: ynh_app_changelog [--format=markdown/html/plain] [--output=changelog_file] --changelog=changelog_source] @@ -508,234 +403,6 @@ ynh_app_changelog () { #================================================= -# Check the amount of available RAM -# -# usage: ynh_check_ram [--required=RAM required in Mb] [--no_swap|--only_swap] [--free_ram] -# | arg: -r, --required= - Amount of RAM required in Mb. The helper will return 0 is there's enough RAM, or 1 otherwise. -# If --required isn't set, the helper will print the amount of RAM, in Mb. -# | arg: -s, --no_swap - Ignore swap -# | arg: -o, --only_swap - Ignore real RAM, consider only swap. -# | arg: -f, --free_ram - Count only free RAM, not the total amount of RAM available. -ynh_check_ram () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [r]=required= [s]=no_swap [o]=only_swap [f]=free_ram ) - local required - local no_swap - local only_swap - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - required=${required:-} - no_swap=${no_swap:-0} - only_swap=${only_swap:-0} - - local total_ram=$(vmstat --stats --unit M | grep "total memory" | awk '{print $1}') - local total_swap=$(vmstat --stats --unit M | grep "total swap" | awk '{print $1}') - local total_ram_swap=$(( total_ram + total_swap )) - - local free_ram=$(vmstat --stats --unit M | grep "free memory" | awk '{print $1}') - local free_swap=$(vmstat --stats --unit M | grep "free swap" | awk '{print $1}') - local free_ram_swap=$(( free_ram + free_swap )) - - # Use the total amount of ram - local ram=$total_ram_swap - if [ $free_ram -eq 1 ] - then - # Use the total amount of free ram - ram=$free_ram_swap - if [ $no_swap -eq 1 ] - then - # Use only the amount of free ram - ram=$free_ram - elif [ $only_swap -eq 1 ] - then - # Use only the amount of free swap - ram=$free_swap - fi - else - if [ $no_swap -eq 1 ] - then - # Use only the amount of free ram - ram=$total_ram - elif [ $only_swap -eq 1 ] - then - # Use only the amount of free swap - ram=$total_swap - fi - fi - - if [ -n "$required" ] - then - # Return 1 if the amount of ram isn't enough. - if [ $ram -lt $required ] - then - return 1 - else - return 0 - fi - - # If no RAM is required, return the amount of available ram. - else - echo $ram - fi -} - -#================================================= - -# Define the values to configure php-fpm -# -# usage: ynh_get_scalable_phpfpm --usage=usage --footprint=footprint [--print] -# | arg: -f, --footprint - Memory footprint of the service (low/medium/high). -# low - Less than 20Mb of ram by pool. -# medium - Between 20Mb and 40Mb of ram by pool. -# high - More than 40Mb of ram by pool. -# Or specify exactly the footprint, the load of the service as Mb by pool instead of having a standard value. -# To have this value, use the following command and stress the service. -# watch -n0.5 ps -o user,cmd,%cpu,rss -u APP -# -# | arg: -u, --usage - Expected usage of the service (low/medium/high). -# low - Personal usage, behind the sso. -# medium - Low usage, few people or/and publicly accessible. -# high - High usage, frequently visited website. -# -# | arg: -p, --print - Print the result -# -# -# -# The footprint of the service will be used to defined the maximum footprint we can allow, which is half the maximum RAM. -# So it will be used to defined 'pm.max_children' -# A lower value for the footprint will allow more children for 'pm.max_children'. And so for -# 'pm.start_servers', 'pm.min_spare_servers' and 'pm.max_spare_servers' which are defined from the -# value of 'pm.max_children' -# NOTE: 'pm.max_children' can't exceed 4 times the number of processor's cores. -# -# The usage value will defined the way php will handle the children for the pool. -# A value set as 'low' will set the process manager to 'ondemand'. Children will start only if the -# service is used, otherwise no child will stay alive. This config gives the lower footprint when the -# service is idle. But will use more proc since it has to start a child as soon it's used. -# Set as 'medium', the process manager will be at dynamic. If the service is idle, a number of children -# equal to pm.min_spare_servers will stay alive. So the service can be quick to answer to any request. -# The number of children can grow if needed. The footprint can stay low if the service is idle, but -# not null. The impact on the proc is a little bit less than 'ondemand' as there's always a few -# children already available. -# Set as 'high', the process manager will be set at 'static'. There will be always as many children as -# 'pm.max_children', the footprint is important (but will be set as maximum a quarter of the maximum -# RAM) but the impact on the proc is lower. The service will be quick to answer as there's always many -# children ready to answer. -ynh_get_scalable_phpfpm () { - local legacy_args=ufp - # Declare an array to define the options of this helper. - declare -Ar args_array=( [u]=usage= [f]=footprint= [p]=print ) - local usage - local footprint - local print - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - # Set all characters as lowercase - footprint=${footprint,,} - usage=${usage,,} - print=${print:-0} - - if [ "$footprint" = "low" ] - then - footprint=20 - elif [ "$footprint" = "medium" ] - then - footprint=35 - elif [ "$footprint" = "high" ] - then - footprint=50 - fi - - # Define the way the process manager handle child processes. - if [ "$usage" = "low" ] - then - php_pm=ondemand - elif [ "$usage" = "medium" ] - then - php_pm=dynamic - elif [ "$usage" = "high" ] - then - php_pm=static - else - ynh_die --message="Does not recognize '$usage' as an usage value." - fi - - # Get the total of RAM available, except swap. - local max_ram=$(ynh_check_ram --no_swap) - - less0() { - # Do not allow value below 1 - if [ $1 -le 0 ] - then - echo 1 - else - echo $1 - fi - } - - # Define pm.max_children - # The value of pm.max_children is the total amount of ram divide by 2 and divide again by the footprint of a pool for this app. - # So if php-fpm start the maximum of children, it won't exceed half of the ram. - php_max_children=$(( $max_ram / 2 / $footprint )) - # If process manager is set as static, use half less children. - # Used as static, there's always as many children as the value of pm.max_children - if [ "$php_pm" = "static" ] - then - php_max_children=$(( $php_max_children / 2 )) - fi - php_max_children=$(less0 $php_max_children) - - # To not overload the proc, limit the number of children to 4 times the number of cores. - local core_number=$(nproc) - local max_proc=$(( $core_number * 4 )) - if [ $php_max_children -gt $max_proc ] - then - php_max_children=$max_proc - fi - - if [ "$php_pm" = "dynamic" ] - then - # Define pm.start_servers, pm.min_spare_servers and pm.max_spare_servers for a dynamic process manager - php_min_spare_servers=$(( $php_max_children / 8 )) - php_min_spare_servers=$(less0 $php_min_spare_servers) - - php_max_spare_servers=$(( $php_max_children / 2 )) - php_max_spare_servers=$(less0 $php_max_spare_servers) - - php_start_servers=$(( $php_min_spare_servers + ( $php_max_spare_servers - $php_min_spare_servers ) /2 )) - php_start_servers=$(less0 $php_start_servers) - else - php_min_spare_servers=0 - php_max_spare_servers=0 - php_start_servers=0 - fi - - if [ $print -eq 1 ] - then - ynh_debug --message="Footprint=${footprint}Mb by pool." - ynh_debug --message="Process manager=$php_pm" - ynh_debug --message="Max RAM=${max_ram}Mb" - if [ "$php_pm" != "static" ]; then - ynh_debug --message="\nMax estimated footprint=$(( $php_max_children * $footprint ))" - ynh_debug --message="Min estimated footprint=$(( $php_min_spare_servers * $footprint ))" - fi - if [ "$php_pm" = "dynamic" ]; then - ynh_debug --message="Estimated average footprint=$(( $php_max_spare_servers * $footprint ))" - elif [ "$php_pm" = "static" ]; then - ynh_debug --message="Estimated footprint=$(( $php_max_children * $footprint ))" - fi - ynh_debug --message="\nRaw php-fpm values:" - ynh_debug --message="pm.max_children = $php_max_children" - if [ "$php_pm" = "dynamic" ]; then - ynh_debug --message="pm.start_servers = $php_start_servers" - ynh_debug --message="pm.min_spare_servers = $php_min_spare_servers" - ynh_debug --message="pm.max_spare_servers = $php_max_spare_servers" - fi - fi -} - -#================================================= - # Execute a command as another user # usage: exec_as USER COMMAND [ARG ...] exec_as() { diff --git a/scripts/actions/install_backports b/scripts/actions/install_backports index 5bab82e..9eb9ae3 100755 --- a/scripts/actions/install_backports +++ b/scripts/actions/install_backports @@ -39,7 +39,7 @@ ynh_script_progression --message="Re-installing MiniDLNA from backports..." --we ynh_package_remove minidlna # Then install the version from backports -codename=$(ynh_debian_release) +codename=$(ynh_get_debian_release) test -z "$codename" && (ynh_die --message="codename empty") ynh_replace_string --match_string="__CODENAME__" --replace_string="$codename" --target_file=/etc/yunohost/apps/$app/conf/minidlna.list diff --git a/scripts/install b/scripts/install index 13f7dca..31cc6a6 100644 --- a/scripts/install +++ b/scripts/install @@ -39,7 +39,7 @@ ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 #================================================= ynh_script_progression --message="Checking Debian's codename..." -codename=$(ynh_debian_release) +codename=$(ynh_get_debian_release) test -z "$codename" && (ynh_die --message="codename empty") #================================================= diff --git a/scripts/restore b/scripts/restore index 3803f87..b66e321 100644 --- a/scripts/restore +++ b/scripts/restore @@ -52,7 +52,7 @@ ynh_script_progression --message="Installing MiniDLNA" --weight=45 if [ ${version:0:1} = "B" ] then # Install the backport version. (If you have issues with the standard version from the stable repository) - codename=$(ynh_debian_release) + codename=$(ynh_get_debian_release) ynh_restore_file --origin_path="/etc/apt/sources.list.d/minidlna.list" ynh_replace_string --match_string=" [a-z]*-backports" --replace_string=" $codename-backports" --target_file=/etc/apt/sources.list.d/minidlna.list ynh_apt update diff --git a/scripts/upgrade b/scripts/upgrade index 50ae197..11e11cc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -80,7 +80,7 @@ ynh_script_progression --message="Upgrading MiniDLNA..." --weight=3 if [ $version = "B" ] then # Install the backport version. (If you have issues with the standard version from the stable repository) - codename=$(ynh_debian_release) + codename=$(ynh_get_debian_release) ynh_replace_string --match_string="__CODENAME__" --replace_string="$codename" --target_file=../conf/minidlna.list cp -a ../conf/minidlna.list /etc/apt/sources.list.d/ ynh_apt update From e71dfdc17366bb88f1fc05a90e99ab1b4ba31ba1 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 3 Nov 2020 16:09:07 +0100 Subject: [PATCH 23/24] Don't use backport anymore (the app is in main source list now) --- README.md | 2 +- README_fr.md | 2 +- actions.toml | 8 ----- check_process | 20 +++--------- manifest.json | 12 +------ scripts/actions/install_backports | 54 ------------------------------- scripts/actions/install_standard | 47 --------------------------- scripts/backup | 11 ------- scripts/install | 18 +---------- scripts/remove | 3 +- scripts/restore | 15 +-------- scripts/upgrade | 20 ++++-------- 12 files changed, 17 insertions(+), 195 deletions(-) delete mode 100755 scripts/actions/install_backports delete mode 100755 scripts/actions/install_standard diff --git a/README.md b/README.md index fd56407..5720777 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to MiniDLNA is a simple media server software, with the aim of being fully compliant with DLNA/UPnP-AV clients. -**Shipped version:** Debian repositories versions. Currently 1.1.6 and 1.2.1 +**Shipped version:** Debian repositories versions. Currently 1.2.1 ## Screenshots diff --git a/README_fr.md b/README_fr.md index f048bd1..0e28f56 100644 --- a/README_fr.md +++ b/README_fr.md @@ -12,7 +12,7 @@ Si vous n'avez pas YunoHost, merci de regarder [ici](https://yunohost.org/#/inst MiniDLNA est un simple serveur multimédia, dont le but est d'être entièrement compatible avec les clients DLNA/UPnP-AV. -**Version embarquée :** Versions des dépôts Debian. Actuellement 1.1.6 et 1.2.1 +**Version embarquée :** Versions des dépôts Debian. Actuellement 1.2.1 ## Captures d'écran diff --git a/actions.toml b/actions.toml index b5f7183..a051a56 100644 --- a/actions.toml +++ b/actions.toml @@ -1,11 +1,3 @@ -[install_standard] -name = "Install the version from stable repository" -command = "/bin/bash scripts/actions/install_standard" - -[install_backports] -name = "Install the version from backports repository" -command = "/bin/bash scripts/actions/install_backports" - [reset_db] name = "Reinitialise the database" command = "/bin/bash scripts/actions/reset_db" diff --git a/check_process b/check_process index 8daa3b8..77a82b6 100644 --- a/check_process +++ b/check_process @@ -1,6 +1,4 @@ ;; Test paquet stable - ; Manifest - version="A. Version of the Debian repositories - recommended" ; Checks pkg_linter=1 setup_sub_dir=0 @@ -10,24 +8,11 @@ setup_public=0 upgrade=1 upgrade=1 from_commit=2c107b09144c9829be5cc94b202d0f766b2a0db4 + upgrade=1 from_commit=7fa6b0a84e0cb24cd5a26d2f5d64f68875862f42 backup_restore=1 multi_instance=0 port_already_use=1 (48200) change_url=0 -;; Test paquet backports - ; Manifest - version="B. Latest version available for Debian" - ; Checks - setup_sub_dir=0 - setup_root=0 - setup_nourl=1 - setup_private=0 - setup_public=0 - upgrade=1 - backup_restore=0 - multi_instance=0 - port_already_use=0 - change_url=0 ;;; Levels Level 5=auto ;;; Options @@ -37,3 +22,6 @@ Notification=down ; commit=2c107b09144c9829be5cc94b202d0f766b2a0db4 name=01 May 2017 2c107b09144c9829be5cc94b202d0f766b2a0db4 manifest_arg=version=A. Version of the Debian repositories - recommended& + ; commit=7fa6b0a84e0cb24cd5a26d2f5d64f68875862f42 + name=20 Jun 2019 7fa6b0a84e0cb24cd5a26d2f5d64f68875862f42 + manifest_arg=version=B. Latest version available for Debian& diff --git a/manifest.json b/manifest.json index 2680500..b41b0ce 100644 --- a/manifest.json +++ b/manifest.json @@ -23,16 +23,6 @@ "multi_instance": false, "services": [], "arguments": { - "install" : [ - { - "name": "version", - "ask": { - "en": "Select the MiniDLNA version to install", - "fr": "Choix de la version de MiniDLNA à installer" - }, - "choices": ["A. Version of the Debian repositories - recommended", "B. Latest version available for Debian"], - "default": "A. Version of the Debian repositories - recommended" - } - ] + "install" : [] } } diff --git a/scripts/actions/install_backports b/scripts/actions/install_backports deleted file mode 100755 index 9eb9ae3..0000000 --- a/scripts/actions/install_backports +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -source scripts/_common.sh -source /usr/share/yunohost/helpers - -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -app=${YNH_APP_INSTANCE_NAME:-$YNH_APP_ID} - -#================================================= -# CHECK IF ARGUMENTS ARE CORRECT -#================================================= - -#================================================= -# CHECK IF AN ACTION HAS TO BE DONE -#================================================= - -if [ -e /etc/apt/sources.list.d/minidlna.list ] -then - ynh_die --message="You are already using the version from backports repository." --ret_code=0 -fi - -#================================================= -# SPECIFIC ACTION -#================================================= -# RE-INSTALL MINIDLNA FROM BACKPORTS -#================================================= -ynh_script_progression --message="Re-installing MiniDLNA from backports..." --weight=9 - -# Remove the current version of minidlna -ynh_package_remove minidlna - -# Then install the version from backports -codename=$(ynh_get_debian_release) -test -z "$codename" && (ynh_die --message="codename empty") - -ynh_replace_string --match_string="__CODENAME__" --replace_string="$codename" --target_file=/etc/yunohost/apps/$app/conf/minidlna.list -cp -a /etc/yunohost/apps/$app/conf/minidlna.list /etc/apt/sources.list.d/ -ynh_apt update -ynh_package_install -t $codename-backports minidlna - -#================================================= -# END OF SCRIPT -#================================================= - -ynh_script_progression --message="Execution completed" --last diff --git a/scripts/actions/install_standard b/scripts/actions/install_standard deleted file mode 100755 index 76f34e6..0000000 --- a/scripts/actions/install_standard +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash - -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -source scripts/_common.sh -source /usr/share/yunohost/helpers - -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -#================================================= -# CHECK IF ARGUMENTS ARE CORRECT -#================================================= - -#================================================= -# CHECK IF AN ACTION HAS TO BE DONE -#================================================= - -if [ ! -e /etc/apt/sources.list.d/minidlna.list ] -then - ynh_die --message="You are already using the version from the stable repository." --ret_code=0 -fi - -#================================================= -# SPECIFIC ACTION -#================================================= -# RE-INSTALL MINIDLNA FROM STABLE -#================================================= -ynh_script_progression --message="Re-installing MiniDLNA from stable..." --weight=9 - -# Remove the current version of minidlna -ynh_package_remove minidlna -ynh_secure_remove --file="/etc/apt/sources.list.d/minidlna.list" - -ynh_apt update -ynh_package_install minidlna - -#================================================= -# END OF SCRIPT -#================================================= - -ynh_script_progression --message="Execution completed" --last diff --git a/scripts/backup b/scripts/backup index fc4e649..c13a19f 100644 --- a/scripts/backup +++ b/scripts/backup @@ -23,22 +23,11 @@ ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -version=$(ynh_app_setting_get --app=$app --key=version) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= ynh_print_info --message="Declaring files to be backed up..." -#================================================= -# BACKUP OF THE APT SOURCE -#================================================= - -if [ $version = "B" ] -then - ynh_backup --src_path="/etc/apt/sources.list.d/minidlna.list" -fi - #================================================= # BACKUP OF INOTIFY'S CONFIG #================================================= diff --git a/scripts/install b/scripts/install index 31cc6a6..706063f 100644 --- a/scripts/install +++ b/scripts/install @@ -20,8 +20,6 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -version="$YNH_APP_ARG_VERSION" - app=$YNH_APP_INSTANCE_NAME #================================================= @@ -29,8 +27,6 @@ app=$YNH_APP_INSTANCE_NAME #================================================= ynh_script_progression --message="Storing installation settings..." --weight=2 -ynh_app_setting_set --app=$app --key=version --value=${version:0:1} - ynh_app_setting_set --app=$app --key=overwrite_settings --value=1 ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 @@ -72,19 +68,7 @@ ynh_multimedia_build_main_dir #================================================= ynh_script_progression --message="Installing MiniDLNA..." --weight=45 -if [ ${version:0:1} = "B" ] -then - # Install the backport version. (If you have issues with the standard version from the stable repository) - ynh_replace_string --match_string="__CODENAME__" --replace_string="$codename" --target_file=../conf/minidlna.list - cp -a ../conf/minidlna.list /etc/apt/sources.list.d/ - ynh_apt update - ynh_package_install -t $codename-backports minidlna -else - # Install the standard version from debian repository - ynh_apt update - ynh_package_install minidlna -fi -ynh_app_setting_set --app=$app --key=version --value=${version:0:1} +ynh_add_app_dependencies --package=minidlna #================================================= # INCREASE INOTIFY'S LIMITS diff --git a/scripts/remove b/scripts/remove index 83788a3..8281d88 100755 --- a/scripts/remove +++ b/scripts/remove @@ -46,8 +46,7 @@ ynh_exec_fully_quiet yunohost firewall disallow UDP 1900 #================================================= ynh_script_progression --message="Removing MiniDLNA..." --weight=6 -ynh_apt purge minidlna -ynh_secure_remove --file="/etc/apt/sources.list.d/minidlna.list" +ynh_remove_app_dependencies #================================================= # REMOVE INOTIFY'S CONFIG diff --git a/scripts/restore b/scripts/restore index b66e321..816f3d3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -23,7 +23,6 @@ ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME -version=$(ynh_app_setting_get --app=$app --key=version) port=$(ynh_app_setting_get --app=$app --key=port) #================================================= @@ -49,19 +48,7 @@ ynh_multimedia_build_main_dir #================================================= ynh_script_progression --message="Installing MiniDLNA" --weight=45 -if [ ${version:0:1} = "B" ] -then - # Install the backport version. (If you have issues with the standard version from the stable repository) - codename=$(ynh_get_debian_release) - ynh_restore_file --origin_path="/etc/apt/sources.list.d/minidlna.list" - ynh_replace_string --match_string=" [a-z]*-backports" --replace_string=" $codename-backports" --target_file=/etc/apt/sources.list.d/minidlna.list - ynh_apt update - ynh_package_install -t $codename-backports minidlna -else - # Install the standard version from debian repository - ynh_apt update - ynh_package_install minidlna -fi +ynh_add_app_dependencies --package=minidlna #================================================= # RESTORE INOTIFY'S CONFIG diff --git a/scripts/upgrade b/scripts/upgrade index 11e11cc..2056fb9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -51,6 +51,12 @@ if [ -z "$friendly_name" ]; then ynh_app_setting_set --app=$app --key=friendly_name --value=$friendly_name fi +# If version exists, remove the backport source list, as it's no longer used. +if [ -n "$version" ]; then + ynh_secure_remove --file="/etc/apt/sources.list.d/minidlna.list" + ynh_app_setting_delete --app=$app --key=version +fi + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -77,19 +83,7 @@ ynh_multimedia_build_main_dir #================================================= ynh_script_progression --message="Upgrading MiniDLNA..." --weight=3 -if [ $version = "B" ] -then - # Install the backport version. (If you have issues with the standard version from the stable repository) - codename=$(ynh_get_debian_release) - ynh_replace_string --match_string="__CODENAME__" --replace_string="$codename" --target_file=../conf/minidlna.list - cp -a ../conf/minidlna.list /etc/apt/sources.list.d/ - ynh_apt update - ynh_package_install -t $codename-backports minidlna -else - # Install the standard version from debian repository - ynh_apt update - ynh_package_install minidlna -fi +ynh_add_app_dependencies --package=minidlna #================================================= # INCREASE INOTIFY'S LIMITS From 915bd181c78aa85c4191517edd4886689f4cb105 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 3 Nov 2020 16:48:32 +0100 Subject: [PATCH 24/24] ynh_add_app_dependencies -> ynh_install_app_dependencies --- conf/minidlna.list | 1 - manifest.json | 2 +- scripts/install | 10 +--------- scripts/restore | 2 +- scripts/upgrade | 2 +- 5 files changed, 4 insertions(+), 13 deletions(-) delete mode 100644 conf/minidlna.list diff --git a/conf/minidlna.list b/conf/minidlna.list deleted file mode 100644 index 73dfaf0..0000000 --- a/conf/minidlna.list +++ /dev/null @@ -1 +0,0 @@ -deb http://http.debian.net/debian __CODENAME__-backports main diff --git a/manifest.json b/manifest.json index b41b0ce..e879bc5 100644 --- a/manifest.json +++ b/manifest.json @@ -18,7 +18,7 @@ "email": "maniackc_dev@crudelis.fr" }], "requirements": { - "yunohost": ">= 3.5" + "yunohost": ">= 3.6" }, "multi_instance": false, "services": [], diff --git a/scripts/install b/scripts/install index 706063f..31b2a6a 100644 --- a/scripts/install +++ b/scripts/install @@ -30,14 +30,6 @@ ynh_script_progression --message="Storing installation settings..." --weight=2 ynh_app_setting_set --app=$app --key=overwrite_settings --value=1 ynh_app_setting_set --app=$app --key=admin_mail_html --value=1 -#================================================= -# CHECK DEBIAN'S CODENAME -#================================================= -ynh_script_progression --message="Checking Debian's codename..." - -codename=$(ynh_get_debian_release) -test -z "$codename" && (ynh_die --message="codename empty") - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -68,7 +60,7 @@ ynh_multimedia_build_main_dir #================================================= ynh_script_progression --message="Installing MiniDLNA..." --weight=45 -ynh_add_app_dependencies --package=minidlna +ynh_install_app_dependencies minidlna #================================================= # INCREASE INOTIFY'S LIMITS diff --git a/scripts/restore b/scripts/restore index 816f3d3..a405df0 100644 --- a/scripts/restore +++ b/scripts/restore @@ -48,7 +48,7 @@ ynh_multimedia_build_main_dir #================================================= ynh_script_progression --message="Installing MiniDLNA" --weight=45 -ynh_add_app_dependencies --package=minidlna +ynh_install_app_dependencies minidlna #================================================= # RESTORE INOTIFY'S CONFIG diff --git a/scripts/upgrade b/scripts/upgrade index 2056fb9..f2157dd 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -83,7 +83,7 @@ ynh_multimedia_build_main_dir #================================================= ynh_script_progression --message="Upgrading MiniDLNA..." --weight=3 -ynh_add_app_dependencies --package=minidlna +ynh_install_app_dependencies minidlna #================================================= # INCREASE INOTIFY'S LIMITS