Browse Source

Update syno_hdd_db.sh

v3.3.75
- Now saves changes.txt as <script-filename>_changes.txt when updating the script.
    - To not overwrite changes.txt if my other scripts are in the same folder.
- Bug fix for detecting if script is located on M.2 drive.
- Minor bug fix.
pull/199/head
Dave Russell 2 years ago
committed by GitHub
parent
commit
903349e82e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      syno_hdd_db.sh

19
syno_hdd_db.sh

@ -27,9 +27,10 @@
# Now warns if script is located on an M.2 volume. # Now warns if script is located on an M.2 volume.
scriptver="v3.3.74" scriptver="v3.3.75"
script=Synology_HDD_db script=Synology_HDD_db
repo="007revad/Synology_HDD_db" repo="007revad/Synology_HDD_db"
scriptname=syno_hdd_db
# Check BASH variable is bash # Check BASH variable is bash
if [ ! "$(basename "$BASH")" = bash ]; then if [ ! "$(basename "$BASH")" = bash ]; then
@ -296,9 +297,9 @@ echo "Running from: ${scriptpath}/$scriptfile"
# Warn if script located on M.2 drive # Warn if script located on M.2 drive
scriptvol=$(echo "$scriptpath" | cut -d"/" -f2) scriptvol=$(echo "$scriptpath" | cut -d"/" -f2)
vg=$(lvdisplay | grep /volume_"${scriptvol#volume}" | cut -d"/" -f3) vg=$(lvdisplay | grep /volume_"${scriptvol#volume}" | cut -d"/" -f3)
md=$(pvdisplay | grep -B 1 "$vg" | grep /dev/ | cut -d"/" -f3) md=$(pvdisplay | grep -B 1 -E '[ ]'"$vg" | grep /dev/ | cut -d"/" -f3)
if cat /proc/mdstat | grep "$md" | grep nvme >/dev/null; then if cat /proc/mdstat | grep "$md" | grep nvme >/dev/null; then
echo "${Yellow}WARNING${Off} Don't store this script on an NVMe volume!" echo -e "${Yellow}WARNING${Off} Don't store this script on an NVMe volume!"
fi fi
@ -381,7 +382,7 @@ if ! printf "%s\n%s\n" "$tag" "$scriptver" |
fi fi
# Copy new script sh file to script location # Copy new script sh file to script location
if ! cp -p "/tmp/$script-$shorttag/syno_hdd_db.sh" "${scriptpath}/${scriptfile}"; if ! cp -p "/tmp/$script-$shorttag/${scriptname}.sh" "${scriptpath}/${scriptfile}";
then then
copyerr=1 copyerr=1
echo -e "${Error}ERROR${Off} Failed to copy"\ echo -e "${Error}ERROR${Off} Failed to copy"\
@ -410,10 +411,12 @@ if ! printf "%s\n%s\n" "$tag" "$scriptver" |
fi fi
fi fi
# Copy new CHANGES.txt file # Copy new CHANGES.txt file to script location (if script on a volume)
if [[ $scriptpath =~ /volume* ]]; then if [[ $scriptpath =~ /volume* ]]; then
# 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}/${scriptname}_CHANGES.txt";
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"
@ -424,7 +427,7 @@ if ! printf "%s\n%s\n" "$tag" "$scriptver" |
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
changestxt=", changes.txt" changestxt=" and changes.txt"
fi fi
fi fi
@ -433,7 +436,7 @@ if ! printf "%s\n%s\n" "$tag" "$scriptver" |
# Notify of success (if there were no errors) # Notify of success (if there were no errors)
if [[ $copyerr != 1 ]] && [[ $permerr != 1 ]]; then if [[ $copyerr != 1 ]] && [[ $permerr != 1 ]]; then
echo -e "\n$tag$changestxt$vids_txt downloaded to: ${scriptpath}\n" echo -e "\n$tag ${scriptfile}$vids_txt$changestxt downloaded to: ${scriptpath}\n"
syslog_set info "$script successfully updated to $tag" syslog_set info "$script successfully updated to $tag"
# Reload script # Reload script

Loading…
Cancel
Save