From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 5821F158041 for ; Thu, 28 Mar 2024 16:13:00 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 787CD2BC023; Thu, 28 Mar 2024 16:12:58 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 592882BC023 for ; Thu, 28 Mar 2024 16:12:58 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 368C3343030 for ; Thu, 28 Mar 2024 16:12:56 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5E2911603 for ; Thu, 28 Mar 2024 16:12:54 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1711639518.6f38e3bd7e84b8d7c8df5229b4a5f1a34cb4843a.grobian@gentoo> Subject: [gentoo-commits] repo/proj/prefix:master commit in: scripts/rsync-generation/ X-VCS-Repository: repo/proj/prefix X-VCS-Files: scripts/rsync-generation/refresh-mirror.sh X-VCS-Directories: scripts/rsync-generation/ X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 6f38e3bd7e84b8d7c8df5229b4a5f1a34cb4843a X-VCS-Branch: master Date: Thu, 28 Mar 2024 16:12:54 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 69a2b5a7-f123-4ab1-8701-00b0a07e4810 X-Archives-Hash: 743e7d099ebbcfb81ca9b7236ec7cd24 commit: 6f38e3bd7e84b8d7c8df5229b4a5f1a34cb4843a Author: Fabian Groffen gentoo org> AuthorDate: Thu Mar 28 15:25:18 2024 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Thu Mar 28 15:25:18 2024 +0000 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=6f38e3bd scripts/rsync-generation/refresh-mirror: shellcheck Signed-off-by: Fabian Groffen gentoo.org> scripts/rsync-generation/refresh-mirror.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/rsync-generation/refresh-mirror.sh b/scripts/rsync-generation/refresh-mirror.sh index 6e2baffaa4..cbcb677266 100755 --- a/scripts/rsync-generation/refresh-mirror.sh +++ b/scripts/rsync-generation/refresh-mirror.sh @@ -1,4 +1,8 @@ #!/bin/bash -l +#shellcheck disable=SC2009,SC2030,SC2031 +#SC2009: consider using pgrep instead of grepping ps output +#SC2030: modification of FD is local (to subshell) +#SC2031: FD was modified in subshell # invocation script meant to be launched from cron @@ -10,7 +14,7 @@ if [[ -f /tmp/rsync-master-busy ]] ; then # allow one run to be skipped quietly if [[ $((laststart + (40 * 60))) -lt ${now} ]] ; then echo "another rsync-master generation process is still busy" - type pstree > /dev/null && pstree -A -l -p $(head -n1 ${LOGFILE}) + type pstree > /dev/null && pstree -A -l -p "$(head -n1 ${LOGFILE})" ps -ef | grep '[r]efresh-mirror' tail ${LOGFILE} else @@ -22,16 +26,16 @@ if [[ -f /tmp/rsync-master-busy ]] ; then pid=$(head -n1 ${LOGFILE}) if [[ ${pid} -gt 0 ]] ; then echo "Killing stray/stuck processes" - pstree -A -l -c -p ${pid} | grep -o '[0-9]\+' | xargs kill + pstree -A -l -c -p "${pid}" | grep -o '[0-9]\+' | xargs kill rm /tmp/rsync-master-busy fi fi else - mv ${LOGFILE} ${LOGFILE%.log}-prev.log - cd "$(readlink -f "${BASH_SOURCE[0]%/*}")" + mv "${LOGFILE}" "${LOGFILE%.log}"-prev.log + cd "$(readlink -f "${BASH_SOURCE[0]%/*}")" || exit 1 touch /tmp/rsync-master-busy - echo $$ > ${LOGFILE} - echo "starting generation $(date)" >> ${LOGFILE} + echo $$ > "${LOGFILE}" + echo "starting generation $(date)" >> "${LOGFILE}" genandpush() { ./update-rsync-master.sh \ && ./push-rsync1.sh