Compare commits

...

3 Commits

Author SHA1 Message Date
Dave Russell 4bae864b3d
Fix issue number for XPE temperature bug 2 weeks ago
007revad 8111e099ae v3.6.126 2 weeks ago
007revad 2da9c19a7b v3.6.126 2 weeks ago
  1. 8
      CHANGES.txt
  2. 98
      syno_hdd_db.sh

8
CHANGES.txt

@ -1,3 +1,11 @@
v3.6.126
- Changed to a more reliable way of getting the NAS model name.
- Changed to keep db file backups up to date.
- If a DSM update, or the user, has updated the drive databases the old db file backups are replaced with new backups of the unedited db files.
- Bug fix for db files with a space in their name, like "rxd1219sas module_v7.db".
- Bug fix for restore mode failing to restore E10M20-T1 nic support on NAS models that don't officially support the E10M20-T1.
- Bug fix for XPE not showing drive's correct temperature. Issue #585
v3.6.125
- Bug fix for missing lvs and pvs errors for 1 bay NAS (that don't have LVM).

98
syno_hdd_db.sh

@ -29,7 +29,7 @@
# /var/packages/StorageManager/target/ui/storage_panel.js
scriptver="v3.6.125"
scriptver="v3.6.126"
script=Synology_HDD_db
repo="007revad/Synology_HDD_db"
scriptname=syno_hdd_db
@ -282,8 +282,9 @@ minor=$(/usr/syno/bin/synogetkeyvalue /etc.defaults/VERSION minorversion)
dsmversion="$major$minor"
# Get Synology model
model=$(cat /proc/sys/kernel/syno_hw_version)
modelname="$model"
#model=$(cat /proc/sys/kernel/syno_hw_version)
#modelname="$model"
modelname=$(/usr/syno/bin/synogetkeyvalue /etc.defaults/synoinfo.conf upnpmodelname)
# Get CPU platform_name
#platform_name=$(/usr/syno/bin/synogetkeyvalue /etc.defaults/synoinfo.conf platform_name)
@ -305,22 +306,24 @@ smallfixnumber=$(/usr/syno/bin/synogetkeyvalue /etc.defaults/VERSION smallfixnum
# Show DSM full version and model
if [[ $buildphase == GM ]]; then buildphase=""; fi
if [[ $smallfixnumber -gt "0" ]]; then smallfix="-$smallfixnumber"; fi
echo "$model $arch DSM $productversion-$buildnumber$smallfix $buildphase"
#echo "$model $arch DSM $productversion-$buildnumber$smallfix $buildphase"
echo "$modelname $arch DSM $productversion-$buildnumber$smallfix $buildphase"
# Convert model to lower case
model=${model,,}
#model=${model,,}
model=${modelname,,}
# Check for dodgy characters after model number
if [[ $model =~ 'pv10-j'$ ]]; then # GitHub issue #10
modelname=${modelname%??????}+ # replace last 6 chars with +
model=${model%??????}+ # replace last 6 chars with +
echo -e "\nUsing model: $model"
elif [[ $model =~ '-j'$ ]]; then # GitHub issue #2
modelname=${modelname%??} # remove last 2 chars
model=${model%??} # remove last 2 chars
echo -e "\nUsing model: $model"
fi
#if [[ $model =~ 'pv10-j'$ ]]; then # GitHub issue #10
# modelname=${modelname%??????}+ # replace last 6 chars with +
# model=${model%??????}+ # replace last 6 chars with +
# echo -e "\nUsing model: $model"
#elif [[ $model =~ '-j'$ ]]; then # GitHub issue #2
# modelname=${modelname%??} # remove last 2 chars
# model=${model%??} # remove last 2 chars
# echo -e "\nUsing model: $model"
#fi
# Get StorageManager version
storagemgrver=$(/usr/syno/bin/synopkg version StorageManager)
@ -631,6 +634,7 @@ get_script_vol() {
fi
}
if which lvm >/dev/null; then
# Single bay Synology NAS don't have lvm
get_script_vol # sets $vol_name to /dev/whatever
if grep -qE "^${vol_name#/dev/} .+ nvme" /proc/mdstat; then
ding
@ -734,11 +738,7 @@ set_writemostly(){
# Restore changes from backups
if [[ $restore == "yes" ]]; then
dbbaklist=($(find $dbpath -maxdepth 1 \( -name "*.db.new.bak" -o -name "*.db.bak" \)))
# Sort array
IFS=$'\n'
dbbakfiles=($(sort <<<"${dbbaklist[*]}"))
unset IFS
readarray -t dbbakfiles < <(find "$dbpath" -maxdepth 1 \( -name "*.db.new.bak" -o -name "*.db.bak" \) | sort)
echo ""
if [[ ${#dbbakfiles[@]} -gt "0" || -f ${synoinfo}.bak ||\
@ -783,8 +783,8 @@ if [[ $restore == "yes" ]]; then
# Make sure they don't lose E10M20-T1 network connection
modelrplowercase=${modelname//RP/rp}
/usr/syno/bin/set_section_key_value ${adapter_cards} E10M20-T1_sup_nic "$modelrplowercase"
/usr/syno/bin/set_section_key_value ${adapter_cards2} E10M20-T1_sup_nic "$modelrplowercase"
/usr/syno/bin/set_section_key_value ${adapter_cards} E10M20-T1_sup_nic "$modelrplowercase" yes
/usr/syno/bin/set_section_key_value ${adapter_cards2} E10M20-T1_sup_nic "$modelrplowercase" yes
fi
# Restore model.dtb from backup
@ -1360,27 +1360,29 @@ fi
# Check databases and add our drives if needed
# Host db files
db1list=($(find "$dbpath" -maxdepth 1 -name "*_host*.db"))
db2list=($(find "$dbpath" -maxdepth 1 -name "*_host*.db.new"))
#db1list=($(find "$dbpath" -maxdepth 1 -name "*_host*.db"))
#db2list=($(find "$dbpath" -maxdepth 1 -name "*_host*.db.new"))
#db1list=($(find "$dbpath" -maxdepth 1 -regextype posix-extended\
# -iregex ".*_host(_v7)?.db"))
#db2list=($(find "$dbpath" -maxdepth 1 -regextype posix-extended\
# -iregex ".*_host(_v7)?.db.new"))
readarray -t db1list < <(find "$dbpath" -maxdepth 1 -name "*_host*.db" | sort)
readarray -t db2list < <(find "$dbpath" -maxdepth 1 -name "*_host*.db.new" | sort)
# Expansion Unit db files
for i in "${!eunits[@]}"; do
#eunitdb1list+=($(find "$dbpath" -maxdepth 1 -name "${eunits[i],,}*.db"))
eunitdb1list+=($(find "$dbpath" -maxdepth 1 -regextype posix-extended\
-iregex ".*${eunits[i],,}(_v7)?.db"))
eunitdb1list+=("$(find "$dbpath" -maxdepth 1 -regextype posix-extended\
-iregex ".*${eunits[i],,}(_v7)?.db")")
#eunitdb2list+=($(find "$dbpath" -maxdepth 1 -name "${eunits[i],,}*.db.new"))
eunitdb2list+=($(find "$dbpath" -maxdepth 1 -regextype posix-extended\
-iregex ".*${eunits[i],,}(_v7)?.db.new"))
eunitdb2list+=("$(find "$dbpath" -maxdepth 1 -regextype posix-extended\
-iregex ".*${eunits[i],,}(_v7)?.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"))
m2carddb1list+=("$(find "$dbpath" -maxdepth 1 -name "*_${m2cards[i],,}*.db")")
m2carddb2list+=("$(find "$dbpath" -maxdepth 1 -name "*_${m2cards[i],,}*.db.new")")
done
@ -1416,23 +1418,51 @@ getdbtype(){
backupdb(){
# Backup database file if needed
local bakversion newversion fname
if [[ $2 == "long" ]]; then
fname="$1"
else
fname=$(basename -- "${1}")
fi
if [[ ! -f "$1.bak" ]]; then
# No existing backup
if [[ $(basename "$1") == "synoinfo.conf" ]]; then
echo "" >&2 # Formatting for stdout
fi
if [[ $2 == "long" ]]; then
fname="$1"
if cp -p "$1" "$1.bak"; then
echo -e "Backed up ${fname}" >&2
if [[ "${1##*.}" == "db" ]]; then
# Backup db version file as well
cp -p "$1.version" "$1.bakver"
fi
else
fname=$(basename -- "${1}")
echo -e "${Error}ERROR 5${Off} Failed to backup ${fname}!" >&2
return 1
fi
elif [[ "${1##*.}" == "db" ]]; then
# Only .db files have version files
if [[ ! -f "$1.bakver" ]]; then
# Existing backup has no .bakver file, create one
cp -p "$1.version" "$1.bakver"
fi
bakversion=$(cat "$1.bakver" 2>/dev/null)
newversion=$(cat "$1.version" 2>/dev/null)
if [[ "$newversion" -gt "$bakversion" ]]; then
# Newer version db files have been installed
if cp -p "$1" "$1.bak"; then
echo -e "Backed up ${fname}" >&2
# Update db version backup as well
cp -p "$1.version" "$1.bakver"
else
echo -e "${Error}ERROR 5${Off} Failed to backup ${fname}!" >&2
return 1
fi
fi
fi
# Fix permissions if needed
local octal
octal=$(stat -c "%a %n" "$1" | cut -d" " -f1)
if [[ ! $octal -eq 644 ]]; then
chmod 644 "$1"
@ -1656,12 +1686,14 @@ updatedb(){
common_string="$common_string"\"smart_test_ignore\":false,
common_string="$common_string"\"smart_attr_ignore\":false
fwstrng=\"$fwrev\":{
#fwstrng=\"$fwrev\":{
fwstrng=\"$fwrev\":{\"fw_buildnumber\":1, # Issue 585. Fix drive temperature for XPE
fwstrng="$fwstrng$common_string"
fwstrng="$fwstrng"}]},
#default=\"default\":{
default=\"default\":{\"size_gb\":$size_gb,
#default=\"default\":{\"fw_buildnumber\":1,\"size_gb\":$size_gb, # Issue 585. Fix drive temperature for XPE
default="$default$common_string"
default="$default"}]}}}

Loading…
Cancel
Save