Browse Source

Update syno_hdd_db.sh

- Now looks for and edits both v7 and non-v7 db files to solve issue #11 for RS '21 models running DSM 6.2.4.
pull/63/head
Dave Russell 3 years ago
committed by GitHub
parent
commit
bdb682b488
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 96
      syno_hdd_db.sh

96
syno_hdd_db.sh

@ -30,6 +30,9 @@
# It's also parsed and checked and probably in some cases it could be more critical to patch that one instead. # It's also parsed and checked and probably in some cases it could be more critical to patch that one instead.
# DONE # DONE
# Now looks for and edits both v7 and non-v7 db files to solve issue #11 for RS '21 models running DSM 6.2.4.
#
#
# Improved shell output when editing max memory setting. # Improved shell output when editing max memory setting.
# #
# Changed method of checking if drive is a USB drive to prevent ignoring internal drives on RS models. # Changed method of checking if drive is a USB drive to prevent ignoring internal drives on RS models.
@ -121,7 +124,7 @@
# Optionally disable "support_disk_compatibility". # Optionally disable "support_disk_compatibility".
scriptver="v2.1.38" scriptver="v2.2.39"
script=Synology_HDD_db script=Synology_HDD_db
repo="007revad/Synology_HDD_db" repo="007revad/Synology_HDD_db"
@ -371,14 +374,14 @@ if ! printf "%s\n%s\n" "$tag" "$scriptver" |
# Delete downloaded .tar.gz file # Delete downloaded .tar.gz file
if ! rm "/tmp/$script-$shorttag.tar.gz"; then if ! rm "/tmp/$script-$shorttag.tar.gz"; then
delerr=1 #delerr=1
echo -e "${Error}ERROR ${Off} Failed to delete"\ echo -e "${Error}ERROR ${Off} Failed to delete"\
"downloaded /tmp/$script-$shorttag.tar.gz!" "downloaded /tmp/$script-$shorttag.tar.gz!"
fi fi
# Delete extracted tmp files # Delete extracted tmp files
if ! rm -r "/tmp/$script-$shorttag"; then if ! rm -r "/tmp/$script-$shorttag"; then
delerr=1 #delerr=1
echo -e "${Error}ERROR ${Off} Failed to delete"\ echo -e "${Error}ERROR ${Off} Failed to delete"\
"downloaded /tmp/$script-$shorttag!" "downloaded /tmp/$script-$shorttag!"
fi fi
@ -437,7 +440,7 @@ getdriveinfo() {
# $1 is /sys/block/sata1 etc # $1 is /sys/block/sata1 etc
# Skip USB drives # Skip USB drives
usb=$(grep $(basename -- "$1") /proc/mounts | grep usb | cut -d" " -f1-2) usb=$(grep "$(basename -- "$1")" /proc/mounts | grep usb | cut -d" " -f1-2)
if [[ ! $usb ]]; then if [[ ! $usb ]]; then
# Get drive model and firmware version # Get drive model and firmware version
@ -479,11 +482,21 @@ getcardmodel() {
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
if [[ -f "${model}_${cardmodel,,}${version}.db" ]]; then
m2carddblist+=("${model}_${cardmodel,,}${version}.db") # M.2 card's db file m2carddblist+=("${model}_${cardmodel,,}${version}.db") # M.2 card's db file
fi
if [[ -f "${model}_${cardmodel,,}.db" ]]; then
m2carddblist+=("${model}_${cardmodel,,}.db") # M.2 card's db file
fi
m2cardlist+=("$cardmodel") # M.2 card m2cardlist+=("$cardmodel") # M.2 card
elif [[ $cardmodel =~ E[0-9][0-9]+M.+ ]]; then elif [[ $cardmodel =~ E[0-9][0-9]+M.+ ]]; then
# Ethernet + M2 adaptor card # Ethernet + M2 adaptor card
if [[ -f "${model}_${cardmodel,,}${version}.db" ]]; then
m2carddblist+=("${model}_${cardmodel,,}${version}.db") # M.2 card's db file m2carddblist+=("${model}_${cardmodel,,}${version}.db") # M.2 card's db file
fi
if [[ -f "${model}_${cardmodel,,}.db" ]]; then
m2carddblist+=("${model}_${cardmodel,,}.db") # M.2 card's db file
fi
m2cardlist+=("$cardmodel") # M.2 card m2cardlist+=("$cardmodel") # M.2 card
fi fi
fi fi
@ -513,7 +526,7 @@ for d in /sys/block/*; do
getcardmodel "/dev/$(basename -- "${d}")" getcardmodel "/dev/$(basename -- "${d}")"
# Enable creating M.2 storage pool and volume in Storage Manager # Enable creating M.2 storage pool and volume in Storage Manager
echo 1 > /run/synostorage/disks/$(basename -- "$d")/m2_pool_support echo 1 > /run/synostorage/disks/"$(basename -- "$d")"/m2_pool_support
fi fi
fi fi
;; ;;
@ -526,7 +539,7 @@ for d in /sys/block/*; do
getcardmodel "/dev/$(basename -- "${d}")" getcardmodel "/dev/$(basename -- "${d}")"
# Enable creating M.2 storage pool and volume in Storage Manager # Enable creating M.2 storage pool and volume in Storage Manager
echo 1 > /run/synostorage/disks/$(basename -- "$d")/m2_pool_support echo 1 > /run/synostorage/disks/"$(basename -- "$d")"/m2_pool_support
fi fi
fi fi
;; ;;
@ -644,16 +657,19 @@ fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Check databases and add our drives if needed # Check databases and add our drives if needed
db1="/var/lib/disk-compatibility/${model}_host${version}.db"
db2="/var/lib/disk-compatibility/${model}_host${version}.db.new"
dbpath="/var/lib/disk-compatibility/" dbpath="/var/lib/disk-compatibility/"
db1list=("$(find "$dbpath" -maxdepth 1 -name "*_host*.db")")
db2list=("$(find "$dbpath" -maxdepth 1 -name "*_host*.db.new")")
synoinfo="/etc.defaults/synoinfo.conf" synoinfo="/etc.defaults/synoinfo.conf"
if [[ ! -f "$db1" ]]; then echo -e "${Error}ERROR 3${Off} $db1 not found!" && exit 3; fi #if [[ ! -f "$db1" ]]; then echo -e "${Error}ERROR 3${Off} $db1 not found!" && exit 3; fi
#if [[ ! -f "$db2" ]]; then echo -e "${Error}ERROR 4${Off} $db2 not found!" && exit 4; fi if [[ ${#db1list[@]} -eq "0" ]]; then
# new installs don't have a .db.new file echo -e "${Error}ERROR 4${Off} Host db file not found!" && exit 4
fi
##if [[ ! -f "$db2" ]]; then echo -e "${Error}ERROR 4${Off} $db2 not found!" && exit 4; fi
## new installs don't have a .db.new file
getdbtype(){ getdbtype(){
@ -689,7 +705,10 @@ backupdb() {
# Backup host database file if needed # Backup host database file if needed
backupdb "$db1" || exit 5 #backupdb "$db1" || exit 5
for i in "${!db2list[@]}"; do
backupdb "${db2list[i]}" || exit 5
done
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -697,9 +716,11 @@ backupdb "$db1" || exit 5
editcount(){ editcount(){
# Count drives added to host db files # Count drives added to host db files
if [[ $1 == "$db1" ]]; then #if [[ $1 == "$db1" ]]; then
if [[ $1 =~ .*\.db$ ]]; then
db1Edits=$((db1Edits +1)) db1Edits=$((db1Edits +1))
elif [[ $1 == "$db2" ]]; then #elif [[ $1 == "$db2" ]]; then
elif [[ $1 =~ .*\.db.new ]]; then
db2Edits=$((db2Edits +1)) db2Edits=$((db2Edits +1))
fi fi
} }
@ -797,11 +818,12 @@ updatedb() {
echo -e "Added ${Yellow}$hdmodel${Off} to ${Cyan}$(basename -- "$2")${Off}" echo -e "Added ${Yellow}$hdmodel${Off} to ${Cyan}$(basename -- "$2")${Off}"
# Count drives added to host db files # Count drives added to host db files
if [[ $2 == "$db1" ]]; then #if [[ $2 == "$db1" ]]; then
db1Edits=$((db1Edits +1)) # db1Edits=$((db1Edits +1))
elif [[ $2 == "$db2" ]]; then #elif [[ $2 == "$db2" ]]; then
db2Edits=$((db2Edits +1)) # db2Edits=$((db2Edits +1))
fi #fi
#editcount "$2"
else else
echo -e "\n${Error}ERROR 8${Off} Failed to update $(basename -- "$2")${Off}" >&2 echo -e "\n${Error}ERROR 8${Off} Failed to update $(basename -- "$2")${Off}" >&2
@ -814,10 +836,16 @@ updatedb() {
# HDDs and SATA SSDs # HDDs and SATA SSDs
num="0" num="0"
while [[ $num -lt "${#hdds[@]}" ]]; do while [[ $num -lt "${#hdds[@]}" ]]; do
updatedb "${hdds[$num]}" "$db1" #updatedb "${hdds[$num]}" "$db1"
if [[ -f "$db2" ]]; then #if [[ -f "$db2" ]]; then
updatedb "${hdds[$num]}" "$db2" # updatedb "${hdds[$num]}" "$db2"
fi #fi
for i in "${!db1list[@]}"; do
updatedb "${hdds[$num]}" "${db1list[i]}"
done
for i in "${!db2list[@]}"; do
updatedb "${hdds[$num]}" "${db2list[i]}"
done
#------------------------------------------------ #------------------------------------------------
# Expansion Units # Expansion Units
@ -840,10 +868,16 @@ done
# M.2 NVMe/SATA drives # M.2 NVMe/SATA drives
num="0" num="0"
while [[ $num -lt "${#nvmes[@]}" ]]; do while [[ $num -lt "${#nvmes[@]}" ]]; do
updatedb "${nvmes[$num]}" "$db1" #updatedb "${hdds[$num]}" "$db1"
if [[ -f "$db2" ]]; then #if [[ -f "$db2" ]]; then
updatedb "${nvmes[$num]}" "$db2" # updatedb "${hdds[$num]}" "$db2"
fi #fi
for i in "${!db1list[@]}"; do
updatedb "${nvmes[$num]}" "$i"
done
for i in "${!db2list[@]}"; do
updatedb "${nvmes[$num]}" "$i"
done
#------------------------------------------------ #------------------------------------------------
# M.2 adaptor cards # M.2 adaptor cards
@ -1039,7 +1073,8 @@ fi
# Show the changes # Show the changes
if [[ ${showedits,,} == "yes" ]]; then if [[ ${showedits,,} == "yes" ]]; then
getdbtype "$db1" for i in "${!db1list[@]}"; do
getdbtype "$i"
if [[ $dbtype -gt "6" ]]; then if [[ $dbtype -gt "6" ]]; then
# Show 11 lines after hdmodel line # Show 11 lines after hdmodel line
lines=11 lines=11
@ -1054,7 +1089,7 @@ if [[ ${showedits,,} == "yes" ]]; then
while [[ $num -lt "${#hdds[@]}" ]]; do while [[ $num -lt "${#hdds[@]}" ]]; do
hdmodel=$(printf "%s" "${hdds[$num]}" | cut -d"," -f 1) hdmodel=$(printf "%s" "${hdds[$num]}" | cut -d"," -f 1)
echo echo
jq . "$db1" | grep -A "$lines" "$hdmodel" jq . "$i" | grep -A "$lines" "$hdmodel"
num=$((num +1)) num=$((num +1))
done done
fi fi
@ -1065,10 +1100,11 @@ if [[ ${showedits,,} == "yes" ]]; then
while [[ $num -lt "${#nvmes[@]}" ]]; do while [[ $num -lt "${#nvmes[@]}" ]]; do
nvmemodel=$(printf "%s" "${nvmes[$num]}" | cut -d"," -f 1) nvmemodel=$(printf "%s" "${nvmes[$num]}" | cut -d"," -f 1)
echo echo
jq . "$db1" | grep -A "$lines" "$nvmemodel" jq . "$i" | grep -A "$lines" "$nvmemodel"
num=$((num +1)) num=$((num +1))
done done
fi fi
done
fi fi

Loading…
Cancel
Save