From d8f1679bc37dc17297b35a0d9500c5bd9127274b Mon Sep 17 00:00:00 2001 From: Dave Russell <39733752+007revad@users.noreply.github.com> Date: Sat, 3 Aug 2024 17:49:45 +1000 Subject: [PATCH 1/9] Update CHANGES.txt --- CHANGES.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index ad11d2b..6f54990 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,6 @@ +v3.5.98 +- Changed to install dtc automaticall if needed and running from task scheduler. + v3.5.97 - Changed silently skip empty .db.new files with showing an error. Issue #175 - Changed to warn if db file is 0 bytes. From 5cb43786c5ed4360d927041e65edf2769e163d22 Mon Sep 17 00:00:00 2001 From: Dave Russell <39733752+007revad@users.noreply.github.com> Date: Sat, 3 Aug 2024 17:50:49 +1000 Subject: [PATCH 2/9] Update syno_hdd_db.sh v3.5.98 - Changed to install dtc automatically if needed and script is running from task scheduler. --- syno_hdd_db.sh | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/syno_hdd_db.sh b/syno_hdd_db.sh index 588df1c..1acb4bc 100644 --- a/syno_hdd_db.sh +++ b/syno_hdd_db.sh @@ -29,7 +29,7 @@ # /var/packages/StorageManager/target/ui/storage_panel.js -scriptver="v3.5.97" +scriptver="v3.5.98" script=Synology_HDD_db repo="007revad/Synology_HDD_db" scriptname=syno_hdd_db @@ -1564,6 +1564,33 @@ EOM2D17 fi } +is_schedule_running(){ + # $1 is script's filename. e.g. syno_hdd_db.sh etc + local file="/usr/syno/etc/esynoscheduler/esynoscheduler.db" + local rows offset task status pid result + + # Get number of rows in database + rows=$(sqlite3 "${file}" < # example: @@ -1580,6 +1607,8 @@ install_binfile(){ # Download binfile if [[ $autoupdate == "yes" ]]; then reply=y + elif is_schedule_running "$(basename -- "$0")"; then + reply=y else echo -e "\nNeed to download ${1}" echo -e "${Cyan}Do you want to download ${1}?${Off} [y/n]" From e86b575537e72c3397d900c3ea0cc4e132f6fc1a Mon Sep 17 00:00:00 2001 From: Dave Russell <39733752+007revad@users.noreply.github.com> Date: Sat, 3 Aug 2024 17:57:05 +1000 Subject: [PATCH 3/9] Update CHANGES.txt --- CHANGES.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 6f54990..36b1124 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,9 @@ v3.5.98 -- Changed to install dtc automaticall if needed and running from task scheduler. +- Changed to automatically download and install dtc if all of the following 4 conditions are met: + 1. dtc is not already installed. + 2. /bin/dtc or dtc are not in the same folder as the script. + 3. The script needs dtc. + 4. The script is running from task scheduler. v3.5.97 - Changed silently skip empty .db.new files with showing an error. Issue #175 From c5a0ebfb59f865926b501470206cf7d325b797d2 Mon Sep 17 00:00:00 2001 From: Dave Russell <39733752+007revad@users.noreply.github.com> Date: Fri, 9 Aug 2024 15:14:52 +1000 Subject: [PATCH 4/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2fc7127..5d3c0cd 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ ### Donators | | | | | |--------------------|--------------------|----------------------|----------------------| -| | Sebastiaan Mulder | Nico Stark | Oleksandr Antonishak | +| vaadmin | Sebastiaan Mulder | Nico Stark | Oleksandr Antonishak | | Marcel Siemienowski | Dave Smart | dweagle79 | lingyinsam | | Vojtech Filkorn | Craig Sadler | Po-Chia Chen | Jean-François Fruhauf | | Sven 'ctraltdelete' | Thomas Horn | Christian | Simon Azzouni | From 1883038e948c852aa29e0d2668dbeb13990e0b03 Mon Sep 17 00:00:00 2001 From: Dave Russell <39733752+007revad@users.noreply.github.com> Date: Thu, 15 Aug 2024 12:25:46 +1000 Subject: [PATCH 5/9] Update CHANGES.txt --- CHANGES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.txt b/CHANGES.txt index 36b1124..f01be33 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,7 @@ v3.5.98 2. /bin/dtc or dtc are not in the same folder as the script. 3. The script needs dtc. 4. The script is running from task scheduler. +- Bug fix for "Enable write_mostly on slow internal drives so DSM runs from the fast internal drive(s)." Issue #340 v3.5.97 - Changed silently skip empty .db.new files with showing an error. Issue #175 From 8f6488e3bfefcfc14bdb43e601e51e67f586362a Mon Sep 17 00:00:00 2001 From: Dave Russell <39733752+007revad@users.noreply.github.com> Date: Thu, 15 Aug 2024 12:26:12 +1000 Subject: [PATCH 6/9] Update syno_hdd_db.sh - Bug fix for "Enable write_mostly on slow internal drives so DSM runs from the fast internal drive(s)." Issue #340 --- syno_hdd_db.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/syno_hdd_db.sh b/syno_hdd_db.sh index 1acb4bc..c11726d 100644 --- a/syno_hdd_db.sh +++ b/syno_hdd_db.sh @@ -1785,13 +1785,12 @@ if [[ $ssd == "yes" ]]; then # Get list of internal HDDs and qty of SSDs internal_ssd_qty="0" for idrive in "${internal_drives[@]}"; do - internal_drive="$(echo "$idrive" | awk '{printf $4}')" - if synodisk --isssd "$internal_drive" >/dev/null; then + if synodisk --isssd /dev/"${idrive:?}" >/dev/null; then # exit code 0 = is not SSD # exit code 1 = is SSD # Add internal HDDs to array - internal_hdds+=("$internal_drive") + internal_hdds+=("$idrive") else # Count number of internal 2.5 inch SSDs internal_ssd_qty=$((internal_ssd_qty +1)) From 92daf9f3331fff18b31a49d5e06f65e24f2cc5a1 Mon Sep 17 00:00:00 2001 From: Dave Russell <39733752+007revad@users.noreply.github.com> Date: Thu, 15 Aug 2024 13:23:40 +1000 Subject: [PATCH 7/9] Update CHANGES.txt --- CHANGES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.txt b/CHANGES.txt index f01be33..3263c9e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -5,6 +5,7 @@ v3.5.98 3. The script needs dtc. 4. The script is running from task scheduler. - Bug fix for "Enable write_mostly on slow internal drives so DSM runs from the fast internal drive(s)." Issue #340 +- Improved output to make it clear which drive(s) have most-writly set. v3.5.97 - Changed silently skip empty .db.new files with showing an error. Issue #175 From 613b54fff183d139ace32d258f8c99ae61902d0d Mon Sep 17 00:00:00 2001 From: Dave Russell <39733752+007revad@users.noreply.github.com> Date: Thu, 15 Aug 2024 13:23:49 +1000 Subject: [PATCH 8/9] Update syno_hdd_db.sh --- syno_hdd_db.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/syno_hdd_db.sh b/syno_hdd_db.sh index c11726d..778f138 100644 --- a/syno_hdd_db.sh +++ b/syno_hdd_db.sh @@ -1730,31 +1730,36 @@ done set_writemostly(){ # $1 is writemostly or in_sync # $2 is sata1 or sas1 or sda etc + local model + # Show drive model + model="$(cat /sys/block/"${2}"/device/model | xargs)" + echo -e "${Yellow}$model${Off}" + if [[ ${1::2} == "sd" ]]; then # sda etc # md0 DSM system partition echo "$1" > /sys/block/md0/md/dev-"${2}"1/state # Show setting - echo -n "$2 DSM partition: " + echo -n " $2 DSM partition: " cat /sys/block/md0/md/dev-"${2}"1/state # md1 DSM swap partition echo "$1" > /sys/block/md1/md/dev-"${2}"2/state # Show setting - echo -n "$2 Swap partition: " + echo -n " $2 Swap partition: " cat /sys/block/md1/md/dev-"${2}"2/state else # sata1 or sas1 etc # md0 DSM system partition echo "$1" > /sys/block/md0/md/dev-"${2}"p1/state # Show setting - echo -n "$2 DSM partition: " + echo -n " $2 DSM partition: " cat /sys/block/md0/md/dev-"${2}"p1/state # md1 DSM swap partition echo "$1" > /sys/block/md1/md/dev-"${2}"p2/state # Show setting - echo -n "$2 Swap partition: " + echo -n " $2 Swap partition: " cat /sys/block/md1/md/dev-"${2}"p2/state fi } @@ -1765,7 +1770,7 @@ if [[ $ssd == "yes" ]]; then if [[ $ssd_restore == "yes" ]]; then # Restore all internal drives to just in_sync - echo -e "\nRestoring internal drive's state:" + echo -e "\nRestoring internal drive's state" for idrive in "${internal_drives[@]}"; do #if ! grep -q "write_mostly"; then set_writemostly -writemostly "$idrive" @@ -1774,7 +1779,7 @@ if [[ $ssd == "yes" ]]; then elif [[ ${#ssds_writemostly[@]} -gt "0" ]]; then # User specified their fast drive(s) - echo -e "\nSetting slow internal HDDs state to write_mostly:" + echo -e "\nSetting slow internal HDDs state to write_mostly" for idrive in "${internal_drives[@]}"; do if [[ ! ${ssds_writemostly[*]} =~ $idrive ]]; then set_writemostly writemostly "$idrive" @@ -1800,7 +1805,7 @@ if [[ $ssd == "yes" ]]; then # Set HDDs to writemostly if there's also internal SSDs if [[ $internal_ssd_qty -gt "0" ]] && [[ ${#internal_hdds[@]} -gt "0" ]]; then # There are internal SSDs and HDDs - echo -e "\nSetting internal HDDs state to write_mostly:" + echo -e "\nSetting internal HDDs state to write_mostly" for idrive in "${internal_hdds[@]}"; do set_writemostly writemostly "$idrive" done From c7f0132c090a259b26af62cff7558c5aec2d6fd5 Mon Sep 17 00:00:00 2001 From: Dave Russell <39733752+007revad@users.noreply.github.com> Date: Thu, 15 Aug 2024 13:24:42 +1000 Subject: [PATCH 9/9] Update CHANGES.txt --- CHANGES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index 3263c9e..f938db2 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -5,7 +5,7 @@ v3.5.98 3. The script needs dtc. 4. The script is running from task scheduler. - Bug fix for "Enable write_mostly on slow internal drives so DSM runs from the fast internal drive(s)." Issue #340 -- Improved output to make it clear which drive(s) have most-writly set. +- Improved output to make it clear which drive(s) have most_writely set. v3.5.97 - Changed silently skip empty .db.new files with showing an error. Issue #175