Browse Source

Merge pull request #63 from 007revad/develop

Develop
pull/91/head v2.2.42
Dave Russell 3 years ago
committed by GitHub
parent
commit
90352989a0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      CHANGES.txt
  2. 253
      syno_hdd_db.sh

11
CHANGES.txt

@ -1,3 +1,14 @@
v2.2.42
- Fixed bug where expansion units ending in RP or II were not detected.
- Added a --restore option to undo all changes made by the script.
- 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.
v2.1.38 v2.1.38
- 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.

253
syno_hdd_db.sh

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck disable=SC1083,SC2054,SC2121 # shellcheck disable=SC1083,SC2054,SC2121,SC2207
#-------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------
# Github: https://github.com/007revad/Synology_HDD_db # Github: https://github.com/007revad/Synology_HDD_db
# Script verified at https://www.shellcheck.net/ # Script verified at https://www.shellcheck.net/
@ -30,6 +30,23 @@
# 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
# 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. # 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 +138,7 @@
# Optionally disable "support_disk_compatibility". # Optionally disable "support_disk_compatibility".
scriptver="v2.1.38" scriptver="v2.2.42"
script=Synology_HDD_db script=Synology_HDD_db
repo="007revad/Synology_HDD_db" repo="007revad/Synology_HDD_db"
@ -171,15 +188,19 @@ EOF
# Save options used # Save options used
args="$@" args="$*"
# Check for flags with getopt # Check for flags with getopt
if options="$(getopt -o abcdefghijklmnopqrstuvwxyz0123456789 -a \ if options="$(getopt -o abcdefghijklmnopqrstuvwxyz0123456789 -a \
-l showedits,noupdate,nodbupdate,m2,force,ram,help,version,debug -- "$@")"; then -l restore,showedits,noupdate,nodbupdate,m2,force,ram,help,version,debug -- "$@")"; then
eval set -- "$options" eval set -- "$options"
while true; do while true; do
case "${1,,}" in case "${1,,}" in
--restore) # Restore changes from backups
restore=yes
break
;;
-s|--showedits) # Show edits done to host db file -s|--showedits) # Show edits done to host db file
showedits=yes showedits=yes
;; ;;
@ -371,14 +392,12 @@ 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
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
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
@ -407,6 +426,49 @@ if ! printf "%s\n%s\n" "$tag" "$scriptver" |
fi fi
#------------------------------------------------------------------------------
# Restore changes from backups
dbpath=/var/lib/disk-compatibility/
synoinfo="/etc.defaults/synoinfo.conf"
if [[ $restore == "yes" ]]; then
dbbakfiles=($(find $dbpath -maxdepth 1 \( -name "*.db.new.bak" -o -name "*.db.bak" \)))
echo
if [[ ${#dbbakfiles[@]} -gt "0" ]] || [[ -f ${synoinfo}.bak ]]; then
# Restore .db files from backups
for f in "${!dbbakfiles[@]}"; do
deleteme="${dbbakfiles[f]%.bak}" # Remove .bak
if mv "${dbbakfiles[f]}" "$deleteme"; then
echo "Restored $(basename -- "$deleteme")"
else
restoreerr=1
echo -e "${Error}ERROR${Off} Failed to restore $(basename -- "$deleteme")!\n"
fi
done
# Restore synoinfo.conf from backup
if [[ -f ${synoinfo}.bak ]]; then
if mv "${synoinfo}.bak" "${synoinfo}"; then
echo "Restored $(basename -- "$synoinfo")"
else
restoreerr=1
echo -e "${Error}ERROR${Off} Failed to restore synoinfo.conf!\n"
fi
fi
if [[ -z $restoreerr ]]; then
echo -e "\nRestore successful."
fi
else
echo "Nothing to restore."
fi
exit
fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Get list of installed SATA, SAS and M.2 NVMe/SATA drives, # Get list of installed SATA, SAS and M.2 NVMe/SATA drives,
# PCIe M.2 cards and connected Expansion Units. # PCIe M.2 cards and connected Expansion Units.
@ -437,7 +499,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 +541,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,12 +585,11 @@ 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
;; ;;
nvc*) # M.2 SATA drives (in PCIe card only?) nvc*) # M.2 SATA drives (in PCIe card only?)
#if [[ $d =~ nvc[0-9][0-9]?p[0-9][0-9]?$ ]]; then
if [[ $d =~ nvc[0-9][0-9]?$ ]]; then if [[ $d =~ nvc[0-9][0-9]?$ ]]; then
if [[ $m2 != "no" ]]; then if [[ $m2 != "no" ]]; then
getm2info "$d" "nvc" getm2info "$d" "nvc"
@ -526,7 +597,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
;; ;;
@ -616,8 +687,7 @@ fi
path="/var/log/diskprediction" path="/var/log/diskprediction"
# shellcheck disable=SC2012 # shellcheck disable=SC2012
file=$(ls $path | tail -n1) file=$(ls $path | tail -n1)
# shellcheck disable=SC2207 eunitlist=($(grep -Eowi "([FRD]XD?[0-9]{3,4})(rp|ii|sas){0,2}" "$path/$file" | uniq))
eunitlist=($(grep -Eow "([FRD]XD?[0-9]{3,4})(RP|II|sas){0,2}" "$path/$file" | uniq))
# Sort eunitlist array into new eunits array to remove duplicates # Sort eunitlist array into new eunits array to remove duplicates
if [[ ${#eunitlist[@]} -gt "0" ]]; then if [[ ${#eunitlist[@]} -gt "0" ]]; then
@ -644,16 +714,27 @@ 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" # Host db files
db2="/var/lib/disk-compatibility/${model}_host${version}.db.new" db1list=($(find "$dbpath" -maxdepth 1 -name "*_host*.db"))
dbpath="/var/lib/disk-compatibility/" db2list=($(find "$dbpath" -maxdepth 1 -name "*_host*.db.new"))
synoinfo="/etc.defaults/synoinfo.conf" # Expansion Unit db files
for i in "${!eunits[@]}"; do
eunitdb1list=($(find "$dbpath" -maxdepth 1 -name "${eunits[i],,}*.db"))
eunitdb2list=($(find "$dbpath" -maxdepth 1 -name "${eunits[i],,}*.db.new"))
done
# M.2 Card db files
for i in "${!m2cards[@]}"; do
m2carddb1list=($(find "$dbpath" -maxdepth 1 -name "*_${m2cards[i],,}*.db"))
m2carddb2list=($(find "$dbpath" -maxdepth 1 -name "*_${m2cards[i],,}*.db.new"))
done
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
# Don't check .db.new as new installs don't have a .db.new file
getdbtype(){ getdbtype(){
@ -689,7 +770,18 @@ backupdb() {
# Backup host database file if needed # Backup host database file if needed
backupdb "$db1" || exit 5 for i in "${!db1list[@]}"; do
backupdb "${db1list[i]}" ||{
echo -e "${Error}ERROR 5${Off} Failed to backup $(basename -- "${db1list[i]}")!"
exit 5
}
done
for i in "${!db2list[@]}"; do
backupdb "${db2list[i]}" ||{
echo -e "${Error}ERROR 5${Off} Failed to backup $(basename -- "${db2list[i]}")!"
exit 5 # maybe don't exit for .db.new file
}
done
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -697,9 +789,9 @@ 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 =~ .*\.db$ ]]; then
db1Edits=$((db1Edits +1)) db1Edits=$((db1Edits +1))
elif [[ $1 == "$db2" ]]; then elif [[ $1 =~ .*\.db.new ]]; then
db2Edits=$((db2Edits +1)) db2Edits=$((db2Edits +1))
fi fi
} }
@ -764,17 +856,17 @@ updatedb() {
if grep '"disk_compatbility_info":{}' "$2" >/dev/null; then 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" #echo "Edit empty db file:" # debug
editdb7 "empty" "$2" editdb7 "empty" "$2"
elif grep '"'"$hdmodel"'":' "$2" >/dev/null; then 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" #echo "Insert firmware version:" # debug
editdb7 "insert" "$2" editdb7 "insert" "$2"
else else
# Add "WD40PURX-64GVNY0":{"80.00A80":{ ... }}},"default":{ ... }}} # Add "WD40PURX-64GVNY0":{"80.00A80":{ ... }}},"default":{ ... }}}
echo "Append drive and firmware" #echo "Append drive and firmware:" # debug
editdb7 "append" "$2" editdb7 "append" "$2"
fi fi
@ -786,23 +878,10 @@ updatedb() {
string="{\"model\":\"${hdmodel}\",\"firmware\":\"\",\"rec_intvl\":\[1\]}," string="{\"model\":\"${hdmodel}\",\"firmware\":\"\",\"rec_intvl\":\[1\]},"
# {"success":1,"list":[ # {"success":1,"list":[
startstring="{\"success\":1,\"list\":\[" startstring="{\"success\":1,\"list\":\["
#echo "$startstring" >&2 # debug
#echo "$string" >&2 # debug
#echo >&2 # debug
# example: # example:
# {"success":1,"list":[{"model":"WD60EFRX-68MYMN1","firmware":"82.00A82","rec_intvl":[1]}, # {"success":1,"list":[{"model":"WD60EFRX-68MYMN1","firmware":"82.00A82","rec_intvl":[1]},
if sed -ir "s/$startstring/$startstring$string/" "$2"; then if sed -ir "s/$startstring/$startstring$string/" "$2"; then
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
if [[ $2 == "$db1" ]]; then
db1Edits=$((db1Edits +1))
elif [[ $2 == "$db2" ]]; then
db2Edits=$((db2Edits +1))
fi
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
exit 8 exit 8
@ -814,23 +893,22 @@ 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" for i in "${!db1list[@]}"; do
if [[ -f "$db2" ]]; then updatedb "${hdds[$num]}" "${db1list[i]}"
updatedb "${hdds[$num]}" "$db2" done
fi for i in "${!db2list[@]}"; do
updatedb "${hdds[$num]}" "${db2list[i]}"
done
#------------------------------------------------ #------------------------------------------------
# Expansion Units # Expansion Units
num2="0" for i in "${!eunitdb1list[@]}"; do
while [[ $num2 -lt "${#eunits[@]}" ]]; do backupdb "${eunitdb1list[i]}" &&\
eudb="${dbpath}${eunits[$num2],,}${version}.db" updatedb "${hdds[$num]}" "${eunitdb1list[i]}"
if [[ -f "$eudb" ]]; then done
backupdb "$eudb" &&\ for i in "${!eunitdb2list[@]}"; do
updatedb "${hdds[$num]}" "$eudb" backupdb "${eunitdb2list[i]}" &&\
else updatedb "${hdds[$num]}" "${eunitdb2list[i]}"
echo -e "${Error}ERROR 11${Off} $eudb not found!"
fi
num2=$((num2 +1))
done done
#------------------------------------------------ #------------------------------------------------
@ -840,22 +918,22 @@ 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" for i in "${!db1list[@]}"; do
if [[ -f "$db2" ]]; then updatedb "${nvmes[$num]}" "${db1list[i]}"
updatedb "${nvmes[$num]}" "$db2" done
fi for i in "${!db2list[@]}"; do
updatedb "${nvmes[$num]}" "${db2list[i]}"
done
#------------------------------------------------ #------------------------------------------------
# M.2 adaptor cards # M.2 adaptor cards
num2="0" for i in "${!m2carddb1list[@]}"; do
while [[ $num2 -lt "${#m2carddbs[@]}" ]]; do backupdb "${m2carddb1list[i]}" &&\
if [[ -f "${dbpath}${m2carddbs[$num2]}" ]]; then updatedb "${nvmes[$num]}" "${m2carddb1list[i]}"
backupdb "${dbpath}${m2carddbs[$num2]}" &&\ done
updatedb "${nvmes[$num]}" "${dbpath}${m2carddbs[$num2]}" for i in "${!m2carddb2list[@]}"; do
else backupdb "${m2carddb2list[i]}" &&\
echo -e "${Error}ERROR 10${Off} ${m2carddbs[$num2]} not found!" updatedb "${nvmes[$num]}" "${m2carddb2list[i]}"
fi
num2=$((num2 +1))
done done
#------------------------------------------------ #------------------------------------------------
@ -875,22 +953,24 @@ setting="$(get_key_value $synoinfo $sdc)"
if [[ $force == "yes" ]]; then if [[ $force == "yes" ]]; then
if [[ $setting == "yes" ]]; then if [[ $setting == "yes" ]]; then
# Disable support_disk_compatibility # Disable support_disk_compatibility
#sed -i "s/${sdc}=\"yes\"/${sdc}=\"no\"/" "$synoinfo"
synosetkeyvalue "$synoinfo" "$sdc" "no" synosetkeyvalue "$synoinfo" "$sdc" "no"
setting="$(get_key_value "$synoinfo" $sdc)" setting="$(get_key_value "$synoinfo" $sdc)"
if [[ $setting == "no" ]]; then if [[ $setting == "no" ]]; then
echo -e "\nDisabled support disk compatibility." echo -e "\nDisabled support disk compatibility."
fi fi
elif [[ $setting == "no" ]]; then
echo -e "\nSupport disk compatibility already disabled."
fi fi
else else
if [[ $setting == "no" ]]; then if [[ $setting == "no" ]]; then
# Enable support_disk_compatibility # Enable support_disk_compatibility
#sed -i "s/${sdc}=\"no\"/${sdc}=\"yes\"/" "$synoinfo"
synosetkeyvalue "$synoinfo" "$sdc" "yes" synosetkeyvalue "$synoinfo" "$sdc" "yes"
setting="$(get_key_value "$synoinfo" $sdc)" setting="$(get_key_value "$synoinfo" $sdc)"
if [[ $setting == "yes" ]]; then if [[ $setting == "yes" ]]; then
echo -e "\nRe-enabled support disk compatibility." echo -e "\nRe-enabled support disk compatibility."
fi fi
elif [[ $setting == "yes" ]]; then
echo -e "\nSupport disk compatibility already enabled."
fi fi
fi fi
@ -901,26 +981,28 @@ setting="$(get_key_value $synoinfo $smc)"
if [[ $ram == "yes" ]]; then if [[ $ram == "yes" ]]; then
if [[ $setting == "yes" ]]; then if [[ $setting == "yes" ]]; then
# Disable support_memory_compatibility # Disable support_memory_compatibility
#sed -i "s/${smc}=\"yes\"/${smc}=\"no\"/" "$synoinfo"
synosetkeyvalue "$synoinfo" "$smc" "no" synosetkeyvalue "$synoinfo" "$smc" "no"
setting="$(get_key_value "$synoinfo" $smc)" setting="$(get_key_value "$synoinfo" $smc)"
if [[ $setting == "no" ]]; then if [[ $setting == "no" ]]; then
echo -e "\nDisabled support memory compatibility." echo -e "\nDisabled support memory compatibility."
fi fi
elif [[ $setting == "no" ]]; then
echo -e "\nSupport memory compatibility already disabled."
fi fi
else else
if [[ $setting == "no" ]]; then if [[ $setting == "no" ]]; then
# Enable support_memory_compatibility # Enable support_memory_compatibility
#sed -i "s/${smc}=\"no\"/${smc}=\"yes\"/" "$synoinfo"
synosetkeyvalue "$synoinfo" "$smc" "yes" synosetkeyvalue "$synoinfo" "$smc" "yes"
setting="$(get_key_value "$synoinfo" $smc)" setting="$(get_key_value "$synoinfo" $smc)"
if [[ $setting == "yes" ]]; then if [[ $setting == "yes" ]]; then
echo -e "\nRe-enabled support memory compatibility." echo -e "\nRe-enabled support memory compatibility."
fi fi
elif [[ $setting == "yes" ]]; then
echo -e "\nSupport memory compatibility already enabled."
fi fi
fi fi
# Optioanlly set mem_max_mb to the amount of installed memory # Optionally set mem_max_mb to the amount of installed memory
if [[ $ram == "yes" ]]; then if [[ $ram == "yes" ]]; then
# Get total amount of installed memory # Get total amount of installed memory
IFS=$'\n' read -r -d '' -a array < <(dmidecode -t memory | grep -i 'size') IFS=$'\n' read -r -d '' -a array < <(dmidecode -t memory | grep -i 'size')
@ -948,7 +1030,9 @@ if [[ $ram == "yes" ]]; then
echo -e "\n${Error}ERROR${Off} Failed to change max memory!" echo -e "\n${Error}ERROR${Off} Failed to change max memory!"
fi fi
elif [[ $setting == "$ramtotal" ]]; then elif [[ $setting == "$ramtotal" ]]; then
echo -e "\nMax memory already set to $ramtotal MB." #echo -e "\nMax memory already set to $ramtotal MB."
ramgb=$((ramtotal / 1024))
echo -e "\nMax memory already set to $ramgb GB."
fi fi
fi fi
@ -966,7 +1050,6 @@ if [[ $m2 != "no" ]]; then
enabled="yes" enabled="yes"
elif [[ $setting == "no" ]]; then elif [[ $setting == "no" ]]; then
# Change support_m2_pool="no" to "yes" # Change support_m2_pool="no" to "yes"
#sed -i "s/${smp}=\"no\"/${smp}=\"yes\"/" "$synoinfo"
synosetkeyvalue "$synoinfo" "$smp" "yes" synosetkeyvalue "$synoinfo" "$smp" "yes"
enabled="yes" enabled="yes"
elif [[ $setting == "yes" ]]; then elif [[ $setting == "yes" ]]; then
@ -997,7 +1080,6 @@ if [[ $nodbupdate == "yes" ]]; then
disabled="yes" disabled="yes"
elif [[ $url != "127.0.0.1" ]]; then elif [[ $url != "127.0.0.1" ]]; then
# Edit drive_db_test_url= # Edit drive_db_test_url=
#sed -i "s/drive_db_test_url=.*/drive_db_test_url=\"127.0.0.1\"/" "$synoinfo" >/dev/null
synosetkeyvalue "$synoinfo" "$dtu" "127.0.0.1" synosetkeyvalue "$synoinfo" "$dtu" "127.0.0.1"
disabled="yes" disabled="yes"
fi fi
@ -1018,7 +1100,6 @@ else
#if [[ $url == "127.0.0.1" ]]; then #if [[ $url == "127.0.0.1" ]]; then
if [[ $url ]]; then if [[ $url ]]; then
# Delete "drive_db_test_url=127.0.0.1" line (inc. line break) # Delete "drive_db_test_url=127.0.0.1" line (inc. line break)
#sed -i "/drive_db_test_url=\"127.0.0.1\"/d" "/etc.defaults/synoinfo.conf"
sed -i "/drive_db_test_url=*/d" "/etc.defaults/synoinfo.conf" sed -i "/drive_db_test_url=*/d" "/etc.defaults/synoinfo.conf"
# Check if we re-enabled drive db auto updates # Check if we re-enabled drive db auto updates
@ -1039,7 +1120,8 @@ fi
# Show the changes # Show the changes
if [[ ${showedits,,} == "yes" ]]; then if [[ ${showedits,,} == "yes" ]]; then
getdbtype "$db1" if [[ ${#db1list[@]} -gt "0" ]]; then
getdbtype "${db1list[0]}"
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
@ -1049,27 +1131,19 @@ if [[ ${showedits,,} == "yes" ]]; then
fi fi
# HDDs/SSDs # HDDs/SSDs
if [[ ${#hdds[@]} -gt "0" ]]; then for i in "${!hdds[@]}"; do
num="0" hdmodel=$(printf "%s" "${hdds[i]}" | cut -d"," -f 1)
while [[ $num -lt "${#hdds[@]}" ]]; do
hdmodel=$(printf "%s" "${hdds[$num]}" | cut -d"," -f 1)
echo echo
jq . "$db1" | grep -A "$lines" "$hdmodel" jq . "${db1list[0]}" | grep -A "$lines" "$hdmodel"
num=$((num +1))
done done
fi
# NVMe drives # NVMe drives
if [[ ${#nvmes[@]} -gt "0" ]]; then for i in "${!nvmes[@]}"; do
num="0" hdmodel=$(printf "%s" "${nvmes[i]}" | cut -d"," -f 1)
while [[ $num -lt "${#nvmes[@]}" ]]; do
nvmemodel=$(printf "%s" "${nvmes[$num]}" | cut -d"," -f 1)
echo echo
jq . "$db1" | grep -A "$lines" "$nvmemodel" jq . "${db1list[0]}" | grep -A "$lines" "$hdmodel"
num=$((num +1))
done done
fi fi
fi fi
@ -1081,6 +1155,7 @@ if [[ -f /usr/syno/sbin/synostgdisk ]]; then # DSM 6.2.3 does not have synostgd
echo -e "\nDSM successfully checked disk compatibility." echo -e "\nDSM successfully checked disk compatibility."
else else
# Ignore DSM 6.2.4 as it returns 255 for "synostgdisk --check-all-disks-compatibility" # Ignore DSM 6.2.4 as it returns 255 for "synostgdisk --check-all-disks-compatibility"
# and DSM 6.2.3 and lower have no synostgdisk command
if [[ $dsm -gt "6" ]]; then if [[ $dsm -gt "6" ]]; then
echo -e "\nDSM ${Red}failed${Off} to check disk compatibility with exit code $status" echo -e "\nDSM ${Red}failed${Off} to check disk compatibility with exit code $status"
echo -e "\nYou may need to ${Cyan}reboot the Synology${Off} to see the changes." echo -e "\nYou may need to ${Cyan}reboot the Synology${Off} to see the changes."

Loading…
Cancel
Save