Browse Source

Update syno_hdd_db.sh

v3.1.59
pull/123/head
Dave Russell 3 years ago
committed by GitHub
parent
commit
811ebc3d86
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 68
      syno_hdd_db.sh

68
syno_hdd_db.sh

@ -30,6 +30,7 @@
# DONE # DONE
# Added enabling E10M20-T1, M2D20 and M2D18 for DS1821+, DS1621+ and DS1520+. # 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. # Fixed enabling E10M20-T1, M2D20 and M2D18 cards in models that don't officially support them.
# #
@ -37,6 +38,8 @@
# - If last memory socket was empty an invalid unit of bytes could be used. Issue #106 # - 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 # - 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
#
# #
# Minor bug fix for checking amount of installed memory. # Minor bug fix for checking amount of installed memory.
# #
@ -477,28 +480,28 @@ if ! printf "%s\n%s\n" "$tag" "$scriptver" |
url="https://github.com/$repo/archive/refs/tags/$tag.tar.gz" url="https://github.com/$repo/archive/refs/tags/$tag.tar.gz"
if ! curl -LJO -m 30 --connect-timeout 5 "$url"; if ! curl -LJO -m 30 --connect-timeout 5 "$url";
then then
echo -e "${Error}ERROR ${Off} Failed to download"\ echo -e "${Error}ERROR${Off} Failed to download"\
"$script-$shorttag.tar.gz!" "$script-$shorttag.tar.gz!"
syslog_set warn "$script $tag failed to download" syslog_set warn "$script $tag failed to download"
else else
if [[ -f /tmp/$script-$shorttag.tar.gz ]]; then if [[ -f /tmp/$script-$shorttag.tar.gz ]]; then
# Extract tar file to /tmp/<script-name> # Extract tar file to /tmp/<script-name>
if ! tar -xf "/tmp/$script-$shorttag.tar.gz" -C "/tmp"; then if ! tar -xf "/tmp/$script-$shorttag.tar.gz" -C "/tmp"; then
echo -e "${Error}ERROR ${Off} Failed to"\ echo -e "${Error}ERROR${Off} Failed to"\
"extract $script-$shorttag.tar.gz!" "extract $script-$shorttag.tar.gz!"
syslog_set warn "$script failed to extract $script-$shorttag.tar.gz!" syslog_set warn "$script failed to extract $script-$shorttag.tar.gz!"
else else
# Copy new script sh files to script location # Copy new script sh files to script location
if ! cp -p "/tmp/$script-$shorttag/"*.sh "$scriptpath"; then if ! cp -p "/tmp/$script-$shorttag/"*.sh "$scriptpath"; then
copyerr=1 copyerr=1
echo -e "${Error}ERROR ${Off} Failed to copy"\ echo -e "${Error}ERROR${Off} Failed to copy"\
"$script-$shorttag .sh file(s) to:\n $scriptpath" "$script-$shorttag .sh file(s) to:\n $scriptpath"
syslog_set warn "$script failed to copy $tag to script location" syslog_set warn "$script failed to copy $tag to script location"
else else
# Set permissions on script sh files # Set permissions on script sh files
if ! chmod 744 "$scriptpath/"*.sh ; then if ! chmod 744 "$scriptpath/"*.sh ; then
permerr=1 permerr=1
echo -e "${Error}ERROR ${Off} Failed to set permissions on:" echo -e "${Error}ERROR${Off} Failed to set permissions on:"
echo "$scriptpath *.sh file(s)" echo "$scriptpath *.sh file(s)"
syslog_set warn "$script failed to set permissions on $tag" syslog_set warn "$script failed to set permissions on $tag"
fi fi
@ -507,27 +510,27 @@ if ! printf "%s\n%s\n" "$tag" "$scriptver" |
# Copy new CHANGES.txt file to script location # Copy new CHANGES.txt file to script location
if ! cp -p "/tmp/$script-$shorttag/CHANGES.txt" "$scriptpath"; then if ! cp -p "/tmp/$script-$shorttag/CHANGES.txt" "$scriptpath"; then
if [[ $autoupdate != "yes" ]]; then copyerr=1; fi if [[ $autoupdate != "yes" ]]; then copyerr=1; fi
echo -e "${Error}ERROR ${Off} Failed to copy"\ echo -e "${Error}ERROR${Off} Failed to copy"\
"$script-$shorttag/CHANGES.txt to:\n $scriptpath" "$script-$shorttag/CHANGES.txt to:\n $scriptpath"
else else
# Set permissions on CHANGES.txt # Set permissions on CHANGES.txt
if ! chmod 744 "$scriptpath/CHANGES.txt"; then if ! chmod 744 "$scriptpath/CHANGES.txt"; then
if [[ $autoupdate != "yes" ]]; then permerr=1; fi if [[ $autoupdate != "yes" ]]; then permerr=1; fi
echo -e "${Error}ERROR ${Off} Failed to set permissions on:" echo -e "${Error}ERROR${Off} Failed to set permissions on:"
echo "$scriptpath/CHANGES.txt" echo "$scriptpath/CHANGES.txt"
fi fi
fi fi
# 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
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!"
syslog_set warn "$script update failed to delete tmp files" syslog_set warn "$script update failed to delete tmp files"
fi fi
# Delete extracted tmp files # Delete extracted tmp files
if ! rm -r "/tmp/$script-$shorttag"; then if ! rm -r "/tmp/$script-$shorttag"; then
echo -e "${Error}ERROR ${Off} Failed to delete"\ echo -e "${Error}ERROR${Off} Failed to delete"\
"downloaded /tmp/$script-$shorttag!" "downloaded /tmp/$script-$shorttag!"
syslog_set warn "$script update failed to delete tmp files" syslog_set warn "$script update failed to delete tmp files"
fi fi
@ -545,15 +548,15 @@ if ! printf "%s\n%s\n" "$tag" "$scriptver" |
fi fi
fi fi
else else
echo -e "${Error}ERROR ${Off}"\ echo -e "${Error}ERROR${Off}"\
"/tmp/$script-$shorttag.tar.gz not found!" "/tmp/$script-$shorttag.tar.gz not found!"
#ls /tmp | grep "$script" # debug #ls /tmp | grep "$script" # debug
syslog_set warn "/tmp/$script-$shorttag.tar.gz not found" syslog_set warn "/tmp/$script-$shorttag.tar.gz not found"
fi fi
fi fi
cd "$scriptpath" || echo -e "${Error}ERROR ${Off} Failed to cd to script location!" cd "$scriptpath" || echo -e "${Error}ERROR${Off} Failed to cd to script location!"
else else
echo -e "${Error}ERROR ${Off} Failed to cd to /tmp!" echo -e "${Error}ERROR${Off} Failed to cd to /tmp!"
syslog_set warn "$script update failed to cd to /tmp" syslog_set warn "$script update failed to cd to /tmp"
fi fi
fi fi
@ -971,14 +974,12 @@ backupdb(){
for i in "${!db1list[@]}"; do for i in "${!db1list[@]}"; do
backupdb "${db1list[i]}" ||{ backupdb "${db1list[i]}" ||{
ding ding
echo -e "${Error}ERROR 5${Off} Failed to backup $(basename -- "${db1list[i]}")!"
exit 5 exit 5
} }
done done
for i in "${!db2list[@]}"; do for i in "${!db2list[@]}"; do
backupdb "${db2list[i]}" ||{ backupdb "${db2list[i]}" ||{
ding ding
echo -e "${Error}ERROR 5${Off} Failed to backup $(basename -- "${db2list[i]}")!"
exit 5 # maybe don't exit for .db.new file exit 5 # maybe don't exit for .db.new file
} }
done done
@ -1153,6 +1154,8 @@ done
# DS1821+, DS1621+ and DS1520+ also need edited device tree blob file # DS1821+, DS1621+ and DS1520+ also need edited device tree blob file
# /etc.defaults/model.dtb # /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(){ enable_card(){
# $1 is the file # $1 is the file
@ -1170,7 +1173,7 @@ enable_card(){
if set_section_key_value "$1" "$2" "$modelname" yes; then if set_section_key_value "$1" "$2" "$modelname" yes; then
echo -e "Enabled ${Yellow}$3${Off} for ${Cyan}$modelname${Off}" >&2 echo -e "Enabled ${Yellow}$3${Off} for ${Cyan}$modelname${Off}" >&2
else else
echo -e "${Error}ERROR 5${Off} Failed to enable $3 for ${modelname}!" >&2 echo -e "${Error}ERROR 9${Off} Failed to enable $3 for ${modelname}!" >&2
fi fi
else else
echo -e "${Yellow}$3${Off} already enabled for ${Cyan}$modelname${Off}" >&2 echo -e "${Yellow}$3${Off} already enabled for ${Cyan}$modelname${Off}" >&2
@ -1182,9 +1185,10 @@ check_modeldtb(){
# $1 is E10M20-T1 or M2D20 or M2D18 or M2D17 # $1 is E10M20-T1 or M2D20 or M2D18 or M2D17
if [[ -f /etc.defaults/model.dtb ]]; then if [[ -f /etc.defaults/model.dtb ]]; then
if ! grep --text "$1" /etc.defaults/model.dtb >/dev/null; then if ! grep --text "$1" /etc.defaults/model.dtb >/dev/null; then
if [[ $modelname == "DS1821+" ]] ||\ if [[ $modelname == "DS1821+" ]] || [[ $modelname == "DS1621+" ]] ||\
[[ $modelname == "DS1621+" ]] ||\ [[ $modelname == "DS1520+" ]] || [[ $modelname == "RS822RP+" ]] ||\
[[ $modelname == "DS1520+" ]]; [[ $modelname == "RS822+" ]] || [[ $modelname == "RS1221RP+" ]] ||\
[[ $modelname == "RS1221+" ]];
then then
echo "" >&2 echo "" >&2
if [[ -f ./dtb/${modelname}_model.dtb ]]; then if [[ -f ./dtb/${modelname}_model.dtb ]]; then
@ -1201,28 +1205,28 @@ check_modeldtb(){
url=${repo}/raw/main/dtb/${modelname}_model.dtb url=${repo}/raw/main/dtb/${modelname}_model.dtb
curl -LJO -m 30 --connect-timeout 5 "$url" curl -LJO -m 30 --connect-timeout 5 "$url"
echo "" >&2 echo "" >&2
cd "$scriptpath" || echo -e "${Error}ERROR ${Off} Failed to cd to script location!" cd "$scriptpath" || echo -e "${Error}ERROR${Off} Failed to cd to script location!"
else else
echo -e "${Error}ERROR ${Off} /var/services/tmp does not exist!" >&2 echo -e "${Error}ERROR${Off} /var/services/tmp does not exist!" >&2
fi fi
# Check we actually downloaded the file # Check we actually downloaded the file
if [[ -f /var/services/tmp/${modelname}_model.dtb ]]; then if [[ -f /var/services/tmp/${modelname}_model.dtb ]]; then
blob="/var/services/tmp/${modelname}_model.dtb" blob="/var/services/tmp/${modelname}_model.dtb"
else else
echo -e "${Error}ERROR ${Off} Failed to download ${modelname}_model.dtb!" >&2 echo -e "${Error}ERROR${Off} Failed to download ${modelname}_model.dtb!" >&2
fi fi
fi fi
if [[ -f $blob ]]; then if [[ -f $blob ]]; then
# Backup model.dtb # Backup model.dtb
if ! backupdb "/etc.defaults/model.dtb"; then if ! backupdb "/etc.defaults/model.dtb"; then
echo -e "${Error}ERROR ${Off} Failed to backup /etc.defaults/model.dtb!" >&2 echo -e "${Error}ERROR${Off} Failed to backup /etc.defaults/model.dtb!" >&2
else else
# Move and rename downloaded model.dtb # Move and rename downloaded model.dtb
if mv "$blob" "/etc.defaults/model.dtb"; then if mv "$blob" "/etc.defaults/model.dtb"; then
echo -e "Enabled ${Yellow}$1${Off} in ${Cyan}model.dtb${Off}" >&2 echo -e "Enabled ${Yellow}$1${Off} in ${Cyan}model.dtb${Off}" >&2
else else
echo -e "${Error}ERROR ${Off} Failed to add support for ${1}" >&2 echo -e "${Error}ERROR${Off} Failed to add support for ${1}" >&2
fi fi
# Fix permissions if needed # Fix permissions if needed
@ -1232,8 +1236,8 @@ check_modeldtb(){
fi fi
fi fi
else else
#echo -e "${Error}ERROR ${Off} Missing file ${modelname}_model.dtb" >&2 #echo -e "${Error}ERROR${Off} Missing file ${modelname}_model.dtb" >&2
echo -e "${Error}ERROR ${Off} Missing file $blob" >&2 echo -e "${Error}ERROR${Off} Missing file $blob" >&2
fi fi
else else
echo -e "\n${Cyan}Contact 007revad to get an edited model.dtb file for your model.${Off}" >&2 echo -e "\n${Cyan}Contact 007revad to get an edited model.dtb file for your model.${Off}" >&2
@ -1376,6 +1380,7 @@ if [[ $dsm -gt "6" ]]; then # DSM 6 as has no /proc/meminfo
fi fi
# Set mem_max_mb to the amount of installed memory # Set mem_max_mb to the amount of installed memory
setting="$(get_key_value $synoinfo mem_max_mb)" setting="$(get_key_value $synoinfo mem_max_mb)"
settingbak="$(get_key_value ${synoinfo}.bak mem_max_mb)" # GitHub issue #107
if [[ $ramtotal =~ ^[0-9]+$ ]]; then # Check $ramtotal is numeric if [[ $ramtotal =~ ^[0-9]+$ ]]; then # Check $ramtotal is numeric
if [[ $ramtotal -gt "$setting" ]]; then if [[ $ramtotal -gt "$setting" ]]; then
synosetkeyvalue "$synoinfo" mem_max_mb "$ramtotal" synosetkeyvalue "$synoinfo" mem_max_mb "$ramtotal"
@ -1388,6 +1393,21 @@ if [[ $dsm -gt "6" ]]; then # DSM 6 as has no /proc/meminfo
else else
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 -gt "$ramtotal" ]] && [[ $setting -gt "$settingbak" ]]; # GitHub issue #107
then
# Fix setting is greater than both ramtotal and default in syninfo.conf.bak
synosetkeyvalue "$synoinfo" mem_max_mb "$settingbak"
# Check we restored mem_max_mb
setting="$(get_key_value $synoinfo mem_max_mb)"
if [[ $settingbak == "$setting" ]]; then
#echo -e "\nSet max memory to $ramtotal MB."
ramgb=$((ramtotal / 1024))
echo -e "\nRestored max memory to $ramtotal GB."
else
echo -e "\n${Error}ERROR${Off} Failed to restore max memory!"
fi
elif [[ $ramtotal == "$setting" ]]; then elif [[ $ramtotal == "$setting" ]]; then
#echo -e "\nMax memory already set to $ramtotal MB." #echo -e "\nMax memory already set to $ramtotal MB."
ramgb=$((ramtotal / 1024)) ramgb=$((ramtotal / 1024))

Loading…
Cancel
Save