From 667fc0768ab628c0d443e0597ce8f36534ab328b Mon Sep 17 00:00:00 2001 From: xf0r3m Date: Sun, 6 Jul 2025 17:55:25 +0200 Subject: [PATCH] =?utf8?q?Dodanie=20dw=C3=B3ch=20funkcji=20do=20pliku=20to?= =?utf8?q?ols/bin/library.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- tools/bin/library.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tools/bin/library.sh b/tools/bin/library.sh index 2e50210..01d711b 100755 --- a/tools/bin/library.sh +++ b/tools/bin/library.sh @@ -57,3 +57,22 @@ function ascii_colors() { echo -e "${ENDCOLOR}"; } + +function deactivate_lvm_w_swap() { + if $(sudo blkid | grep "$1" | grep -q 'LVM2_member'); then + vgName=$(sudo pvs | grep "$1" | awk '{printf $2}' | sed 's/-/--/g'); + swapFile=$(cat /proc/swaps | sed -n 2p | awk '{printf $1}'); + if [ "$swapFile" ]; then + if $(ls -l /dev/mapper | grep "$(basename $swapFile)" | grep -q "$vgName"); then + sudo swapoff $swapFile; + fi + fi + sudo vgchange -a n; + fi +} + +function deactivate_lvm() { + if $(sudo blkid | grep "$1" | grep -q 'LVM2_member'); then + sudo vgchange -a n; + fi +} -- 2.39.5