From 0978f8ab29743848b22460075fa0ff783f059345 Mon Sep 17 00:00:00 2001 From: Dave Russell <39733752+007revad@users.noreply.github.com> Date: Tue, 25 Apr 2023 22:51:11 +1000 Subject: [PATCH] Update syno_hdd_db.sh - Added --restore info to --help - Updated restore option to download the latest db files from Synology - Now warns you if you try to run it in sh with "sh scriptname.sh" --- syno_hdd_db.sh | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/syno_hdd_db.sh b/syno_hdd_db.sh index 839ff23..778e7bc 100644 --- a/syno_hdd_db.sh +++ b/syno_hdd_db.sh @@ -30,7 +30,12 @@ # It's also parsed and checked and probably in some cases it could be more critical to patch that one instead. # DONE -# Prevent running with "sh scriptname.sh". +# Added --restore info to --help +# +# Updated restore option to download the latest db files from Synology +# +# Now warns you if you try to run it in sh with "sh scriptname.sh" +# # # Fixed DSM 6 bug where the drives were being duplicated in the .db files each time the script was run. # @@ -181,6 +186,7 @@ Options: -m, --m2 Don't process M.2 drives -f, --force Force DSM to not check drive compatibility -r, --ram Disable memory compatibility checking + --restore Undo all changes made by the script -h, --help Show this help message -v, --version Show the script version @@ -450,6 +456,16 @@ if [[ $restore == "yes" ]]; then if [[ ${#dbbakfiles[@]} -gt "0" ]] || [[ -f ${synoinfo}.bak ]]; then + # 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 + # Restore .db files from backups for f in "${!dbbakfiles[@]}"; do deleteme="${dbbakfiles[f]%.bak}" # Remove .bak @@ -461,15 +477,8 @@ if [[ $restore == "yes" ]]; then 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 + # Update .db files from Synology + syno_disk_db_update --update if [[ -z $restoreerr ]]; then echo -e "\nRestore successful."