From patchwork Fri Jan 10 15:06:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Weismueller X-Patchwork-Id: 2690 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 (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 47vRBm52ZTz3xXp for ; Fri, 10 Jan 2020 15:06:08 +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 (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 47vRBl2vrbz2L2; Fri, 10 Jan 2020 15:06:07 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 47vRBk6G0Hz2yRV; Fri, 10 Jan 2020 15:06:06 +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 (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 47vRBj6Rknz2xq0 for ; Fri, 10 Jan 2020 15:06:05 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 47vRBh5VkLz2L2; Fri, 10 Jan 2020 15:06:04 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=201909ed25519; t=1578668764; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1Q0UPs3G1cMcq3VCTVtwsm2Uhlewny6pbRDdLHp358c=; b=c3dpGldCeitc8DwqTQLIgyd12xx3uV8y7w4XcoL9/BZA7LB3b0b9Up4kvkp6AJZhqCJ+Z2 1KF6v0WcBMa31GCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201909rsa; t=1578668764; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=1Q0UPs3G1cMcq3VCTVtwsm2Uhlewny6pbRDdLHp358c=; b=OUHCSxk1iJUfcCgsjrSSNd4nZoBmnSO++64clIDwNx4MYtR3YQV9NSd3AVXKpW1+NZPr6e +zvPFzvHIuhFYMLlCn/Qxedl4Sj9AbE8ABfngGfYrO8rXVxOnWRPv1UOhtbBSdOiK3t6u7 rheCT2CRn5IzTjZF6p9K1fUpkro6p4BMqYtEcqbYiHYGqjVI0IJCmRDzsjIu4BsDWr/IsM TYyHfC4vE3DWUQyj3rqkTiJCXHmn/6laf0y7iTo7nZLDFDXsuyENLgSHZ/onWICyweLOg+ eGmeyx/0wGTxUfXjgPfoBytnXFIu+/BCzmgC4DrD03YQufoAtGf5guTAR2gZ+A== From: =?utf-8?q?Daniel_Weism=C3=BCller?= To: development@lists.ipfire.org Subject: [PATCH] filesystem-cleanup: Add parameter to show changes Date: Fri, 10 Jan 2020 16:06:00 +0100 Message-Id: <20200110150600.24259-1-daniel.weismueller@ipfire.org> MIME-Version: 1.0 Authentication-Results: mail01.ipfire.org; auth=pass smtp.auth=dweismueller smtp.mailfrom=daniel.weismueller@ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Daniel_Weism=C3=BCller?= Errors-To: development-bounces@lists.ipfire.org Sender: "Development" From: Daniel Weismüller Use --dry-run to only show files that would be deleted, but do not actually delete them. Signed-off-by: Daniel Weismüller --- src/scripts/filesystem-cleanup | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/scripts/filesystem-cleanup b/src/scripts/filesystem-cleanup index d4cdfe8d3..7e7accc7a 100644 --- a/src/scripts/filesystem-cleanup +++ b/src/scripts/filesystem-cleanup @@ -27,6 +27,22 @@ PATHS=( ) main() { + local dry_run="false" + + while [ $# -gt 0 ]; do + case "${1}" in + --dry-run) + dry_run="true" + ;; + + *) + echo "${0}: Invalid argument: ${1}" >&2 + return 2 + ;; + esac + shift + done + # Update the runtime linker cache (this may fix any broken symlinks) ldconfig @@ -65,7 +81,12 @@ main() { ;; *) - unlink "${file}" + echo "Removing ${file}..." + + # Actually remove the file (maybe) + if [ "${dry_run}" = "false" ]; then + unlink "${file}" + fi ;; esac done