Browse Source

Merge pull request #398 from dotysan/rootfs

De-spaghettifi shell code
pull/401/head
Dave Russell 1 year ago
committed by GitHub
parent
commit
5d04a24ee9
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 23
      syno_hdd_db.sh

23
syno_hdd_db.sh

@ -362,11 +362,24 @@ echo "Running from: ${scriptpath}/$scriptfile"
# Warn if script located on M.2 drive # Warn if script located on M.2 drive
scriptvol=$(echo "$scriptpath" | cut -d"/" -f2) get_script_vol() {
vg=$(lvdisplay | grep /volume_"${scriptvol#volume}" | cut -d"/" -f3) local script_root vol_num vg_name
md=$(pvdisplay | grep -B 1 -E '[ ]'"$vg" | grep /dev/ | cut -d"/" -f3) script_root="${scriptpath#/*}"
# shellcheck disable=SC2002 # Don't warn about "Useless cat" script_root="${script_root%%/*}"
if cat /proc/mdstat | grep "$md" | grep -q nvme; then if [[ $script_root =~ ^volume ]]
then
vol_num="${script_root:6}"
vg_name=$(lvs --noheadings --select=lv_name="volume_$vol_num" --options=vg_name)
vg_name="${vg_name// }"
vol_name=$(pvs --noheadings --select=vg_name="$vg_name" --options=pv_name)
vol_name="${vol_name// }"
else
vol_name=$(df --output=source "/$script_root" |sed 1d)
fi
}
get_script_vol # sets $vol_name to /dev/whatever
if grep -qE "^${vol_name#/dev/} .+ nvme" /proc/mdstat
then
echo -e "\n${Yellow}WARNING${Off} Don't store this script on an NVMe volume!" echo -e "\n${Yellow}WARNING${Off} Don't store this script on an NVMe volume!"
fi fi

Loading…
Cancel
Save