mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-06-28 04:06:54 +00:00
Update scripts for disk
This commit is contained in:
parent
84912fcaac
commit
aed76879b1
@ -176,14 +176,18 @@ while read -r DISK; do
|
|||||||
REAL_PATH=$(readlink -f "$DISK")
|
REAL_PATH=$(readlink -f "$DISK")
|
||||||
CONFIG_DATA=$(cat /etc/pve/qemu-server/*.conf /etc/pve/lxc/*.conf 2>/dev/null)
|
CONFIG_DATA=$(cat /etc/pve/qemu-server/*.conf /etc/pve/lxc/*.conf 2>/dev/null)
|
||||||
|
|
||||||
|
if grep -Fq "$REAL_PATH" <<< "$CONFIG_DATA"; then
|
||||||
|
USED_BY="⚠ $(translate "In use")"
|
||||||
|
else
|
||||||
for SYMLINK in /dev/disk/by-id/*; do
|
for SYMLINK in /dev/disk/by-id/*; do
|
||||||
if [[ "$(readlink -f "$SYMLINK")" == "$REAL_PATH" ]]; then
|
if [[ "$(readlink -f "$SYMLINK")" == "$REAL_PATH" ]]; then
|
||||||
if grep -Fq "$SYMLINK" <<< "$CONFIG_DATA"; then
|
if grep -Fq "$SYMLINK" <<< "$CONFIG_DATA"; then
|
||||||
USED_BY="$(translate "in use ct or vm")"
|
USED_BY="⚠ $(translate "In use")"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -215,7 +219,7 @@ while read -r DISK; do
|
|||||||
[[ "$IS_LVM" == true ]] && LABEL+=" ⚠ LVM"
|
[[ "$IS_LVM" == true ]] && LABEL+=" ⚠ LVM"
|
||||||
[[ "$IS_ZFS" == true ]] && LABEL+=" ⚠ ZFS"
|
[[ "$IS_ZFS" == true ]] && LABEL+=" ⚠ ZFS"
|
||||||
|
|
||||||
DESCRIPTION=$(printf "%-24s %10s%s" "$MODEL" "$SIZE" "$LABEL")
|
DESCRIPTION=$(printf "%-30s %10s%s" "$MODEL" "$SIZE" "$LABEL")
|
||||||
FREE_DISKS+=("$DISK" "$DESCRIPTION" "OFF")
|
FREE_DISKS+=("$DISK" "$DESCRIPTION" "OFF")
|
||||||
fi
|
fi
|
||||||
done < <(lsblk -dn -e 7,11 -o PATH)
|
done < <(lsblk -dn -e 7,11 -o PATH)
|
||||||
@ -311,7 +315,7 @@ for DISK in $SELECTED; do
|
|||||||
done < <(pct list | awk 'NR>1 {print $1, $2}')
|
done < <(pct list | awk 'NR>1 {print $1, $2}')
|
||||||
|
|
||||||
if [ -n "$RUNNING_VMS" ] || [ -n "$RUNNING_CTS" ]; then
|
if [ -n "$RUNNING_VMS" ] || [ -n "$RUNNING_CTS" ]; then
|
||||||
ERROR_MESSAGES+="$(translate "The disk") $DISK_INFO $(translate "is in use by the following running VM(s) or CT(s):")\\n$RUNNING_VMS$RUNNING_CTS\\n\\n"
|
ERROR_MESSAGES+="$(translate "The disk") $DISK_INFO $(translate "is currently in use by the following running VM(s) or CT(s):")\\n$RUNNING_VMS$RUNNING_CTS\\n\\n$(translate "You cannot add this disk while the VM or CT is running.")\\n$(translate "Please shut it down first and run this script again to add the disk.")\\n\\n"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -222,14 +222,18 @@ while read -r DISK; do
|
|||||||
REAL_PATH=$(readlink -f "$DISK")
|
REAL_PATH=$(readlink -f "$DISK")
|
||||||
CONFIG_DATA=$(cat /etc/pve/qemu-server/*.conf /etc/pve/lxc/*.conf 2>/dev/null)
|
CONFIG_DATA=$(cat /etc/pve/qemu-server/*.conf /etc/pve/lxc/*.conf 2>/dev/null)
|
||||||
|
|
||||||
|
if grep -Fq "$REAL_PATH" <<< "$CONFIG_DATA"; then
|
||||||
|
USED_BY="⚠ $(translate "In use")"
|
||||||
|
else
|
||||||
for SYMLINK in /dev/disk/by-id/*; do
|
for SYMLINK in /dev/disk/by-id/*; do
|
||||||
if [[ "$(readlink -f "$SYMLINK")" == "$REAL_PATH" ]]; then
|
if [[ "$(readlink -f "$SYMLINK")" == "$REAL_PATH" ]]; then
|
||||||
if grep -Fq "$SYMLINK" <<< "$CONFIG_DATA"; then
|
if grep -Fq "$SYMLINK" <<< "$CONFIG_DATA"; then
|
||||||
USED_BY="$(translate "in use ct or vm")"
|
USED_BY="⚠ $(translate "In use")"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -257,7 +261,7 @@ while read -r DISK; do
|
|||||||
[[ "$IS_LVM" == true ]] && LABEL+=" ⚠ LVM"
|
[[ "$IS_LVM" == true ]] && LABEL+=" ⚠ LVM"
|
||||||
[[ "$IS_ZFS" == true ]] && LABEL+=" ⚠ ZFS"
|
[[ "$IS_ZFS" == true ]] && LABEL+=" ⚠ ZFS"
|
||||||
|
|
||||||
DESCRIPTION=$(printf "%-24s %10s%s" "$MODEL" "$SIZE" "$LABEL")
|
DESCRIPTION=$(printf "%-30s %10s%s" "$MODEL" "$SIZE" "$LABEL")
|
||||||
FREE_DISKS+=("$DISK" "$DESCRIPTION" "OFF")
|
FREE_DISKS+=("$DISK" "$DESCRIPTION" "OFF")
|
||||||
fi
|
fi
|
||||||
done < <(lsblk -dn -e 7,11 -o PATH)
|
done < <(lsblk -dn -e 7,11 -o PATH)
|
||||||
@ -399,7 +403,7 @@ for DISK in $SELECTED; do
|
|||||||
if [[ "$CURRENT_FS" == "ext4" || "$CURRENT_FS" == "xfs" || "$CURRENT_FS" == "btrfs" ]]; then
|
if [[ "$CURRENT_FS" == "ext4" || "$CURRENT_FS" == "xfs" || "$CURRENT_FS" == "btrfs" ]]; then
|
||||||
SKIP_FORMAT=true
|
SKIP_FORMAT=true
|
||||||
PARTITION="$DISK"
|
PARTITION="$DISK"
|
||||||
msg_ok "$(translate "Detected filesystem") $CURRENT_FS $(translate "directly on disk") $DISK. $(translate "Proceeding without partition.")"
|
msg_ok "$(translate "Detected filesystem") $CURRENT_FS $(translate "directly on disk") $DISK.)"
|
||||||
else
|
else
|
||||||
|
|
||||||
whiptail --title "$(translate "No Valid Partitions")" --yesno "$(translate "The disk has no partitions and no valid filesystem. Do you want to create a new partition and format it?")" 10 70
|
whiptail --title "$(translate "No Valid Partitions")" --yesno "$(translate "The disk has no partitions and no valid filesystem. Do you want to create a new partition and format it?")" 10 70
|
||||||
|
@ -546,6 +546,23 @@ function select_passthrough_disk() {
|
|||||||
IS_MOUNTED=true
|
IS_MOUNTED=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
USED_BY=""
|
||||||
|
REAL_PATH=$(readlink -f "$DISK")
|
||||||
|
CONFIG_DATA=$(cat /etc/pve/qemu-server/*.conf /etc/pve/lxc/*.conf 2>/dev/null)
|
||||||
|
|
||||||
|
if grep -Fq "$REAL_PATH" <<< "$CONFIG_DATA"; then
|
||||||
|
USED_BY="⚠ $(translate "In use")"
|
||||||
|
else
|
||||||
|
for SYMLINK in /dev/disk/by-id/*; do
|
||||||
|
if [[ "$(readlink -f "$SYMLINK")" == "$REAL_PATH" ]]; then
|
||||||
|
if grep -Fq "$SYMLINK" <<< "$CONFIG_DATA"; then
|
||||||
|
USED_BY="⚠ $(translate "In use")"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
if $IS_RAID && grep -q "$DISK" <<< "$(cat /proc/mdstat)" && grep -q "active raid" /proc/mdstat; then
|
if $IS_RAID && grep -q "$DISK" <<< "$(cat /proc/mdstat)" && grep -q "active raid" /proc/mdstat; then
|
||||||
SHOW_DISK=false
|
SHOW_DISK=false
|
||||||
fi
|
fi
|
||||||
@ -555,7 +572,8 @@ function select_passthrough_disk() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if $SHOW_DISK; then
|
if $SHOW_DISK; then
|
||||||
[[ "$IS_RAID" == true ]] && LABEL+=" ⚠ with partitions"
|
[[ -n "$USED_BY" ]] && LABEL+=" [$USED_BY]"
|
||||||
|
[[ "$IS_RAID" == true ]] && LABEL+=" ⚠ RAID"
|
||||||
[[ "$IS_LVM" == true ]] && LABEL+=" ⚠ LVM"
|
[[ "$IS_LVM" == true ]] && LABEL+=" ⚠ LVM"
|
||||||
[[ "$IS_ZFS" == true ]] && LABEL+=" ⚠ ZFS"
|
[[ "$IS_ZFS" == true ]] && LABEL+=" ⚠ ZFS"
|
||||||
DESCRIPTION=$(printf "%-30s %10s%s" "$MODEL" "$SIZE" "$LABEL")
|
DESCRIPTION=$(printf "%-30s %10s%s" "$MODEL" "$SIZE" "$LABEL")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user