Browse Source

Update syno_hdd_db.sh

pull/14/head
007revad 3 years ago
committed by GitHub
parent
commit
7c37061e4d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 43
      syno_hdd_db.sh

43
syno_hdd_db.sh

@ -84,6 +84,7 @@ scriptver="v1.1.15"
script=Synology_HDD_db script=Synology_HDD_db
repo="007revad/Synology_HDD_db" repo="007revad/Synology_HDD_db"
#echo -e "bash version: $(bash --version | head -1 | cut -d' ' -f4)\n" # debug
# Shell Colors # Shell Colors
#Black='\e[0;30m' #Black='\e[0;30m'
@ -297,7 +298,8 @@ getm2info() {
} }
getcardmodel() { getcardmodel() {
# Get M.2 card model # Get M.2 card model (if M.2 drives found)
if [[ ${#nvmelist[@]} -gt "0" ]]; then
cardmodel=$(synodisk --m2-card-model-get "$1") cardmodel=$(synodisk --m2-card-model-get "$1")
if [[ $cardmodel =~ M2D[0-9][0-9] ]]; then if [[ $cardmodel =~ M2D[0-9][0-9] ]]; then
# M2 adaptor card # M2 adaptor card
@ -308,6 +310,7 @@ getcardmodel() {
m2carddblist+=("${model}_${cardmodel,,}${version}.db") # M.2 card's db file m2carddblist+=("${model}_${cardmodel,,}${version}.db") # M.2 card's db file
m2cardlist+=("$cardmodel") # M.2 card m2cardlist+=("$cardmodel") # M.2 card
fi fi
fi
} }
@ -348,21 +351,12 @@ for d in /sys/block/*; do
done done
sortarray(){ # Sort hdlist array into new hdds array to remove duplicates
# Sort $1 array into new $2 array to remove duplicates if [[ ${#hdlist[@]} -gt "0" ]]; then
local -n inarray=$1
outarray=()
if [[ ${#inarray[@]} -gt "0" ]]; then
while IFS= read -r -d '' x; do while IFS= read -r -d '' x; do
outarray+=("$x") hdds+=("$x")
done < <(printf "%s\0" "${inarray[@]}" | sort -uz) done < <(printf "%s\0" "${hdlist[@]}" | sort -uz)
fi fi
}
# Sort hdlist array into new hdds array to remove duplicates
sortarray "hdlist"
hdds=${outarray[*]}
# Check hdds array isn't empty # Check hdds array isn't empty
if [[ ${#hdds[@]} -eq "0" ]]; then if [[ ${#hdds[@]} -eq "0" ]]; then
@ -379,8 +373,11 @@ fi
# Sort nvmelist array into new nvmes array to remove duplicates # Sort nvmelist array into new nvmes array to remove duplicates
sortarray "nvmelist" if [[ ${#nvmelist[@]} -gt "0" ]]; then
nvmes=${outarray[*]} while IFS= read -r -d '' x; do
nvmes+=("$x")
done < <(printf "%s\0" "${nvmelist[@]}" | sort -uz)
fi
# Check nvmes array isn't empty # Check nvmes array isn't empty
if [[ ${#nvmes[@]} -eq "0" ]]; then if [[ ${#nvmes[@]} -eq "0" ]]; then
@ -400,13 +397,19 @@ fi
# M.2 card db files # M.2 card db files
# Sort m2carddblist array into new m2carddbs array to remove duplicates # Sort m2carddblist array into new m2carddbs array to remove duplicates
sortarray "m2carddblist" if [[ ${#m2carddblist[@]} -gt "0" ]]; then
m2carddbs=${outarray[*]} while IFS= read -r -d '' x; do
m2carddbs+=("$x")
done < <(printf "%s\0" "${m2carddblist[@]}" | sort -uz)
fi
# M.2 cards # M.2 cards
# Sort m2cardlist array into new m2cards array to remove duplicates # Sort m2cardlist array into new m2cards array to remove duplicates
sortarray "m2cardlist" if [[ ${#m2cardlist[@]} -gt "0" ]]; then
m2cards=${outarray[*]} while IFS= read -r -d '' x; do
m2cards+=("$x")
done < <(printf "%s\0" "${m2cardlist[@]}" | sort -uz)
fi
# Check m2cards array isn't empty # Check m2cards array isn't empty
if [[ ${#m2cards[@]} -gt "0" ]]; then if [[ ${#m2cards[@]} -gt "0" ]]; then

Loading…
Cancel
Save