From 452f2cad22a5546087f5a69d4dace8154ba71a59 Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 4 Dec 2020 16:51:27 +0100 Subject: [PATCH] Fix linter warnings --- scripts/_common.sh | 69 ---------------------------------------------- scripts/restore | 12 ++++---- scripts/upgrade | 13 ++++----- 3 files changed, 11 insertions(+), 83 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 180e689..45b1e90 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -125,72 +125,3 @@ $(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')" # Send the email to the recipients echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients" } - -#================================================= -# fail2ban helpers -# taken from https://github.com/YunoHost-Apps/shaarli_ynh -#================================================= - -# Create a dedicated fail2ban config (jail and filter conf files) -# -# usage: ynh_add_fail2ban_config log_file filter [max_retry [ports]] -# | arg: log_file - Log file to be checked by fail2ban -# | arg: failregex - Failregex to be looked for by fail2ban -# | 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 () { - local logpath - local failregex - local max_retry - local ports - - logpath=$1 - failregex=$2 - max_retry=${3:-3} - ports=${4:-http,https} - - test -n "$logpath" || ynh_die --message="ynh_add_fail2ban_config expects a logfile path as first argument and received nothing." - test -n "$failregex" || ynh_die --message="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 -} - -# 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" - systemctl reload fail2ban -} diff --git a/scripts/restore b/scripts/restore index d135d4e..0eb59f6 100644 --- a/scripts/restore +++ b/scripts/restore @@ -131,17 +131,17 @@ ynh_restore_file --origin_path="/etc/systemd/system/$app-server.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-worker.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.target" -systemctl enable "$app-beat.service" -systemctl enable "$app-server.service" -systemctl enable "$app-worker.service" +systemctl enable "$app-beat.service" --quiet +systemctl enable "$app-server.service" --quiet +systemctl enable "$app-worker.service" --quiet #================================================= # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add "$app-server" --log "/var/log/$app/server.log" -yunohost service add "$app-worker" --log "/var/log/$app/worker.log" -yunohost service add "$app-beat" --log "/var/log/$app/beat.log" +yunohost service add "$app-server" --log="/var/log/$app/server.log" +yunohost service add "$app-worker" --log="/var/log/$app/worker.log" +yunohost service add "$app-beat" --log="/var/log/$app/beat.log" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index 7cf2238..e88049c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -74,13 +74,6 @@ ynh_abort_if_errors # CHECK THE PATH #================================================= -# Normalize the URL path syntax -path_url=$(ynh_normalize_url_path "$path_url") - -#================================================= -# CHECK THE PATH -#================================================= - # see 0.20.0: https://docs.funkwhale.audio/changelog.html#automatically-load-env-file loadfile="$final_path/code/load_env" if [ -e "$loadfile" ] ; then @@ -220,7 +213,7 @@ ynh_replace_string --match_string="__KEY__" --replace_string="$key" # Delete the original thumbnails and generate new ones for # higher quality images # https://docs.funkwhale.audio/changelog.html#increased-quality-of-jpeg-thumbnails-manual-action-required - rm -rf "$final_path/media/__sized__" + ynh_secure_remove "$final_path/media/__sized__" python api/manage.py fw media generate-thumbnails ) @@ -263,6 +256,10 @@ chmod -R 755 "$final_path/code/front/dist/" mkdir -p "/var/log/$app" chown -R "$app": "/var/log/$app" +yunohost service add "$app-server" --log="/var/log/$app/server.log" +yunohost service add "$app-worker" --log="/var/log/$app/worker.log" +yunohost service add "$app-beat" --log="/var/log/$app/beat.log" + #================================================= # SETUP SSOWAT #=================================================