Browse Source

v3.6.126

main
007revad 2 weeks ago
parent
commit
2da9c19a7b
  1. 7
      CHANGES.txt
  2. 76
      syno_hdd_db.sh

7
CHANGES.txt

@ -1,3 +1,10 @@
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.
v3.6.125 v3.6.125
- Bug fix for missing lvs and pvs errors for 1 bay NAS (that don't have LVM). - Bug fix for missing lvs and pvs errors for 1 bay NAS (that don't have LVM).

76
syno_hdd_db.sh

@ -29,7 +29,7 @@
# /var/packages/StorageManager/target/ui/storage_panel.js # /var/packages/StorageManager/target/ui/storage_panel.js
scriptver="v3.6.125" scriptver="v3.6.126"
script=Synology_HDD_db script=Synology_HDD_db
repo="007revad/Synology_HDD_db" repo="007revad/Synology_HDD_db"
scriptname=syno_hdd_db scriptname=syno_hdd_db
@ -282,8 +282,9 @@ minor=$(/usr/syno/bin/synogetkeyvalue /etc.defaults/VERSION minorversion)
dsmversion="$major$minor" dsmversion="$major$minor"
# Get Synology model # Get Synology model
model=$(cat /proc/sys/kernel/syno_hw_version) #model=$(cat /proc/sys/kernel/syno_hw_version)
modelname="$model" #modelname="$model"
modelname=$(/usr/syno/bin/synogetkeyvalue /etc.defaults/synoinfo.conf upnpmodelname)
# Get CPU platform_name # Get CPU platform_name
#platform_name=$(/usr/syno/bin/synogetkeyvalue /etc.defaults/synoinfo.conf 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 # Show DSM full version and model
if [[ $buildphase == GM ]]; then buildphase=""; fi if [[ $buildphase == GM ]]; then buildphase=""; fi
if [[ $smallfixnumber -gt "0" ]]; then smallfix="-$smallfixnumber"; 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 # Convert model to lower case
model=${model,,} #model=${model,,}
model=${modelname,,}
# Check for dodgy characters after model number # Check for dodgy characters after model number
if [[ $model =~ 'pv10-j'$ ]]; then # GitHub issue #10 #if [[ $model =~ 'pv10-j'$ ]]; then # GitHub issue #10
modelname=${modelname%??????}+ # replace last 6 chars with + # modelname=${modelname%??????}+ # replace last 6 chars with +
model=${model%??????}+ # replace last 6 chars with + # model=${model%??????}+ # replace last 6 chars with +
echo -e "\nUsing model: $model" # echo -e "\nUsing model: $model"
elif [[ $model =~ '-j'$ ]]; then # GitHub issue #2 #elif [[ $model =~ '-j'$ ]]; then # GitHub issue #2
modelname=${modelname%??} # remove last 2 chars # modelname=${modelname%??} # remove last 2 chars
model=${model%??} # remove last 2 chars # model=${model%??} # remove last 2 chars
echo -e "\nUsing model: $model" # echo -e "\nUsing model: $model"
fi #fi
# Get StorageManager version # Get StorageManager version
storagemgrver=$(/usr/syno/bin/synopkg version StorageManager) storagemgrver=$(/usr/syno/bin/synopkg version StorageManager)
@ -631,6 +634,7 @@ get_script_vol() {
fi fi
} }
if which lvm >/dev/null; then if which lvm >/dev/null; then
# Single bay Synology NAS don't have lvm
get_script_vol # sets $vol_name to /dev/whatever get_script_vol # sets $vol_name to /dev/whatever
if grep -qE "^${vol_name#/dev/} .+ nvme" /proc/mdstat; then if grep -qE "^${vol_name#/dev/} .+ nvme" /proc/mdstat; then
ding ding
@ -734,11 +738,7 @@ set_writemostly(){
# Restore changes from backups # Restore changes from backups
if [[ $restore == "yes" ]]; then if [[ $restore == "yes" ]]; then
dbbaklist=($(find $dbpath -maxdepth 1 \( -name "*.db.new.bak" -o -name "*.db.bak" \))) readarray -t dbbakfiles < <(find "$dbpath" -maxdepth 1 \( -name "*.db.new.bak" -o -name "*.db.bak" \) | sort)
# Sort array
IFS=$'\n'
dbbakfiles=($(sort <<<"${dbbaklist[*]}"))
unset IFS
echo "" echo ""
if [[ ${#dbbakfiles[@]} -gt "0" || -f ${synoinfo}.bak ||\ 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 # Make sure they don't lose E10M20-T1 network connection
modelrplowercase=${modelname//RP/rp} 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_cards} E10M20-T1_sup_nic "$modelrplowercase" yes
/usr/syno/bin/set_section_key_value ${adapter_cards2} E10M20-T1_sup_nic "$modelrplowercase" /usr/syno/bin/set_section_key_value ${adapter_cards2} E10M20-T1_sup_nic "$modelrplowercase" yes
fi fi
# Restore model.dtb from backup # Restore model.dtb from backup
@ -1416,23 +1416,51 @@ getdbtype(){
backupdb(){ backupdb(){
# Backup database file if needed # 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 if [[ ! -f "$1.bak" ]]; then
# No existing backup
if [[ $(basename "$1") == "synoinfo.conf" ]]; then if [[ $(basename "$1") == "synoinfo.conf" ]]; then
echo "" >&2 # Formatting for stdout echo "" >&2 # Formatting for stdout
fi fi
if [[ $2 == "long" ]]; then if cp -p "$1" "$1.bak"; then
fname="$1" echo -e "Backed up ${fname}" >&2
if [[ "${1##*.}" == "db" ]]; then
# Backup db version file as well
cp -p "$1.version" "$1.bakver"
fi
else 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 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 if cp -p "$1" "$1.bak"; then
echo -e "Backed up ${fname}" >&2 echo -e "Backed up ${fname}" >&2
# Update db version backup as well
cp -p "$1.version" "$1.bakver"
else else
echo -e "${Error}ERROR 5${Off} Failed to backup ${fname}!" >&2 echo -e "${Error}ERROR 5${Off} Failed to backup ${fname}!" >&2
return 1 return 1
fi fi
fi fi
fi
# Fix permissions if needed # Fix permissions if needed
local octal
octal=$(stat -c "%a %n" "$1" | cut -d" " -f1) octal=$(stat -c "%a %n" "$1" | cut -d" " -f1)
if [[ ! $octal -eq 644 ]]; then if [[ ! $octal -eq 644 ]]; then
chmod 644 "$1" chmod 644 "$1"

Loading…
Cancel
Save