From 621405a523013d8607fc061208fdb2af4b503071 Mon Sep 17 00:00:00 2001 From: Dave Russell <39733752+007revad@users.noreply.github.com> Date: Sun, 14 Jul 2024 11:23:19 +1000 Subject: [PATCH] Update syno_hdd_db.sh v3.5.94 - Updated to support newer drive db versions. - Synology added size_gb in host v7 version 8051. - Synology added barebone_installable_v2 in host v7 version 8054. - Bug fix when restoring where memcheck service was only re-enabled on DVA models. - Changed to add leading 0 to short vids reported by drive. - Sets 2 vids in case DSM uses the short one (e.g. 0x05dc=brand and 0x5dc=brand). --- syno_hdd_db.sh | 83 +++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 45 deletions(-) diff --git a/syno_hdd_db.sh b/syno_hdd_db.sh index faa8697..6840261 100644 --- a/syno_hdd_db.sh +++ b/syno_hdd_db.sh @@ -16,31 +16,7 @@ #-------------------------------------------------------------------------------------------------- # https://smarthdd.com/database/ -# CHANGES -# Bug fix for when there's multiple expansion unit models only the last expansion unit was processed. Issue #288 -# Bug fix for when there's multiple M2 adaptor card models only the last M2 card was processed. -# Bug fix for incorrectly matching model name variations as well as the exact model name. -# - e.g. RX1217 matched RX1217, RX1217rp and RX1217sas. -# -# Changed to enable creating storage pools/volumes on NVMe drives in a PCIe M.2 adaptor even if -# PCIe M.2 adaptor not found. This may allow creating NVMe volumes on 3rd party PCIe M.2 adaptors. -# -# Bug fix for -s, --showedits option for multiple of the same drive model -# but with different firmware versions. Issue #276 -# -# Changed disabling memory compatibility for older models. Issue #272 -# -# Hard coded /usr/syno/bin/ for Synology commands (to prevent $PATH issues). -# -# Now enables creating storage pools in Storage Manager for M.2 drives in PCIe adaptor cards. -# - E10M20-T1, M2D20, M2D18, M2D17 and FX2422N -# -# Added new vendor ids for Apacer, aigo, Lexar and Transcend NVMe drives. -# -# Now includes syno_hdd_vendor_ids.txt so users can add their NVMe drive's vendor id. -# - syno_hdd_vendor_ids.txt needs to be in the same folder as syno_hdd_db.sh -# -# Now warns if script is located on an M.2 volume. +# RECENT CHANGES # TODO # Enable SMART Attributes button on Storage Manager @@ -49,7 +25,7 @@ # /var/packages/StorageManager/target/ui/storage_panel.js -scriptver="v3.5.93" +scriptver="v3.5.94" script=Synology_HDD_db repo="007revad/Synology_HDD_db" scriptname=syno_hdd_db @@ -686,12 +662,10 @@ if [[ $restore == "yes" ]]; then # Update .db files from Synology /usr/syno/bin/syno_disk_db_update --update - # Enable SynoMemCheck.service for DVA models - if [[ ${model:0:3} == "dva" ]]; then - memcheck="/usr/lib/systemd/system/SynoMemCheck.service" - if [[ $(/usr/syno/bin/synogetkeyvalue "$memcheck" ExecStart) == "/bin/true" ]]; then - /usr/syno/bin/synosetkeyvalue "$memcheck" ExecStart /usr/syno/bin/syno_mem_check - fi + # Enable SynoMemCheck.service if disabled + memcheck="/usr/lib/systemd/system/SynoMemCheck.service" + if [[ $(/usr/syno/bin/synogetkeyvalue "$memcheck" ExecStart) == "/bin/true" ]]; then + /usr/syno/bin/synosetkeyvalue "$memcheck" ExecStart /usr/syno/bin/syno_mem_check fi if [[ -z $restoreerr ]]; then @@ -772,6 +746,18 @@ set_vendor(){ if ! grep "$vid" "$vidfile2" >/dev/null; then /usr/syno/bin/synosetkeyvalue "$vidfile2" "${vid,,}" "$vendor" fi + + # Add leading 0 to short vid (change 0x5dc to 0x05dc) + if [[ ${#vid} -eq "5" ]]; then + vid="0x0${vid: -3}" + fi + if ! grep "$vid" "$vidfile" >/dev/null; then + /usr/syno/bin/synosetkeyvalue "$vidfile" "${vid,,}" "$vendor" + fi + if ! grep "$vid" "$vidfile2" >/dev/null; then + /usr/syno/bin/synosetkeyvalue "$vidfile2" "${vid,,}" "$vendor" + fi + fi fi } @@ -997,7 +983,7 @@ else echo -e "\nHDD/SSD models found: ${#hdds[@]}" num="0" while [[ $num -lt "${#hdds[@]}" ]]; do - echo "${hdds[num]}" + echo "${hdds[num]} GB" num=$((num +1)) done echo @@ -1020,7 +1006,7 @@ if [[ $m2 != "no" ]]; then echo "M.2 drive models found: ${#nvmes[@]}" num="0" while [[ $num -lt "${#nvmes[@]}" ]]; do - echo "${nvmes[num]}" + echo "${nvmes[num]} GB" num=$((num +1)) done echo @@ -1259,16 +1245,16 @@ updatedb(){ if grep "$hdmodel"'":{"'"$fwrev" "$2" >/dev/null; then echo -e "${Yellow}$hdmodel${Off} already exists in ${Cyan}$(basename -- "$2")${Off}" >&2 else - common_string="$common_string"\"size_gb\":$size_gb, + common_string=\"size_gb\":$size_gb, common_string="$common_string"\"compatibility_interval\":[{ common_string="$common_string"\"compatibility\":\"support\", common_string="$common_string"\"not_yet_rolling_status\":\"support\", common_string="$common_string"\"fw_dsm_update_status_notify\":false, common_string="$common_string"\"barebone_installable\":true, - common_string="$default"\"barebone_installable_v2\":\"auto\", + common_string="$common_string"\"barebone_installable_v2\":\"auto\", common_string="$common_string"\"smart_test_ignore\":false, common_string="$common_string"\"smart_attr_ignore\":false - + fwstrng=\"$fwrev\":{ fwstrng="$fwstrng$common_string" fwstrng="$fwstrng"}]}, @@ -2023,16 +2009,23 @@ fi #------------------------------------------------------------------------------ # Finished +show_changes(){ + # $1 is drive_model,firmware_version,size_gb + drive_model="$(printf "%s" "$1" | cut -d"," -f 1)" + echo -e "\n$drive_model:" + jq -r --arg drive_model "$drive_model" '.disk_compatbility_info[$drive_model]' "${db1list[0]}" +} + # Show the changes if [[ ${showedits,,} == "yes" ]]; then - # Sort array to remove duplicates - IFS=$'\n' - drives_sorted=($(sort -u <<<"${drivelist[*]}")) - unset IFS - # Show the changes for drive model - for drive_model in "${drives_sorted[@]}"; do - echo -e "\n$drive_model:" - jq -r --arg drive_model "$drive_model" '.disk_compatbility_info[$drive_model]' "${db1list[0]}" + # HDDs/SSDs + for d in "${hdds[@]}"; do + show_changes "$d" + done + + # NVMe drives + for d in "${nvmes[@]}"; do + show_changes "$d" done fi