From 9ffeb7037f8304c959dfccb411ff93913a776c44 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 14 Mar 2018 23:24:11 +0100 Subject: [PATCH 1/2] Upgrade to 0.9.3 --- README.md | 5 +++-- README_fr.md | 5 +++-- conf/app.src | 4 ++-- manifest.json | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5ecb467..15314b4 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to Lutim stores images and allows you to see them, download them or share them on social networks. Images are indefinitely stored unless you request that they will be deleted at first view or after 24 hours / one week / one month / one year. -**Shipped version:** 0.8.8 +**Shipped version:** 0.9.3 ## Screenshots @@ -35,7 +35,8 @@ Not relevant. #### Supported architectures -* Tested on x86_64 +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/lutim%20(Community)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/lutim%20(Community)/) +* ARMv8-A - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/lutim%20(Community)%20(%7EARM%7E)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/lutim%20(Community)%20(%7EARM%7E)/) ## Limitations diff --git a/README_fr.md b/README_fr.md index 945867d..938b7e6 100644 --- a/README_fr.md +++ b/README_fr.md @@ -13,7 +13,7 @@ Si vous n'avez pas YunoHost, merci de regarder [ici](https://yunohost.org/#/inst Lutim stocke les images et vous permet de les voir, de les télécharger ou de les partager sur les réseaux sociaux. Les images sont stockées indéfiniment à moins que vous ne demandiez qu'elles soient effacées à la première vue ou après 24 heures / une semaine / un mois / un an. -**Version embarquée:** 0.8.8 +**Version embarquée:** 0.9.3 ## Captures d'écran @@ -35,7 +35,8 @@ Non applicable. #### Architectures supportées. -* Testé sur x86_64 +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/lutim%20(Community)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/lutim%20(Community)/) +* ARMv8-A - [![Build Status](https://ci-apps.yunohost.org/jenkins/job/lutim%20(Community)%20(%7EARM%7E)/badge/icon)](https://ci-apps.yunohost.org/jenkins/job/lutim%20(Community)%20(%7EARM%7E)/) ## Limitations diff --git a/conf/app.src b/conf/app.src index 157a9a1..bbdffd9 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://framagit.org/luc/lutim/repository/0.8.8/archive.tar.gz -SOURCE_SUM=86f8d05ef19b8919074a28273a00e85c +SOURCE_URL=https://framagit.org/luc/lutim/repository/0.9.3/archive.tar.gz +SOURCE_SUM=e11380472f314011328b4e2aa31f3ba8 SOURCE_SUM_PRG=md5sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index b9b6ecd..2223b7b 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Self hosting images and sharing anonymous application", "fr": "Application d'hébergement et de partage d'images anonyme" }, - "version": "0.8.8~ynh1", + "version": "0.9.3~ynh1", "url": "https://lut.im", "license": "AGPL-3.0", "maintainer": { From 4f529c127b99c805f748b87b0be0553ab800b92d Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 14 Mar 2018 23:24:29 +0100 Subject: [PATCH 2/2] Update helpers --- scripts/_common.sh | 123 ++++++++++++++++++++++++++++++--------------- scripts/change_url | 2 +- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 5 files changed, 87 insertions(+), 44 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 746baa4..22b21c9 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -212,15 +212,17 @@ EOF # Start or restart a service and follow its booting # -# usage: ynh_check_starting "Line to match" [Log file] [Timeout] +# usage: ynh_check_starting "Line to match" [Log file] [Timeout] [Service name] # # | arg: Line to match - The line to find in the log to attest the service have finished to boot. # | arg: Log file - The log file to watch +# | arg: Service name # /var/log/$app/$app.log will be used if no other log is defined. # | arg: Timeout - The maximum time to wait before ending the watching. Defaut 300 seconds. ynh_check_starting () { local line_to_match="$1" - local app_log="${2:-/var/log/$app/$app.log}" + local service_name="${4:-$app}" + local app_log="${2:-/var/log/$service_name/$service_name.log}" local timeout=${3:-300} ynh_clean_check_starting () { @@ -229,13 +231,14 @@ ynh_check_starting () { ynh_secure_remove "$templog" 2>&1 } - echo "Starting of $app" >&2 - systemctl restart $app + echo "Starting of $service_name" >&2 + systemctl stop $service_name local templog="$(mktemp)" # Following the starting of the app in its log - tail -f -n1 "$app_log" > "$templog" & + tail -F -n0 "$app_log" > "$templog" & # Get the PID of the tail command local pid_tail=$! + systemctl start $service_name local i=0 for i in `seq 1 $timeout` @@ -243,7 +246,7 @@ ynh_check_starting () { # Read the log until the sentence is found, that means the app finished to start. Or run until the timeout if grep --quiet "$line_to_match" "$templog" then - echo "The service $app has correctly started." >&2 + echo "The service $service_name has correctly started." >&2 break fi echo -n "." >&2 @@ -251,7 +254,7 @@ ynh_check_starting () { done if [ $i -eq $timeout ] then - echo "The service $app didn't fully started before the timeout." >&2 + echo "The service $service_name didn't fully started before the timeout." >&2 fi echo "" @@ -419,55 +422,56 @@ ynh_multimedia_addaccess () { # | arg: max_retry - Maximum number of retries allowed before banning IP address - default: 3 # | arg: ports - Ports blocked for a banned IP address - default: http,https ynh_add_fail2ban_config () { - # Process parameters - logpath=$1 - failregex=$2 - max_retry=${3:-3} - ports=${4:-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 - - sudo tee $finalfail2banjailconf <&2 - echo "WARNING${fail2ban_error#*WARNING}" >&2 - fi + ynh_store_file_checksum "$finalfail2banjailconf" + ynh_store_file_checksum "$finalfail2banfilterconf" + + systemctl restart fail2ban + local fail2ban_error="$(journalctl -u fail2ban | tail -n50 | grep "WARNING.*$app.*")" + if [ -n "$fail2ban_error" ] + then + echo "[ERR] Fail2ban failed to load the jail for $app" >&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" - sudo systemctl restart fail2ban + ynh_secure_remove "/etc/fail2ban/jail.d/$app.conf" + ynh_secure_remove "/etc/fail2ban/filter.d/$app.conf" + sudo systemctl restart fail2ban } #================================================= @@ -480,7 +484,7 @@ ynh_remove_fail2ban_config () { ynh_read_manifest () { manifest="$1" key="$2" - python3 -c "import sys, json;print(json.load(open('$manifest'))['$key'])" + python3 -c "import sys, json;print(json.load(open('$manifest', encoding='utf-8'))['$key'])" } # Exit without error if the package is up to date @@ -525,7 +529,7 @@ ynh_abort_if_up_to_date () { # If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you # example: "root admin@domain user1 user2" ynh_send_readme_to_admin() { - local app_message="${1:-...No specific informations...}" + local app_message="${1:-...No specific information...}" local recipients="${2:-root}" # Retrieve the email of users @@ -556,7 +560,7 @@ ynh_send_readme_to_admin() { local mail_message="This is an automated message from your beloved YunoHost server. -Specific informations for the application $app. +Specific information for the application $app. $app_message @@ -569,6 +573,45 @@ $(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')" echo "$mail_message" | mail -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients" } +#================================================= + +# Reload (or other actions) a service and print a log in case of failure. +# +# usage: ynh_system_reload service_name [action] +# | arg: service_name - Name of the service to reload +# | arg: action - Action to perform with systemctl. Default: reload +ynh_system_reload () { + local service_name=$1 + local action=${2:-reload} + + # Reload, restart or start and print the log if the service fail to start or reload + systemctl $action $service_name || ( journalctl --lines=20 -u $service_name >&2 && false) +} + +#================================================= + +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 +} + #================================================= #============= FUTURE YUNOHOST HELPER ============ #================================================= diff --git a/scripts/change_url b/scripts/change_url index 52411cb..267503b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -127,7 +127,7 @@ ynh_replace_string "\(^ *prefix.*=> '\).*" "\1$new_path'," "$final_path/lutim.co # RELOAD NGINX #================================================= -systemctl reload nginx +ynh_system_reload nginx #================================================= # START AND CHECK LUTIM BOOTING diff --git a/scripts/install b/scripts/install index 5d39039..16edee3 100644 --- a/scripts/install +++ b/scripts/install @@ -185,7 +185,7 @@ fi # RELOAD NGINX #================================================= -systemctl reload nginx +ynh_system_reload nginx #================================================= # CHECK LUTIM BOOTING diff --git a/scripts/restore b/scripts/restore index b7b3821..eedaa59 100644 --- a/scripts/restore +++ b/scripts/restore @@ -122,7 +122,7 @@ ynh_restore_file "/etc/logrotate.d/$app" # RELOAD NGINX #================================================= -systemctl reload nginx +ynh_system_reload nginx #================================================= # START AND CHECK LUTIM BOOTING diff --git a/scripts/upgrade b/scripts/upgrade index 93bb749..57ac4ae 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -170,7 +170,7 @@ fi # RELOAD NGINX #================================================= -systemctl reload nginx +ynh_system_reload nginx #================================================= # START AND CHECK LUTIM BOOTING