Browse Source

Merge branch 'develop' of https://github.com/007revad/Synology_HDD_db into develop

develop
007revad 3 years ago
parent
commit
492916cf98
  1. 23
      CHANGES.txt
  2. 86
      README.md
  3. BIN
      images/how_to_download.png
  4. BIN
      images/syno_hdd_db1.png
  5. BIN
      images/syno_hdd_db_help.png
  6. 370
      syno_hdd_db.sh

23
CHANGES.txt

@ -1,11 +1,24 @@
v1.1.15 v2.2.18
- Added support for M.2 drives on a PCI card (M2Dxx and E10G18-T1 and future models). - Minor shell output formatting fix.
- 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). v1.2.17
- Added disable support memory compatibility option --ram or -r
v1.2.16
- Changed to show the script version, Synology model and DSM version on each run to make it easier to debug any user's issues.
v1.2.15
- 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 card's db files (supports M2Dxx and E10M20-T1 and future models with similar model names).
- Improved flags/options checking and added usage help (-h or --help) and version info (-v or --version).
- 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 - 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. - 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). - Added removal of " 00Y" from end of Samsung/Lenovo SSDs to fix issue #13.
- Changed Synology NAS model detection to be more reliable (for models that came in different variations and report extra text after model). issue #2 and issue #10
- Changed checking drive_db_test_url setting to be more durable. - Changed checking drive_db_test_url setting to be more durable.
- Fixed bug where removable drives were being added to the drive database.
- Fixed bug where "M.2 volume support already enabled" message appeared when NAS had no M.2 drives.
v1.1.14 v1.1.14
- Minor bug fix. - Minor bug fix.

86
README.md

@ -0,0 +1,86 @@
# Synology HDD db
<a href="https://github.com/007revad/Synology_HDD_db/releases"><img src="https://img.shields.io/github/release/007revad/Synology_HDD_db.svg"></a>
<a href="https://hits.seeyoufarm.com"><img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2F007revad%2FSynology_HDD_db&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false"/></a>
### Description
Add your SATA or SAS HDDs and SSDs plus SATA and NVMe M.2 drives to your Synology's compatible drive databases, including your M.2 card and Expansion Unit databases.
The script works in DSM 7 and DSM 6.
#### What the script does:
* Gets the Synology NAS model and DSM version (so it knows which db files to edit).
* Gets a list of the HDD, SSD, SAS and NVMe drives installed in your Synology NAS.
* Gets each drive's model number and firmware version.
* Backs up the database files if there is no backup already.
* Checks if each drive is already in the Synology's compatible-drive database.
* Adds any missing drives to the Synology's compatible-drive database.
* Prevents DSM auto updating the drive database.
* Optionally disable DSM's "support_disk_compatibility".
* Optionally disable DSM's "support_memory_compatibility".
* Checks that M.2 volume support is enabled (on supported models).
* Makes DSM recheck disk compatibility so rebooting is not needed (DSM 7 only).
* Reminds you that you may need to reboot the Synology after running the script (DSM 6 only).
* Checks if there is a newer version of this script and offers to download it for you.
* The new version available messages time out so they don't prevent the script running if it is scheduled to run unattended.
**Planned updates:**
* Allow unsupported M.2 drives for use as volumes in DSM 7.2 (for models that supported M.2 volumes).
### Download the script
See <a href=images/how_to_download.png/>How to download the script</a> for the easiest way to download the script.
### When to run the script
You would need to re-run the script after a DSM update. If you have DSM set to auto update the best option is to run the script every time the Synology boots, and the best way to do that is to setup a scheduled task to run the the script at boot-up.
**Note:** For DSM 6, after you first run the script you may need to reboot the Synology to see the effect of the changes.
### Options when running the script
There are optional flags you can use when running the script:
* --showedits or -s to show you the changes it made to the Synology's compatible-drive database.
* --noupdate or -n to prevent DSM updating the compatible drive databases.
* --m2 or -m to prevent processing M.2 drives.
* --force or -f to disable "support_disk_compatibility". This should only be needed if any of your drives weren't detected.
* If you run the script without --force or -f it will re-eanble "support_disk_compatibility".
* --ram or -r to disable "support_memory_compatibility".
* If you run the script without --ram or -r it will re-eanble "support_memory_compatibility".
<p align="leftr"><img src="images/syno_hdd_db_help.png"></p>
### Scheduling the script in Synology's Task Scheduler
See <a href=how_to_schedule.md/>How to schedule a script in Synology Task Manager</a>
### Running the script via SSH
You run the script in a shell with sudo or as root.
```YAML
sudo /path-to-script/syno_hdd_db.sh
```
**Note:** Replace /path-to-script/ with the actual path to the script on your Synology.
<p align="leftr"><img src="images/syno_hdd_db1.png"></p>
If you run the script with the -showedits flag it will show you the changes it made to the Synology's compatible-drive database. Obviously this is only useful if you run the script in a shell.
```YAML
sudo /path-to-script/syno_hdd_db.sh -showedits
```
**Note:** Replace /path-to-script/ with the actual path to the script on your Synology.
<p align="leftr"><img src="images/syno_hdd_db.png"></p>
**Credits**
- The idea for this script came from a comment made by Empyrealist on the Synology subreddit.
- Thanks for the assistance from Alex_of_Chaos on the Synology subreddit.
- Thanks to dwabraxus and aferende for help detecting connected expansion units.
- Thanks to bartoque on the Synology subreddit for the tip on making the script download the latest release from github.

BIN
images/how_to_download.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

BIN
images/syno_hdd_db1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
images/syno_hdd_db_help.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

370
syno_hdd_db.sh

@ -3,7 +3,7 @@
#-------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------
# 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/
# Tested on DSM 7.1.1 and DSM 6.2.4 # Tested on DSM 7.2 beta, 7.1.1 and DSM 6.2.4
# #
# Easiest solution: # Easiest solution:
# Edit /etc.defaults/synoinfo.conf and change support_disk_compatibility="yes" to "no" and reboot. # Edit /etc.defaults/synoinfo.conf and change support_disk_compatibility="yes" to "no" and reboot.
@ -25,15 +25,15 @@
# TODO # TODO
# Bypass M.2 volume lock for unsupported M.2 drives. # Bypass M.2 volume lock for unsupported M.2 drives.
# #
# Detect if expansion unit(s) connected and get model(s) and edit expansion unit db files.
# Or add support for specifying user's expansion unit model(s) as arguments.
# Or maybe use the shotgun approach and update all expansion unit db files.
#
# Maybe also edit the other disk compatibility db in synoboot, used during boot time. # 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. # It's also parsed and checked and probably in some cases it could be more critical to patch that one instead.
# DONE # DONE
# Added support for M.2 drives on a PCI card (M2Dxx and E10G18-T1 and future models). # 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. # Improved flags/options checking and added usage help.
# #
@ -47,6 +47,12 @@
# #
# Changed checking drive_db_test_url setting to be more durable. # 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 check that M.2 volume support is enabled (on supported models).
# #
@ -78,10 +84,11 @@
# Optionally disable "support_disk_compatibility". # Optionally disable "support_disk_compatibility".
scriptver="v1.1.15" scriptver="v1.2.18"
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'
@ -118,18 +125,17 @@ exit 0
scriptversion(){ scriptversion(){
cat <<EOF cat <<EOF
$script $scriptver $script $scriptver - by 007revad
by 007revad
https://github.com/$repo See https://github.com/$repo
EOF EOF
exit 0 exit 0
} }
# Check for flags with getopt # Check for flags with getopt
options="$(getopt -o abcdefghijklmnopqrstuvwxyz0123456789 -a \ if options="$(getopt -o abcdefghijklmnopqrstuvwxyz0123456789 -a \
-l showedits,noupdate,m2,force,ram,help,version -- "$@")" -l showedits,noupdate,m2,force,ram,help,version -- "$@")"; then
if [[ $? -eq "0" ]]; then
eval set -- "$options" eval set -- "$options"
while true; do while true; do
case "${1,,}" in case "${1,,}" in
@ -145,8 +151,8 @@ if [[ $? -eq "0" ]]; then
-f|--force) # Disable "support_disk_compatibility" -f|--force) # Disable "support_disk_compatibility"
force=yes force=yes
;; ;;
-r|--ram) # Include memory compatibility -r|--ram) # Disable "support_memory_compatibility"
ram=yes # for future use ram=yes
;; ;;
-h|--help) # Show usage options -h|--help) # Show usage options
usage usage
@ -181,22 +187,35 @@ if [[ $dsm -gt "6" ]]; then
fi fi
# Get Synology model # Get Synology model
model=$(cat /proc/sys/kernel/syno_hw_version) # not always the actual model number
modeltype=$(printf "%s" "$model" | sed 's/[0-9].*//') # DS, RS etc # 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)
unique=$(get_key_value /etc/synoinfo.conf unique | cut -d'_' -f3) # 920+ etc model=$(cat /proc/sys/kernel/syno_hw_version)
# Remove extra text from end, like DS213pv10-j and DS1817+-j
#[[ $model =~ ([0-9]{3,}) ]] && modelnum=${BASH_REMATCH[1]}
[[ $model =~ ([0-9]{3,}(RP\+|RPxs|RP|\+II|xsII|xs\+|xs|\+|j|slim|play|se|air|D)?) ]] &&\
modelnum=${BASH_REMATCH[1]}
if [[ $modelnum != "$unique" ]]; then # Show script version
model="$modeltype$unique" echo "$script $scriptver"
fi #echo "github.com/$repo"
model=${model,,} # convert to lower case # Show NAS info
productversion=$(get_key_value /etc.defaults/VERSION productversion)
buildphase=$(get_key_value /etc.defaults/VERSION buildphase)
if [[ $buildphase == GM ]]; then buildphase=""; fi
echo "$model DSM $productversion $buildphase"
echo ""
# Convert model to lower case
model=${model,,}
# Check for dodgy characters after model number
if [[ $model =~ 'pv10-j'$ ]]; then # GitHub issue #10
model=${model%??????}+ # replace last 6 chars with +
elif [[ $model =~ '-j'$ ]]; then # GitHub issue #2
model=${model%??} # remove last 2 chars
fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -260,18 +279,34 @@ 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.
fixdrivemodel(){
# Remove " 00Y" from end of Samsung/Lenovo SSDs
# To fix issue #13
if [[ $1 =~ MZ.*" 00Y" ]]; then
hdmodel=$(printf "%s" "$1" | sed 's/ 00Y.*//')
fi
}
getdriveinfo() { getdriveinfo() {
# Get drive model and firmware version # Skip removable drives (USB drives)
hdmodel=$(cat "$1/device/model") removable=$(cat "$1/removable")
hdmodel=$(printf "%s" "$hdmodel" | xargs) # trim leading and trailing white space if [[ $removable == "0" ]]; then
# Get drive model and firmware version
hdmodel=$(cat "$1/device/model")
hdmodel=$(printf "%s" "$hdmodel" | xargs) # trim leading and trailing white space
# Fix dodgy model numbers
fixdrivemodel "$hdmodel"
fwrev=$(cat "$1/device/rev") fwrev=$(cat "$1/device/rev")
fwrev=$(printf "%s" "$fwrev" | xargs) # trim leading and trailing white space fwrev=$(printf "%s" "$fwrev" | xargs) # trim leading and trailing white space
if [[ $hdmodel ]] && [[ $fwrev ]]; then if [[ $hdmodel ]] && [[ $fwrev ]]; then
hdlist+=("${hdmodel},${fwrev}") hdlist+=("${hdmodel},${fwrev}")
fi
fi fi
} }
@ -291,16 +326,18 @@ getm2info() {
} }
getcardmodel() { getcardmodel() {
# Get M.2 card model # Get M.2 card model (if M.2 drives found)
cardmodel=$(synodisk --m2-card-model-get "$1") if [[ ${#nvmelist[@]} -gt "0" ]]; then
if [[ $cardmodel =~ M2D[0-9][0-9] ]]; then cardmodel=$(synodisk --m2-card-model-get "$1")
# M2 adaptor card if [[ $cardmodel =~ M2D[0-9][0-9] ]]; then
m2carddblist+=("${model}_${cardmodel,,}${version}.db") # M.2 card's db file # M2 adaptor card
m2cardlist+=("$cardmodel") # M.2 card m2carddblist+=("${model}_${cardmodel,,}${version}.db") # M.2 card's db file
elif [[ $cardmodel =~ E[0-9][0-9]+M.+ ]]; then m2cardlist+=("$cardmodel") # M.2 card
# Ethernet + M2 adaptor card elif [[ $cardmodel =~ E[0-9][0-9]+M.+ ]]; then
m2carddblist+=("${model}_${cardmodel,,}${version}.db") # M.2 card's db file # Ethernet + M2 adaptor card
m2cardlist+=("$cardmodel") # M.2 card m2carddblist+=("${model}_${cardmodel,,}${version}.db") # M.2 card's db file
m2cardlist+=("$cardmodel") # M.2 card
fi
fi fi
} }
@ -342,21 +379,12 @@ for d in /sys/block/*; do
done done
sortarray(){
# Sort $1 array into new $2 array to remove duplicates
local -n inarray=$1
outarray=()
if [[ ${#inarray[@]} -gt "0" ]]; then
while IFS= read -r -d '' x; do
outarray+=("$x")
done < <(printf "%s\0" "${inarray[@]}" | sort -uz)
fi
}
# Sort hdlist array into new hdds array to remove duplicates # Sort hdlist array into new hdds array to remove duplicates
sortarray "hdlist" if [[ ${#hdlist[@]} -gt "0" ]]; then
hdds=${outarray[*]} while IFS= read -r -d '' x; do
hdds+=("$x")
done < <(printf "%s\0" "${hdlist[@]}" | sort -uz)
fi
# Check hdds array isn't empty # Check hdds array isn't empty
if [[ ${#hdds[@]} -eq "0" ]]; then if [[ ${#hdds[@]} -eq "0" ]]; then
@ -373,34 +401,44 @@ 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 [[ $m2 != "no" ]]; then
if [[ $m2 != "no" ]]; then if [[ ${#nvmes[@]} -eq "0" ]]; then
echo -e "No M.2 drives found\n" echo -e "No M.2 drives found\n"
else
m2exists="yes"
echo "M.2 drive models found: ${#nvmes[@]}"
num="0"
while [[ $num -lt "${#nvmes[@]}" ]]; do
echo "${nvmes[num]}"
num=$((num +1))
done
echo
fi fi
else
echo "M.2 drive models found: ${#nvmes[@]}"
num="0"
while [[ $num -lt "${#nvmes[@]}" ]]; do
echo "${nvmes[num]}"
num=$((num +1))
done
echo
fi 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
@ -414,6 +452,36 @@ if [[ ${#m2cards[@]} -gt "0" ]]; then
fi fi
# Expansion units
# Get list of connected expansion units (aka eunit/ebox)
path="/var/log/diskprediction"
# shellcheck disable=SC2012
file=$(ls $path | tail -n1)
# shellcheck disable=SC2207
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
if [[ ${#eunitlist[@]} -gt "0" ]]; then
while IFS= read -r -d '' x; do
eunits+=("$x")
done < <(printf "%s\0" "${eunitlist[@]}" | sort -uz)
fi
# Check eunits array isn't empty
if [[ ${#eunits[@]} -eq "0" ]]; then
echo -e "No Expansion Units found\n"
else
#eunitexists="yes"
echo "Expansion Unit models found: ${#eunits[@]}"
num="0"
while [[ $num -lt "${#eunits[@]}" ]]; do
echo "${eunits[num]}"
num=$((num +1))
done
echo
fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Check databases and add our drives if needed # Check databases and add our drives if needed
@ -429,27 +497,32 @@ if [[ ! -f "$db1" ]]; then echo -e "${Error}ERROR 3${Off} $db1 not found!" && ex
# new installs don't have a .db.new file # new installs don't have a .db.new file
# Detect drive db type getdbtype(){
if grep -F '{"disk_compatbility_info":' "$db1" >/dev/null; then # Detect drive db type
# DSM 7 drive db files start with {"disk_compatbility_info": if grep -F '{"disk_compatbility_info":' "$1" >/dev/null; then
dbtype=7 # DSM 7 drive db files start with {"disk_compatbility_info":
elif grep -F '{"success":1,"list":[' "$db1" >/dev/null; then dbtype=7
# DSM 6 drive db files start with {"success":1,"list":[ elif grep -F '{"success":1,"list":[' "$1" >/dev/null; then
dbtype=6 # DSM 6 drive db files start with {"success":1,"list":[
else dbtype=6
echo -e "${Error}ERROR${Off} Unknown database type $(basename -- "${db1}")!" else
exit 7 echo -e "${Error}ERROR${Off} Unknown database type $(basename -- "${1}")!" >&2
fi dbtype=1
#echo "dbtype: $dbtype" # debug fi
#echo "db type: $dbtype" >&2 # debug
}
backupdb() { backupdb() {
# Backup database file if needed # Backup database file if needed
if [[ ! -f "$1.bak" ]]; then if [[ ! -f "$1.bak" ]]; then
if [[ $(basename "$1") == "synoinfo.conf" ]]; then
echo "" >&2
fi
if cp "$1" "$1.bak"; then if cp "$1" "$1.bak"; then
echo -e "\nBacked up $(basename -- "${1}") database.\n" echo -e "Backed up $(basename -- "${1}")" >&2
else else
echo -e "${Error}ERROR 5${Off} Failed to backup $(basename -- "${1}")!" echo -e "${Error}ERROR 5${Off} Failed to backup $(basename -- "${1}")!" >&2
return 1 return 1
fi fi
fi fi
@ -459,9 +532,6 @@ backupdb() {
# Backup host database file if needed # Backup host database file if needed
backupdb "$db1" || exit 5 backupdb "$db1" || exit 5
# Backup synoinfo.conf if needed
backupdb "$synoinfo" || exit 9
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Edit db files # Edit db files
@ -470,14 +540,17 @@ updatedb() {
hdmodel=$(printf "%s" "$1" | cut -d"," -f 1) hdmodel=$(printf "%s" "$1" | cut -d"," -f 1)
fwrev=$(printf "%s" "$1" | cut -d"," -f 2) fwrev=$(printf "%s" "$1" | cut -d"," -f 2)
#echo arg1 "$1" # debug #echo arg1 "$1" >&2 # debug
#echo arg2 "$2" # debug #echo arg2 "$2" >&2 # debug
#echo hdmodel "$hdmodel" # debug #echo hdmodel "$hdmodel" >&2 # debug
#echo fwrev "$fwrev" # debug #echo fwrev "$fwrev" >&2 # debug
if grep "$hdmodel" "$2" >/dev/null; then if grep "$hdmodel" "$2" >/dev/null; then
echo -e "${Yellow}$hdmodel${Off} already exists in ${Cyan}$(basename -- "$2")${Off}" echo -e "${Yellow}$hdmodel${Off} already exists in ${Cyan}$(basename -- "$2")${Off}" >&2
else else
# Check if db file is new or old style
getdbtype "$2"
if [[ $dbtype -gt "6" ]];then if [[ $dbtype -gt "6" ]];then
# Don't need to add firmware version? # Don't need to add firmware version?
fwstrng=\"$fwrev\" fwstrng=\"$fwrev\"
@ -503,7 +576,7 @@ updatedb() {
echo -e "\n${Error}ERROR 6${Off} Failed to update v7 $(basename -- "$2")${Off}" echo -e "\n${Error}ERROR 6${Off} Failed to update v7 $(basename -- "$2")${Off}"
exit 6 exit 6
fi fi
else elif [[ $dbtype -eq "6" ]];then
# example: # example:
# {"model":"WD60EFRX-68MYMN1","firmware":"82.00A82","rec_intvl":[1]}, # {"model":"WD60EFRX-68MYMN1","firmware":"82.00A82","rec_intvl":[1]},
# Don't need to add firmware version? # Don't need to add firmware version?
@ -512,9 +585,9 @@ updatedb() {
# {"success":1,"list":[ # {"success":1,"list":[
startstring="{\"success\":1,\"list\":\[" startstring="{\"success\":1,\"list\":\["
#echo "$startstring" # debug #echo "$startstring" >&2 # debug
#echo "$string" # debug #echo "$string" >&2 # debug
#echo # 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]},
@ -529,7 +602,7 @@ updatedb() {
fi fi
else else
echo -e "\n${Error}ERROR 8${Off} Failed to update $(basename -- "$2")${Off}" echo -e "\n${Error}ERROR 8${Off} Failed to update $(basename -- "$2")${Off}" >&2
exit 8 exit 8
fi fi
fi fi
@ -543,6 +616,22 @@ while [[ $num -lt "${#hdds[@]}" ]]; do
if [[ -f "$db2" ]]; then if [[ -f "$db2" ]]; then
updatedb "${hdds[$num]}" "$db2" updatedb "${hdds[$num]}" "$db2"
fi fi
#------------------------------------------------
# Expansion Units
num2="0"
while [[ $num2 -lt "${#eunits[@]}" ]]; do
eudb="${dbpath}${eunits[$num2],,}${version}.db"
if [[ -f "$eudb" ]];then
backupdb "$eudb" &&\
updatedb "${hdds[$num]}" "$eudb"
else
echo -e "${Error}ERROR 11${Off} $eudb not found!"
fi
num2=$((num2 +1))
done
#------------------------------------------------
num=$((num +1)) num=$((num +1))
done done
@ -575,6 +664,9 @@ done
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Edit /etc.defaults/synoinfo.conf # Edit /etc.defaults/synoinfo.conf
# Backup synoinfo.conf if needed
backupdb "$synoinfo" || exit 9
# Optionally disable "support_disk_compatibility" # Optionally disable "support_disk_compatibility"
sdc=support_disk_compatibility sdc=support_disk_compatibility
setting="$(get_key_value $synoinfo $sdc)" setting="$(get_key_value $synoinfo $sdc)"
@ -599,29 +691,58 @@ else
fi fi
# Check m2 volume support enabled # Optionally disable "support_memory_compatibility"
smp=support_m2_pool smc=support_memory_compatibility
setting="$(get_key_value $synoinfo ${smp})" setting="$(get_key_value $synoinfo $smc)"
enabled="" if [[ $ram == "yes" ]]; then
if [[ ! $setting ]]; then if [[ $setting == "yes" ]]; then
# Add support_m2_pool"yes" # Disable support_memory_compatibility
echo 'support_m2_pool="yes"' >> "$synoinfo" sed -i "s/${smc}=\"yes\"/${smc}=\"no\"/" "$synoinfo"
enabled="yes" setting="$(get_key_value "$synoinfo" $smc)"
elif [[ $setting == "no" ]]; then if [[ $setting == "no" ]]; then
# Change support_m2_pool"no" to "yes" echo -e "\nDisabled support memory compatibility."
sed -i "s/${smp}=\"no\"/${smp}=\"yes\"/" "$synoinfo" fi
enabled="yes" fi
elif [[ $setting == "yes" ]]; then else
echo -e "\nM.2 volume support already enabled." if [[ $setting == "no" ]]; then
# Enable support_memory_compatibility
sed -i "s/${smc}=\"no\"/${smc}=\"yes\"/" "$synoinfo"
setting="$(get_key_value "$synoinfo" $smc)"
if [[ $setting == "yes" ]]; then
echo -e "\nRe-enabled support memory compatibility."
fi
fi
fi fi
# Check if we enabled m2 volume support
setting="$(get_key_value $synoinfo ${smp})" # Enable m2 volume support
if [[ $enabled == "yes" ]]; then if [[ $m2 != "no" ]]; then
if [[ $setting == "yes" ]]; then if [[ $m2exists == "yes" ]]; then
echo -e "\nEnabled M.2 volume support." # Check if m2 volume support is enabled
else smp=support_m2_pool
echo -e "${Error}ERROR${Off} Failed to enable m2 volume support!" setting="$(get_key_value $synoinfo ${smp})"
enabled=""
if [[ ! $setting ]]; then
# Add support_m2_pool"yes"
echo 'support_m2_pool="yes"' >> "$synoinfo"
enabled="yes"
elif [[ $setting == "no" ]]; then
# Change support_m2_pool"no" to "yes"
sed -i "s/${smp}=\"no\"/${smp}=\"yes\"/" "$synoinfo"
enabled="yes"
elif [[ $setting == "yes" ]]; then
echo -e "\nM.2 volume support already enabled."
fi
# Check if we enabled m2 volume support
setting="$(get_key_value $synoinfo ${smp})"
if [[ $enabled == "yes" ]]; then
if [[ $setting == "yes" ]]; then
echo -e "\nEnabled M.2 volume support."
else
echo -e "\n${Error}ERROR${Off} Failed to enable m2 volume support!"
fi
fi
fi fi
fi fi
@ -647,7 +768,7 @@ if [[ $nodbupdate == "yes" ]]; then
if [[ $url == "127.0.0.1" ]]; then if [[ $url == "127.0.0.1" ]]; then
echo -e "\nDisabled drive db auto updates." echo -e "\nDisabled drive db auto updates."
else else
echo -e "${Error}ERROR${Off} Failed to disable drive db auto updates!" echo -e "\n${Error}ERROR${Off} Failed to disable drive db auto updates!"
fi fi
fi fi
else else
@ -673,6 +794,7 @@ fi
# Show the changes # Show the changes
if [[ ${showedits,,} == "yes" ]]; then if [[ ${showedits,,} == "yes" ]]; then
getdbtype "$db1"
if [[ $dbtype -gt "6" ]];then if [[ $dbtype -gt "6" ]];then
# Show last 12 lines per drive + 4 # Show last 12 lines per drive + 4
lines=$(((db1Edits *12) +4)) lines=$(((db1Edits *12) +4))
@ -683,7 +805,7 @@ if [[ ${showedits,,} == "yes" ]]; then
echo -e "\nChanges to ${Cyan}$(basename -- "$db2")${Off}" echo -e "\nChanges to ${Cyan}$(basename -- "$db2")${Off}"
jq . "$db2" | tail -n "$lines" jq . "$db2" | tail -n "$lines"
fi fi
else elif [[ $dbtype -eq "6" ]];then
# Show first 8 lines per drive + 2 # Show first 8 lines per drive + 2
lines=$(((db1Edits *8) +2)) lines=$(((db1Edits *8) +2))
if [[ $db1Edits -gt "0" ]]; then if [[ $db1Edits -gt "0" ]]; then

Loading…
Cancel
Save