From patchwork Thu Jan 11 15:21:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tremer X-Patchwork-Id: 7450 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4T9pKY1zjwz3wnw for ; Thu, 11 Jan 2024 15:21:21 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4T9pKT2yjCz2Qr; Thu, 11 Jan 2024 15:21:17 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4T9pKT0Zw9z32gs; Thu, 11 Jan 2024 15:21:17 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384 client-signature ECDSA (secp384r1) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4T9pKP0KcMz2xWt for ; Thu, 11 Jan 2024 15:21:13 +0000 (UTC) Received: from michael.haj.ipfire.org (michael.haj.ipfire.org [172.28.1.242]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384 client-signature ECDSA (secp384r1) client-digest SHA384) (Client CN "michael.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4T9pKN0x5hzkB; Thu, 11 Jan 2024 15:21:12 +0000 (UTC) Received: by michael.haj.ipfire.org (Postfix, from userid 0) id 4T9pKM3Hm2zThcn; Thu, 11 Jan 2024 15:21:11 +0000 (UTC) From: Michael Tremer To: development@lists.ipfire.org Subject: [PATCH 1/2] initscripts: Fix wrong variable check for $PIDFILE in getpids Date: Thu, 11 Jan 2024 15:21:07 +0000 Message-Id: <20240111152108.4041802-1-michael.tremer@ipfire.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Message-ID-Hash: OMVMAXULDLF2R3F4ADFPCKEXKGXAHJBC X-Message-ID-Hash: OMVMAXULDLF2R3F4ADFPCKEXKGXAHJBC X-MailFrom: root@michael.haj.ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Michael Tremer X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: getpids() checked whether it needed to pass a pid file to pidofproc, but the check was inverted. Signed-off-by: Daniel Weismüller --- src/initscripts/system/functions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index 6f53a941b..e4cb30456 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -407,7 +407,7 @@ pidofproc() # This will ensure compatibility with previous LFS Bootscripts getpids() { - if [ -z "${PIDFILE}" ]; then + if [ -n "${PIDFILE}" ]; then pidofproc -s -p "${PIDFILE}" $@ else pidofproc -s $@ From patchwork Thu Jan 11 15:21:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tremer X-Patchwork-Id: 7449 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384 client-signature ECDSA (secp384r1) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4T9pKX6049z3wmD for ; Thu, 11 Jan 2024 15:21:20 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4T9pKS6CT1z18j; Thu, 11 Jan 2024 15:21:16 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4T9pKS4kpdz31s1; Thu, 11 Jan 2024 15:21:16 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384 client-signature ECDSA (secp384r1) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4T9pKP0BGvz2xNr for ; Thu, 11 Jan 2024 15:21:12 +0000 (UTC) Received: from michael.haj.ipfire.org (michael.haj.ipfire.org [172.28.1.242]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384 client-signature ECDSA (secp384r1) client-digest SHA384) (Client CN "michael.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4T9pKN1571z18j; Thu, 11 Jan 2024 15:21:12 +0000 (UTC) Received: by michael.haj.ipfire.org (Postfix, from userid 0) id 4T9pKM3NLhzTh1X; Thu, 11 Jan 2024 15:21:11 +0000 (UTC) From: Michael Tremer To: development@lists.ipfire.org Subject: [PATCH 2/2] initscripts: Implement storing PIDs in loadproc Date: Thu, 11 Jan 2024 15:21:08 +0000 Message-Id: <20240111152108.4041802-2-michael.tremer@ipfire.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240111152108.4041802-1-michael.tremer@ipfire.org> References: <20240111152108.4041802-1-michael.tremer@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: E2NX5NW4JTPE4XRYZCWTOVWK7VJUMBUD X-Message-ID-Hash: E2NX5NW4JTPE4XRYZCWTOVWK7VJUMBUD X-MailFrom: root@michael.haj.ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Michael Tremer X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Some programs do not write their own PID files any more, but since our initscripts heavily rely on those, this extension allows to store it easily. Signed-off-by: Daniel Weismüller --- src/initscripts/system/functions | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index e4cb30456..5a26aef45 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -446,6 +446,7 @@ loadproc() local pidfile="" local forcestart="" local nicelevel="" + local pid # This will ensure compatibility with previous LFS Bootscripts if [ -n "${PIDFILE}" ]; then @@ -521,12 +522,19 @@ loadproc() ( ${cmd} &>/dev/null ) & + pid="$!" evaluate_retval else ${cmd} + pid="$!" evaluate_retval # This is "Probably" not LSB compliant, but required to be compatible with older bootscripts fi + # Write the pidfile + if [ -n "${pid}" -a -n "${pidfile}" ]; then + echo "${pid}" > "${pidfile}" + fi + return 0 }