diff --git a/syno_hdd_db.sh b/syno_hdd_db.sh index 263ea4a..aff7000 100644 --- a/syno_hdd_db.sh +++ b/syno_hdd_db.sh @@ -4,12 +4,6 @@ # Github: https://github.com/007revad/Synology_HDD_db # Script verified at https://www.shellcheck.net/ # -# Easiest solution: -# Edit /etc.defaults/synoinfo.conf and change support_disk_compatibility="yes" to "no" and reboot. -# Then all drives can be used without error messages. -# -# But lets do this the proper way by adding our drive models to the appropriate .db file. -# # To run in task manager as root (manually or scheduled): # /volume1/scripts/syno_hdd_db.sh # replace /volume1/scripts/ with path to script # @@ -21,212 +15,22 @@ # sudo -i /volume1/scripts/syno_hdd_db.sh -force -showedits #-------------------------------------------------------------------------------------------------- -# TODO -# Maybe also edit the other disk compatibility db in synoboot, used during boot time. -# It's also parsed and checked and probably in some cases it could be more critical to patch that one instead. -# -# Solve issue of --restore option restoring files that were backed up with older DSM version. -# Change how synoinfo.conf is backed up and restored to prevent issue #73 - -# DONE +# CHANGES # Updated so E10M20-T1, M2D20 and M2D18 now work in models that use device tree, -# and are using DSM 7.2 Update 2, Update 3, 7.2.1 and 7.2.1 Update 1. -# -# Fixed bug where memory was shown in MB but with GB unit. -# -# -# Bug fix for script not updating itself if .sh file had been renamed. -# -# Bug fix for missing executable permissions if .sh file had been renamed. -# -# Bug fix to prevent update loop if script's .tar.gz file already exists in /tmp. -# -# Bug fix to prevent update failing if script's temp folder already exists in /tmp. -# -# Now only copies CHANGES.txt to script location if script is located on a volume, -# to prevent putting CHANGES.txt on system partition (/usr/bin, /usr/sbin, /root etc.) -# -# Added -e --email option to disable coloured output to make task scheduler emails easier to read. -# -# -# Added support to disable unsupported memory warnings on DVA models. -# -# Fixed bug where newly connected expansion units weren't found until up to 24 hours later. #124 -# -# Added enabling E10M20-T1, M2D20 and M2D18 for DS1821+, DS1621+ and DS1520+. -# Added enabling M2D18 for RS822RP+, RS822+, RS1221RP+ and RS1221+ with older DSM version. -# -# Fixed enabling E10M20-T1, M2D20 and M2D18 cards in models that don't officially support them. -# -# Enable NVMe drive use for models that do not have NVMe drives enabled. -# -# Fixed bugs where the calculated amount of installed memory could be incorrect: -# - If last memory socket was empty an invalid unit of bytes could be used. Issue #106 -# - When dmidecode returned MB for one ram module and GB for another ram module. Issue #107 -# -# Fixed bug displaying the max memory setting if total installed memory was less than the max memory. Issue #107 -# -# Fixed bug where sata1 drive firmware version was wrong if there was a sata10 drive. -# -# Minor bug fix for checking amount of installed memory. -# -# Now enables any installed Synology M.2 PCIe cards for models that don't officially support them. -# -# Added -i, --immutable option to enable immutable snapshots on models older than '20 series running DSM 7.2. -# -# Changed help to show that -r, --ram also sets max memory to the amount of installed memory. -# -# Changed the "No M.2 cards found" to "No M.2 PCIe cards found" to make it clearer. -# -# Added "You may need to reboot" message when NVMe drives were detected. -# -# Fixed HDD/SSD firmware versions always being 4 characters long (for DSM 7.2 and 6.2.4 Update 7). -# -# Fixed detecting the amount of installed memory (for DSM 7.2 which now reports GB instead of MB). -# -# Fixed USB drives sometimes being detected as internal drives (for DSM 7.2). -# -# Fixed error if /run/synostorage/disks/nvme0n1/m2_pool_support doesn't exist yet (for DSM 7.2). -# -# Fixed drive db update still being disabled in /etc/synoinfo.conf after script run without -n or --noupdate option. -# -# Fixed drive db update still being disabled in /etc/synoinfo.conf after script run with --restore option. -# -# Fixed permissions on restored files being incorrect after script run with --restore option. -# -# Fixed permissions on backup files. -# -# Now skips checking the amount of installed memory in DSM 6 (because it was never working). -# -# Now the script reloads itself after updating. -# -# Added --autoupdate=AGE option to auto update synology_hdd_db x days after new version released. -# Autoupdate logs update success or errors to DSM system log. -# -# Added -w, --wdda option to disable WDDA -# https://kb.synology.com/en-us/DSM/tutorial/Which_Synology_NAS_supports_WDDA -# https://www.youtube.com/watch?v=cLGi8sPLkLY -# https://community.synology.com/enu/forum/1/post/159537 -# -# Added --restore info to --help -# -# Updated restore option to download the latest db files from Synology -# -# Now warns you if you try to run it in sh with "sh scriptname.sh" -# -# Fixed DSM 6 bug where the drives were being duplicated in the .db files each time the script was run. -# -# Fixed DSM 6 bug where the .db files were being duplicated as .dbr each time the db files were edited. -# -# Fixed bug where expansion units ending in RP or II were not detected. -# -# Added a --restore option to undo all changes. -# -# 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. -# This will also ensure the script still works if: -# Synology append different numbers to the db file names in DSM 8 etc. -# The detected NAS model name does not match the .db files' model name. -# -# Now backs up the .db.new files (as well as the .db files). -# -# Now shows max memory in GB instead of MB. -# -# Now shows status of "Support disk compatibility" setting even if it wasn't changed. -# -# Now shows status of "Support memory compatibility" setting even if it wasn't changed. -# -# 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 to not run "synostgdisk --check-all-disks-compatibility" in DSM 6.2.3 (which has no synostgdisk). -# -# Now edits max supported memory to match the amount of memory installed, if greater than the current max memory setting. -# -# Now allows creating M.2 storage pool and volume all from Storage Manager -# -# Now always shows your drive entries in the host db file if -s or --showedits used, -# instead of only db file was edited during that run. -# -# Changed to show usage if invalid long option used instead of continuing. -# -# Fixed bug inserting firmware version for already existing model. -# -# Changed to add drives' firmware version to the db files (to support data deduplication). -# See https://github.com/007revad/Synology_enable_Deduplication -# -# Changed to be able to edit existing drive entries in the db files to add the firmware version. -# -# Now supports editing db files that don't currently have any drives listed. -# -# Fixed bug where the --noupdate option was coded as --nodbupdate. Now either will work. -# -# Fixed bug in re-enable drive db updates -# -# Fixed "download new version" failing if script was run via symlink or ./ -# -# Changed to show if no M.2 cards were found, if M.2 drives were found. -# -# Changed latest version check to download to /tmp and extract files to the script's location, -# replacing the existing .sh and readme.txt files. -# -# Added a timeouts when checking for newer script version in case github is down or slow. -# -# Added option to disable incompatible memory notifications. -# -# Now finds your expansion units' model numbers and adds your drives to their db files. -# -# Now adds your M.2 drives to your M.2 PCI cards db files (M2Dxx and E10M20-T1 and future models). -# -# Improved flags/options checking and added usage help. -# -# Can now download the latest script version for you (if you have user home service enabled in DSM). -# -# Now adds 'support_m2_pool="yes"' line for models that don't have support_m2_pool in synoinfo.conf -# to (hopefully) prevent losing your SSH created M2 volume when running this script on models -# that DSM 7.2 Beta does not list as supported for creating M2 volumes. -# -# Changed Synology model detection to be more reliable (for models that came in different variations). -# -# Changed checking drive_db_test_url setting to be more durable. -# -# Added removal of " 00Y" from end of Samsung/Lenovo SSDs to fix issue #13. -# -# Fixed bug where removable drives were being detected and added to drive database. -# -# Fixed bug where "M.2 volume support already enabled" message appeared when NAS had no M.2 drives. -# -# Added check that M.2 volume support is enabled (on supported models). -# -# Added support for M.2 SATA drives. -# -# Can now skip processing M.2 drives by running script with the -m2 flag. -# -# Changed method of getting drive and firmware version so script is faster and easier to maintain. -# - No longer using smartctl or hdparm. -# -# Changed SAS drive firmware version detection to support SAS drives that hdparm doesn't work with. -# -# Removed error message and aborting if *.db.new not found (clean DSM installs don't have a *.db.new). -# -# Force DSM to check disk compatibility so reboot not needed (DSM 6 may still need a reboot). -# -# Fixed DSM 6 issue when DSM 6 has the old db file format. -# -# Add support for SAS drives. -# -# Get HDD/SSD/SAS drive model number with smartctl instead of hdparm. +# and are using DSM 7.2 Update 2 and 3, 7.2.1, 7.2.1 Update 1, 2 and 3. # -# Check if there is a newer script version available. +# Now edits model.dtb instead of downloading a pre-edited version. # -# Add support for NVMe drives. +# Fix for Unknown vendor causing "Unsupported firmware version" warning. Issue #161 # -# Prevent DSM auto updating the drive database. +# Now supports NVMe drives that show as Unknown brand in storage manager: Issue #161 +# - ADATA, Corsair, Gigabyte, HS/MAXIO, MSI, Netac, Phison, PNY +# - SK Hynix, Solidigm, SPCC/Lexar, TEAMGROUP, UMIS, ZHITAI # -# Optionally disable "support_disk_compatibility". +# Fixed bug where memory was shown in MB but with GB unit. -scriptver="v3.2.66" +scriptver="v3.2.67" script=Synology_HDD_db repo="007revad/Synology_HDD_db" @@ -310,9 +114,6 @@ if options="$(getopt -o abcdefghijklmnopqrstuvwxyz0123456789 -l \ -r|--ram) # Disable "support_memory_compatibility" ram=yes ;; - -i|--immutable) # Enable "support_worm" (immutable snapshots) - immutable=yes # Does not work for models without support_worm=yes already - ;; -w|--wdda) # Disable "support_memory_compatibility" wdda=no ;; @@ -391,11 +192,6 @@ if [[ $dsm -gt "6" ]]; then fi # Get Synology model - -# This doesn't work for drives migrated from different model -#model=$(find /var/lib/disk-compatibility -regextype egrep -regex ".*host(_v7)?\.db$" |\ -# cut -d"/" -f5 | cut -d"_" -f1 | uniq) - model=$(cat /proc/sys/kernel/syno_hw_version) modelname="$model" @@ -430,6 +226,13 @@ elif [[ $model =~ '-j'$ ]]; then # GitHub issue #2 echo -e "\nUsing model: $model" fi + +# Get StorageManager version +storagemgrver=$(synopkg version StorageManager) +# Show StorageManager version +if [[ $storagemgrver ]]; then echo -e "StorageManager $storagemgrver\n"; fi + + # Show options used echo "Using options: ${args[*]}" @@ -726,6 +529,68 @@ fi # Get list of installed SATA, SAS and M.2 NVMe/SATA drives, # PCIe M.2 cards and connected Expansion Units. +vendor_from_id(){ + # Vendor ids missing in /usr/syno/etc.defaults/pci_vendor_ids.conf + # $1 is vendor id + # https://devicehunt.com/all-pci-vendors + vendor="" + case "${1,,}" in + 0x10ec) vendor=TEAMGROUP ;; + 0x025e) vendor=Solidigm ;; + 0x1458) vendor=Gigabyte ;; + 0x1462) vendor=MSI ;; + 0x196e) vendor=PNY ;; + 0x1987) vendor=Phison ;; + 0x1b1c) vendor=Corsair ;; + 0x1c5c) vendor="SK Hynix" ;; + 0x1cc4) vendor=UMIS ;; + 0x1cfa) vendor=Corsair ;; # Memory only? + 0x1d97) vendor=SPCC/Lexar ;; # 2 brands with same vid + 0x1dbe) vendor=ADATA ;; + 0x1e49) vendor=ZHITAI ;; + 0x1e4b) vendor=HS/MAXIO ;; # 2 brands with same vid + 0x1f40) vendor=Netac ;; + *) + echo -e "\n${Error}WARNING{OFF} No vendor found for id $1" >&2 + echo -e "Contact 007revad to get your drive added.\n" >&2 + ;; + esac +} + +set_vendor(){ + # Add missing vendors to /usr/syno/etc.defaults/pci_vendor_ids.conf + if [[ $vendor ]]; then + if ! grep "$vid" "$vidfile" >/dev/null; then + synosetkeyvalue "$vidfile" "${vid,,}" "$vendor" + val=$(synogetkeyvalue "$vidfile" "${vid,,}") + if [[ $val == "${vendor}" ]]; then + echo "Added $vendor to pci_vendor_ids" >&2 + else + echo "Failed to add $vendor to pci_vendor_ids!" >&2 + fi + fi + if ! grep "$vid" "$vidfile2" >/dev/null; then + synosetkeyvalue "$vidfile2" "${vid,,}" "$vendor" + fi + fi +} + +get_vid(){ + # $1 is /dev/nvme0n1 etc + if [[ $1 ]]; then + vid=$(nvme id-ctrl "$1" | grep -E ^vid | awk '{print $NF}') + if [[ $vid ]]; then + val=$(synogetkeyvalue "$vidfile" "${vid,,}") + if [[ -z $val ]]; then + vendor_from_id "$vid" && set_vendor + fi + fi + fi +} + +vidfile="/usr/syno/etc.defaults/pci_vendor_ids.conf" +vidfile2="/usr/syno/etc/pci_vendor_ids.conf" + fixdrivemodel(){ # Remove " 00Y" from end of Samsung/Lenovo SSDs # Github issue #13 if [[ $1 =~ MZ.*' 00Y' ]]; then @@ -733,8 +598,8 @@ fixdrivemodel(){ fi # Brands that return "BRAND " and need "BRAND " removed. - if [[ $1 =~ ^[A-Za-z]{1,7}' '.* ]]; then - # See Smartmontools database in /var/lib/smartmontools/drivedb.db + if [[ $1 =~ ^[A-Za-z]{3,7}' '.* ]]; then + # See Smartmontools database in /var/lib/smartmontools/drivedb.db hdmodel=${hdmodel#"WDC "} # Remove "WDC " from start of model name hdmodel=${hdmodel#"HGST "} # Remove "HGST " from start of model name hdmodel=${hdmodel#"TOSHIBA "} # Remove "TOSHIBA " from start of model name @@ -743,14 +608,18 @@ fixdrivemodel(){ hdmodel=${hdmodel#"Hitachi "} # Remove "Hitachi " from start of model name hdmodel=${hdmodel#"SAMSUNG "} # Remove "SAMSUNG " from start of model name hdmodel=${hdmodel#"FUJISTU "} # Remove "FUJISTU " from start of model name + elif [[ $1 =~ ^'APPLE HDD '.* ]]; then + # Old drive brands hdmodel=${hdmodel#"APPLE HDD "} # Remove "APPLE HDD " from start of model name fi } getdriveinfo(){ # $1 is /sys/block/sata1 etc + + # Skip USB drives usb=$(grep "$(basename -- "$1")" /proc/mounts | grep "[Uu][Ss][Bb]" | cut -d" " -f1-2) - if [[ ! $usb ]]; then # Skip USB drives + if [[ ! $usb ]]; then # Get drive model hdmodel=$(cat "$1/device/model") @@ -821,6 +690,7 @@ getcardmodel(){ } m2_pool_support(){ + # M.2 drives in M2 adaptor card do not support storage pools if [[ $isinm2card != "yes" ]]; then if [[ -f /run/synostorage/disks/"$(basename -- "$1")"/m2_pool_support ]]; then # GitHub issue #86, 87 echo 1 > /run/synostorage/disks/"$(basename -- "$1")"/m2_pool_support @@ -846,6 +716,11 @@ for d in /sys/block/*; do nvme*) if [[ $d =~ nvme[0-9][0-9]?n[0-9][0-9]?$ ]]; then if [[ $m2 != "no" ]]; then + # Fix unknown vendor id if needed. GitHub issue #161 + # "Failed to get disk vendor" from synonvme --vendor-get + # causes "Unsupported firmware version" warning. + get_vid "/dev/$(basename -- "${d}")" + getm2info "$d" "nvme" # Get M.2 card model if in M.2 card getcardmodel "/dev/$(basename -- "${d}")" @@ -1139,17 +1014,18 @@ updatedb(){ default="$default":\"support\",\"fw_dsm_update_status_notify\":false,\"barebone_installable\":true}]}}} if grep '"disk_compatbility_info":{}' "$2" >/dev/null; then - # Replace "disk_compatbility_info":{} with "disk_compatbility_info":{"WD40PURX-64GVNY0":{"80.00A80":{ ... }}},"default":{ ... }}}} + # Replace "disk_compatbility_info":{} with + # "disk_compatbility_info":{"WD40PURX-64GVNY0":{"80.00A80":{ ... }}},"default":{ ... }}}} #echo "Edit empty db file:" # debug editdb7 "empty" "$2" elif grep '"'"$hdmodel"'":' "$2" >/dev/null; then - # Replace "WD40PURX-64GVNY0":{ with "WD40PURX-64GVNY0":{"80.00A80":{ ... }}}, + # Replace "WD40PURX-64GVNY0":{ with "WD40PURX-64GVNY0":{"80.00A80":{ ... }}}, #echo "Insert firmware version:" # debug editdb7 "insert" "$2" else - # Add "WD40PURX-64GVNY0":{"80.00A80":{ ... }}},"default":{ ... }}} + # Add "WD40PURX-64GVNY0":{"80.00A80":{ ... }}},"default":{ ... }}} #echo "Append drive and firmware:" # debug editdb7 "append" "$2" fi @@ -1168,7 +1044,8 @@ updatedb(){ # example: # {"success":1,"list":[{"model":"WD60EFRX-68MYMN1","firmware":"82.00A82","rec_intvl":[1]}, #if sed -i "s/$startstring/$startstring$string/" "$2"; then - if sed -i "s/${startstring//\//\\/}/${startstring//\//\\/}$string/" "$2"; then + #if sed -i "s/${startstring//\//\\/}/${startstring//\//\\/}$string/" "$2"; then + if sed -i "s/$startstring/$startstring${string//\//\\/}/" "$2"; then echo -e "Added ${Yellow}$hdmodel${Off} to ${Cyan}$(basename -- "$2")${Off}" else ding @@ -1234,11 +1111,6 @@ done #------------------------------------------------------------------------------ # Enable unsupported Synology M2 PCIe cards -# DS1821+, DS1621+ and DS1520+ also need edited device tree blob file -# /etc.defaults/model.dtb -# RS822RP+, RS822+, RS1221RP+ and RS1221+ with DSM older than 7.2 need -# device tree blob file from DSM 7.2 to support M2D18 - enable_card(){ # $1 is the file # $2 is the section @@ -1278,6 +1150,7 @@ if [[ $1 == E10M20-T1 ]] || [[ $1 == M2D20 ]]; then $1 { compatible = "Synology"; model = "synology_${1,,}"; + power_limit = "14.85,14.85"; m2_card@1 { @@ -1304,6 +1177,7 @@ elif [[ $1 == M2D18 ]]; then M2D18 { compatible = "Synology"; model = "synology_m2d18"; + power_limit = "9.9,9.9"; m2_card@1 { @@ -1338,26 +1212,58 @@ fi } -download_dtc(){ - # Download dtc from github - echo "Downloading dtc" >&2 - if cd /var/services/tmp; then - url="https://github.com/${repo}/raw/main/bin/dtc" - #if curl -kLJO -m 30 --connect-timeout 5 "$url"; then - if curl -kLO -m 30 --connect-timeout 5 "$url"; then - mv /var/services/tmp/dtc /usr/sbin/dtc - chmod 755 /usr/sbin/dtc - fi +install_binfile(){ + # install_binfile + # example: + # file_url="https://raw.githubusercontent.com/${repo}/main/bin/dtc" + # install_binfile dtc "$file_url" /usr/bin/bc a+x bin/dtc + + if [[ -f "${scriptpath}/$5" ]]; then + binfile="${scriptpath}/$5" + echo -e "\nInstalling ${1}" + elif [[ -f "${scriptpath}/$(basename -- "$5")" ]]; then + binfile="${scriptpath}/$(basename -- "$5")" + echo -e "\nInstalling ${1}" else - echo -e "${Error}ERROR${Off} Failed to cd to /var/services/tmp!" >&2 - fi -} + # Download binfile + if [[ $autoupdate == "yes" ]]; then + reply=y + else + echo -e "\nNeed to download ${1}" + echo -e "${Cyan}Do you want to download ${1}?${Off} [y/n]" + read -r -t 30 reply + fi + if [[ ${reply,,} == "y" ]]; then + echo -e "\nDownloading ${1}" + if ! curl -kLO -m 30 --connect-timeout 5 "$2" -o "/tmp/$1"; then + echo -e "${Error}ERROR${Off} Failed to download ${1}!" + return + fi + binfile="/tmp/${1}" + printf "Downloaded md5: " + md5sum -b "$binfile" | awk '{print $1}' -edit_dts(){ + md5=$(md5sum -b "$binfile" | awk '{print $1}') + if [[ $md5 != "$6" ]]; then + echo "Expected md5: $6" + echo -e "${Error}ERROR${Off} Downloaded $1 md5 hash does not match!" + exit 1 + fi + else + echo -e "${Error}ERROR${Off} Cannot add M2 PCIe card without ${1}!" + exit 1 + fi + fi -#set -x # debug + # Set binfile executable + chmod "$4" "$binfile" + # Copy binfile to destination + cp -p "$binfile" "$3" +} + +edit_dts(){ # $1 is M.2 card model # Edit model.dts if needed if ! grep "$1" "$dtb_file" >/dev/null; then @@ -1368,42 +1274,6 @@ edit_dts(){ #echo "$1 already exists in model${hwrev}.dtb" >&2 # echo -e "${Yellow}$1${Off} already exists in ${Cyan}model${hwrev}.dtb${Off}" >&2 fi - -#set +x # debug - -} - - -set_pwr_limit(){ - if ! grep "$pwr_limit" "$dts_file" >/dev/null; then - # Save current power_limit - pwr_lmt_old=$(grep power_limit "$dts_file" | cut -d\" -f2) - - # Find line to insert power_limit - pwrlim_line=$(awk '! NF { print NR }' "$dts_file" | head -n 2 | tail -n 1) - - power_limit=" power_limit = \"$pwr_limit\";" - #echo "$power_limit" >&2 # debug - - if grep power_limit "$dts_file" >/dev/null; then - filehead=$(head -n $((pwrlim_line -2)) "$dts_file") - else - filehead=$(head -n $((pwrlim_line -1)) "$dts_file") - fi - #echo "$filehead" >&2 # debug - - filetail=$(tail -n +$((pwrlim_line +1)) "$dts_file") - #echo "$filetail" >&2 # debug - - echo "$filehead" > "$dts_file" - echo -e "$power_limit\n" >> "$dts_file" - echo "$filetail" >> "$dts_file" - - # Show result - echo -e "Updated power limit in ${Cyan}model${hwrev}.dtb${Off}" >&2 - echo " Old power_limit $pwr_lmt_old" >&2 - echo " New power_limit $pwr_limit" >&2 - fi } @@ -1416,54 +1286,21 @@ check_modeldtb(){ # If syno_hw_revision is r1 or r2 it's a real Synology, # and I need to edit model_rN.dtb instead of model.dtb if [[ $hwrevision =~ r[0-9] ]]; then - #echo "hwrevision: $hwrevision" >&2 # debug + #echo "hwrevision: $hwrevision" # debug hwrev="_$hwrevision" fi - dtb_file="/etc.defaults/model${hwrev}.dtb" dts_file="/etc.defaults/model${hwrev}.dts" dtb2_file="/etc/model${hwrev}.dtb" - - # NVMe power_limit - if grep power_limit /run/model.dtb >/dev/null; then - - if [ -f /sys/firmware/devicetree/base/power_limit ]; then - pwrval=$(cat /sys/firmware/devicetree/base/power_limit | cut -d"," -f1) - # Check pwrval is float or numeric - if [[ ! $pwrval =~ ^[0-9]+([.][0-9]+)?$ ]]; then - pwrval="100" - fi - else - pwrval="100" - fi - - pwr_limit="" - nvme_drives=$(ls /sys/class/nvme | wc -w) - for i in $(seq 0 $((nvme_drives -1))); do - [ "$i" -eq 0 ] && pwr_limit="$pwrval" || pwr_limit="${pwr_limit},$pwrval" - done - - #echo "power_limit $pwr_limit" >&2 # debug - fi - - # Check power_limit and adapter card already in model.dtb - if grep "$pwr_limit" "$dtb_file" >/dev/null && grep "$1" "$dtb_file" >/dev/null - then - echo -e "${Yellow}$1${Off} already exists in ${Cyan}model${hwrev}.dtb${Off}" >&2 - return - fi - - # Check if dtc exists and is executable - if [[ ! -x /usr/sbin/dtc ]]; then - if [[ -f ./bin/dtc ]]; then - cp -f ./bin/dtc /usr/sbin/dtc - chmod 755 /usr/sbin/dtc - else - download_dtc - fi + if [[ ! -x $(which dtc) ]]; then + md5hash="01381dabbe86e13a2f4a8017b5552918" + branch="main" + file_url="https://raw.githubusercontent.com/${repo}/${branch}/bin/dtc" + # install_binfile + install_binfile dtc "$file_url" /usr/sbin/dtc "a+x" bin/dtc "$md5hash" fi # Check again if dtc exists and is executable @@ -1479,13 +1316,8 @@ check_modeldtb(){ chmod 644 "$dts_file" # Edit model.dts - #edit_dts "E10M20-T1" # test - #edit_dts "M2D20" # test - #edit_dts "M2D18" # test edit_dts "$1" - [[ -n $pwr_limit ]] && set_pwr_limit - # Compile model.dts to model.dtb dtc -q -I dts -O dtb -o "$dtb_file" "$dts_file" # -q Suppress warnings @@ -1493,9 +1325,6 @@ check_modeldtb(){ chmod a+r "$dtb_file" chown root:root "$dtb_file" cp -pu "$dtb_file" "$dtb2_file" # Copy dtb file to /etc - - # Delete model.dts - rm "$dts_file" else echo -e "${Error}ERROR${Off} Missing /usr/sbin/dtc or not executable!" >&2 fi @@ -1506,6 +1335,7 @@ check_modeldtb(){ for c in "${m2cards[@]}"; do #echo "" m2cardconf="/usr/syno/etc.defaults/adapter_cards.conf" + m2card2conf="/usr/syno/etc/adapter_cards.conf" case "$c" in E10M20-T1) backupdb "$m2cardconf" @@ -1513,12 +1343,16 @@ for c in "${m2cards[@]}"; do enable_card "$m2cardconf" E10M20-T1_sup_nic "E10M20-T1 NIC" enable_card "$m2cardconf" E10M20-T1_sup_nvme "E10M20-T1 NVMe" #enable_card "$m2cardconf" E10M20-T1_sup_sata "E10M20-T1 SATA" + enable_card "$m2card2conf" E10M20-T1_sup_nic "E10M20-T1 NIC" + enable_card "$m2card2conf" E10M20-T1_sup_nvme "E10M20-T1 NVMe" + #enable_card "$m2card2conf" E10M20-T1_sup_sata "E10M20-T1 SATA" check_modeldtb "$c" ;; M2D20) backupdb "$m2cardconf" echo "" enable_card "$m2cardconf" M2D20_sup_nvme "M2D20 NVMe" + enable_card "$m2card2conf" M2D20_sup_nvme "M2D20 NVMe" check_modeldtb "$c" ;; M2D18) @@ -1526,12 +1360,15 @@ for c in "${m2cards[@]}"; do echo "" enable_card "$m2cardconf" M2D18_sup_nvme "M2D18 NVMe" enable_card "$m2cardconf" M2D18_sup_sata "M2D18 SATA" + enable_card "$m2card2conf" M2D18_sup_nvme "M2D18 NVMe" + enable_card "$m2card2conf" M2D18_sup_sata "M2D18 SATA" check_modeldtb "$c" ;; M2D17) backupdb "$m2cardconf" echo "" enable_card "$m2cardconf" M2D17_sup_sata "M2D17 SATA" + enable_card "$m2card2conf" M2D17_sup_sata "M2D17 SATA" ;; *) echo "Unknown M2 card type: $c" @@ -1689,9 +1526,7 @@ if [[ $dsm -gt "6" ]]; then # DSM 6 as has no /proc/meminfo fi - -# Enable nvme support This probably should be before we look for NVMe drives. -# But it probably also needs a reboot after we change it. +# Enable nvme support if [[ $m2 != "no" ]]; then # Check if nvme support is enabled setting="$(get_key_value $synoinfo supportnvme)" @@ -1817,22 +1652,6 @@ if [[ $wdda == "no" ]]; then fi -# Optionally enable "support_worm" (immutable snapshots) -setting="$(get_key_value $synoinfo support_worm)" -if [[ $immutable == "yes" ]]; then - if [[ $setting != "yes" ]]; then - # Disable support_memory_compatibility - synosetkeyvalue "$synoinfo" support_worm "yes" - setting="$(get_key_value "$synoinfo" support_worm)" - if [[ $setting == "yes" ]]; then - echo -e "\nEnabled Immutable Snapshots." - fi - elif [[ $setting == "no" ]]; then - echo -e "\nImmutable Snapshots already enabled." - fi -fi - - #------------------------------------------------------------------------------ # Finished