Skip to content

Commit

Permalink
Update syno_hdd_db.sh
Browse files Browse the repository at this point in the history
- 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"
  • Loading branch information
007revad authored Apr 25, 2023
1 parent 077419a commit 0978f8a
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions syno_hdd_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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."
Expand Down

0 comments on commit 0978f8a

Please sign in to comment.