Compare commits

...

103 Commits

Author SHA1 Message Date
007revad fc799e1e13 Merge branch 'main' into develop 1 week ago
007revad 95a448dd76 Merge branch 'develop' of https://github.com/007revad/Synology_HDD_db into develop 1 week ago
Dave Russell ea471b9b40
Update CHANGES.txt 1 week ago
Dave Russell 3618a2d935
Update CHANGES.txt with new bug fix details 1 week ago
Dave Russell 226d444d31
Fix db file processing bug for migrated Synology models 1 week ago
Dave Russell 1f53949189
Update script version and M.2 card database file search 1 week ago
Dave Russell 64aded0da8 Sync my-other-scripts.md from 007revad.github.io 2 weeks ago
Dave Russell 05a0fa3215
v3.6.136 2 weeks ago
Dave Russell 73e715913a
Update CHANGES.txt for version 3.6.136 2 weeks ago
Dave Russell aa5f164a49 Sync my-other-scripts.md from 007revad.github.io 2 weeks ago
Dave Russell d94ca37693
Update CHANGES.txt for versions 3.6.135 and 3.6.134 2 weeks ago
Dave Russell b8d066abd6
Update script version and fix command paths 2 weeks ago
Dave Russell 371a886ab7
Update CHANGES.txt for version 3.6.135 2 weeks ago
007revad 6fba438739 v3.6.134 3 weeks ago
007revad 8e6728c9de v3.6.134 3 weeks ago
007revad 21efba3ae9 v3.6.134 3 weeks ago
007revad a328fb71cf v3.6.134 3 weeks ago
007revad a3c9495649 v3.6.133 3 weeks ago
007revad 556daeb144 Merge branch 'main' of https://github.com/007revad/Synology_HDD_db 3 weeks ago
007revad 1131d4adaf v3.6.133 3 weeks ago
Dave Russell 0d0fdf6ff7 Sync my-other-scripts.md from 007revad.github.io 1 month ago
Dave Russell b74ffce943 Sync my-other-scripts.md from 007revad.github.io 2 months ago
Dave Russell f4fda18c20
Fix SynoOnlinePack version not found error 2 months ago
Dave Russell c53372ed19
Fix issue references in CHANGES.txt 2 months ago
007revad df9ec99d61 v3.6.132 2 months ago
Dave Russell 7ad2f4c6df
Update CHANGES.txt for version 3.6.132 2 months ago
007revad c7b583adcc Merge branch 'main' of https://github.com/007revad/Synology_HDD_db 2 months ago
007revad 50a9ec1987 v3.6.132 2 months ago
Dave Russell 461f7875ec
Update CHANGES.txt for version 3.6.132 2 months ago
Dave Russell 84478e2319
Merge pull request #590 from tkirkland/fix/rx1217-runtime-alias 2 months ago
Dave Russell c2cc51ff47
Update image tags in README.md for better formatting 2 months ago
tkirkland 8c143c80f9 Fix expansion unit database alias selection 2 months ago
Dave Russell 801acf39f0
Correct typo in CHANGES.txt for DSM 7.4 fix 2 months ago
Dave Russell 3c6e1847b0
Add support for DSM 7.4 in README 2 months ago
007revad c33881d1d0 Merge branch 'main' of https://github.com/007revad/Synology_HDD_db 2 months ago
007revad 67dde6623d v3.6.131 2 months ago
Dave Russell dce582f665 Sync my-other-scripts.md from 007revad.github.io 2 months ago
Dave Russell a263a52aa2 Sync my-other-scripts.md from 007revad.github.io 2 months ago
Dave Russell c903d99d6b Sync my-other-scripts.md from 007revad.github.io 2 months ago
Dave Russell f0242c025b Sync my-other-scripts.md from 007revad.github.io 2 months ago
Dave Russell f223b1be8a
Enhance telnet connection instructions for Mac users 2 months ago
Dave Russell 6e755a0864
Fix version reference and add Mac Terminal note 2 months ago
Dave Russell c9d4a447e3
Update 2025_plus_models.md 2 months ago
Dave Russell 2a3a9a346c
Update 2025_plus_models.md 2 months ago
Dave Russell b028b15daf
Update 2025_plus_models.md 2 months ago
Dave Russell c1b5e817a0
Update 2025_plus_models.md 2 months ago
007revad 4015c3ce08 v3.6.130 2 months ago
007revad ceea30c7f0 v3.6.129 2 months ago
007revad aba32f6796 v3.6.128 2 months ago
007revad 489416b078 v3.6.127 2 months ago
007revad 699f6f9c51 v3.6.127 2 months ago
007revad 608de6f86d v3.6.127 2 months ago
007revad 248763c5a5 Merge branch 'main' of https://github.com/007revad/Synology_HDD_db 2 months ago
007revad 716db64e31 v3.6.127 2 months ago
Dave Russell 4bae864b3d
Fix issue number for XPE temperature bug 2 months ago
007revad 8111e099ae v3.6.126 2 months ago
007revad 2da9c19a7b v3.6.126 2 months ago
Dave Russell d2b55ceedf Sync my-other-scripts.md from 007revad.github.io 3 months ago
Dave Russell 802f32ccc0 Sync my-other-scripts.md from 007revad.github.io 3 months ago
Dave Russell 66eb0278a3 Sync my-other-scripts.md from 007revad.github.io 3 months ago
Dave Russell fc18071433 Sync my-other-scripts.md from 007revad.github.io 4 months ago
Dave Russell 684fef5501 Sync my-other-scripts.md from 007revad.github.io 4 months ago
Dave Russell 36ab0a12eb Sync my-other-scripts.md from 007revad.github.io 4 months ago
Dave Russell d296f1ba90 Sync my-other-scripts.md from 007revad.github.io 4 months ago
Dave Russell e8496028e7
Update CHANGES.txt for version 3.6.125 4 months ago
Dave Russell 2629d1efa1
Bug fix for 1 bay NAS without LVM 4 months ago
Dave Russell 8a477fbb2c Sync my-other-scripts.md from 007revad.github.io 4 months ago
Dave Russell f82bba2f0e Sync my-other-scripts.md from 007revad.github.io 4 months ago
Dave Russell 107c103f61 Sync my-other-scripts.md from 007revad.github.io 4 months ago
Dave Russell 1cb9e7cc6b Sync my-other-scripts.md from 007revad.github.io 5 months ago
Dave Russell 07bb5d3da5 Sync my-other-scripts.md from 007revad.github.io 5 months ago
Dave Russell 8bed2207ec Sync my-other-scripts.md from 007revad.github.io 5 months ago
Dave Russell 3ffc092bc6 Sync my-other-scripts.md from 007revad.github.io 5 months ago
007revad 50e7370d52 Update my-other-scripts.md 5 months ago
007revad 2c558a6889 Update my-other-scripts.md 5 months ago
007revad 3172b2e360 Update my-other-scripts.md 5 months ago
007revad 9e7f5f618c Update my-other-scripts.md 5 months ago
Dave Russell f64caba58b
Merge pull request #569 from 007revad/develop 6 months ago
007revad b72ac0deb7 Merge branch 'develop' of https://github.com/007revad/Synology_HDD_db into develop 3 years ago
007revad 492916cf98 Merge branch 'develop' of https://github.com/007revad/Synology_HDD_db into develop 3 years ago
007revad 8a9e798601
Delete how_to_schedule.md 3 years ago
007revad 7f0ed23cd6
Delete README.md 3 years ago
007revad 6f3b86663a
Delete images directory 3 years ago
007revad f335bdd3d8
Delete LICENSE 3 years ago
007revad 6b6c982765
Update syno_hdd_db.sh 3 years ago
007revad d9fce321b0
Update CHANGES.txt 3 years ago
007revad e89f1da284
Update CHANGES.txt 3 years ago
007revad 0e4c229fee
Update syno_hdd_db.sh 3 years ago
007revad b08c66be3b
Update syno_hdd_db.sh 3 years ago
007revad d204276858
Update syno_hdd_db.sh 3 years ago
007revad 9df855b69f
Update syno_hdd_db.sh 3 years ago
007revad 2384cc9dff
Update README.md 3 years ago
007revad 33353d716d
Update CHANGES.txt 3 years ago
007revad 0be26411e6
Update CHANGES.txt 3 years ago
007revad 9f0f102df5
Update CHANGES.txt 3 years ago
007revad d45ae58e84
Update syno_hdd_db.sh 3 years ago
007revad 5c27a6a7ec
Update syno_hdd_db.sh 3 years ago
007revad 76caf0fdc9
Create CHANGES.txt 3 years ago
007revad 8d3433f0c6
Update syno_hdd_db.sh 3 years ago
007revad 96b6a88f32
Update syno_hdd_db.sh 3 years ago
007revad a0322474c3
Update syno_hdd_db.sh 3 years ago
007revad 0729382798
Update syno_hdd_db.sh 3 years ago
007revad 30400d7966
Update syno_hdd_db.sh 4 years ago
  1. 50
      2025_plus_models.md
  2. 65
      CHANGES.txt
  3. 21
      LICENSE
  4. 6
      README.md
  5. 27
      how_to_schedule.md
  6. BIN
      images/schedule1.png
  7. BIN
      images/schedule2.png
  8. BIN
      images/schedule3.png
  9. BIN
      images/syno_hdd_db.png
  10. BIN
      images/syno_hdd_db2.png
  11. 179
      my-other-scripts.md
  12. 512
      syno_hdd_db.sh
  13. 92
      tests/test_expansion_unit_db_selection.sh

50
2025_plus_models.md

@ -36,26 +36,56 @@ ### Setting up a new 2025 or later plus model with only unverified HDDs in DSM 7
Credit to Alex_of_Chaos on reddit
DSM won't install on a 2025 or later series plus model if you only have unverified HDDs. But we can get around that.
DSM 7.2.2 won't install on a 2025 or later series plus model if you only have unverified HDDs. But we can get around that.
1. Start telnet by entering `http://<NAS-IP>:5000/webman/start_telnet.cgi` into your browser's address bar.
1. Get the Synology's IP address from Synology Assistant.
2. Start DSM's telnet server by entering `http://<NAS-IP>:5000/webman/start_telnet.cgi` into your browser's address bar.
- Replace `<NAS-IP>` with the IP address of the Synology NAS.
2. Open a telnet client (powershell, PuTTY etc) on your computer and connect to the Synology with 'telnet <NAS-IP>`.
- Replace `<NAS-IP>` with the IP address of the Synology NAS.
3. Log into telnet with:
3. Open a telnet client (PowerShell, PuTTY, Terminal etc) on your computer and connect to the Synology by typing the following in the telnet window then press enter:
```
telnet <NAS-IP>
```
- Replace `<NAS-IP>` with the IP address of the Synology NAS.
- **Note:** If using a Mac you may need to install Terminal.
<details>
<summary>Click here to see how to install telnet on a Mac</summary>
**Installing telnet on a Mac**
a. Open your Terminal app.
b. If you don't have Homebrew installed, copy and paste the following command into Terminal and press Enter:
```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```
c. Once Homebrew is installed, simply run the installation command:
```
brew install telnet
```
</details>
4. When it asks you to log in use:
- `root` for the login
- `101-0101` for the password
4. Execute the following command: (using a while loop in case DSM is running in a VM)
- **Note:** When you type the password you may not see what you are typing.
5. Execute the following command:
```
touch /tmp/installable_check_pass
```
- If DSM is running in a virtual machine use this command instead:
```
while true; do touch /tmp/installable_check_pass; sleep 1; done
```
5. Refresh the web installation page and install DSM.
6. Then in the telnet window, or via SSH, execute the following command:
6. Refresh the web browser installation page and install DSM.
7. Then back in the telnet window, or via SSH, paste the following command and press enter:
```
/usr/syno/bin/synosetkeyvalue /etc.defaults/synoinfo.conf support_disk_compatibility no
```
7. If Storage Manager is already open close then open it, or refresh the web page. If refreshing the page or restarting Storage Manager is not working, try restarting your Synology NAS.
8. You can now create your storage pool from Storage Manager.
8. If Storage Manager is already open close then open it, or refresh the web page. If refreshing the page or restarting Storage Manager is not working, try restarting your Synology NAS.
9. You can now create your storage pool from Storage Manager.
<br>

65
CHANGES.txt

@ -1,3 +1,67 @@
v3.6.137
- Bug fix for the wrong E10M20-T1, M2D20, M2D18 and M2D17 db files getting processed if the main drives were migrated from a different Synology model.
- Resulted in NVMe drives in one of the above PCIe cards still showing as Unverified.
v3.6.136
- Added messages when write mostly options were used but write mostly cannot be set. Issue #602
- Message for when the `-S` option is used and there are no internal 2.5 inch SDDs found.
- Message for when the user used `-ssd=nvmeNnN` as NVMe drives do not contain DSM system or swap partitions.
v3.6.135
- Changed to replace curly/smart quotes (from db files edited in Word or in iOS) before backing up db files to prevent jq errors.
- Added `/usr/syno/bin` or `/usr/syno/sbin` to the syno... commmands that were missing the full path (for people with a corrupt or edited PATH). Issue #601
- The change above also fixes jq errors caused by those commmands not returning anything. Issue #601
- Bug fix for not detecting script was running from triggered scheduled task.
v3.6.134
- Bug fix for trying to backup M.2 PCIe card's .db.new when it didn't exist which caused the following error. Issue #599
- **cp: cannot stat '': No such file or directory
- ERROR 5 Failed to backup !**
v3.6.133
- Bug fix for not updating db files with each drive's firmware version if drives were previously added to the db files without firmware version from an older script version. Issue #598
- Bug fix for restore mode not re-enabling drive database updates in DSM 7.3 and later.
- Bug fix for sometimes not detecting script was running from scheduled task.
- Bug fix for some errors showing in all red instead of just ERROR being in red.
v3.6.132
- Bug fix for expansion units that DSM reports with different model names. Issue #574
- Adds aliases from each expansion disk's runtime container, such as mapping RX1217-1 to RX1217 when detection reports RX1217RP.
- Uses exact model-family matching so RX1217 does not also edit RX1217RP or RX1217SAS database files.
- Bug fix for trying to backup non-existent file. Issue #574
- Bug fix for SynoOnlinePack version not found causing an error.
Thanks @tkirkland
v3.6.131
- Fix for DSM 7.4 including "rules" db files in the drive db files folder.
v3.6.130
- Bug fix for Samsung SSDs that have 2.5" in their model name.
- Bug fix for not removing leading spaces in drive model names (introduced in v3.6.123).
v3.6.129
- Bug fix for backing up expansion unit db files (introduced in v3.6.126).
v3.6.128
- Bug fix for trying to backup "*_v7.db.version" instead of "*_v7.version".
v3.6.127
- Bug fix for trying to backup "*_v7.db.version" instead of "*_v7.version".
- Bug fix for 6 TB drives having '"size_gb": 6001' in db files instead of '"size_gb": 6000'.
- Also replaces any existing '"size_gb": 6001' in db files with '"size_gb": 6000'.
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.
- Bug fix for XPE not showing drive's correct temperature. Issue #585
v3.6.125
- Bug fix for missing lvs and pvs errors for 1 bay NAS (that don't have LVM).
v3.6.124
- Bug fix for script trying to set write_mostly on SATA M.2 drives. Issue #567
- Bug fix for script trying to use nvme command to get SATA M.2 drives' vendor id. Issue #567
@ -441,4 +505,3 @@ v1.0.1
v1.0.0
- Initial release.

21
LICENSE

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2023 007revad
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

6
README.md

@ -13,7 +13,7 @@ ### Description
Add your SATA or SAS HDDs and SSDs plus SATA and NVMe M.2 drives to your Synology's compatible drive databases, including your Synology M.2 PCIe card and Expansion Unit databases.
The script works in DSM 7, including DSM 7.1, 7.2 and 7.3, and DSM 6.
The script works in DSM 7, including DSM 7.1, 7.2, 7.3 and 7.4, and DSM 6.
It also has a restore option to undo all the changes made by the script.
@ -186,7 +186,7 @@ ### vendor_ids.txt
If DSM doesn't know the brand of your NVMe drives they will show up in Storage Manager as Unknown brand, and Unrecognised firmware version.
<p align="left"><img src="images/unknown.png"></p>
<p align="left"><kbd><img src="images/unknown.png"></kbd></p>
In this case the script will show you the vendor ID and advise you to add it to the syno_hdd_vendor_ids.txt file.
@ -195,7 +195,7 @@ ### vendor_ids.txt
### Ironwolf Health
Ironwolf Health working with the latest version of Ironwolf Health Monitor.
<p align="left"><img src="images/ihm.png"></p>
<p align="left"><kbd><img src="images/ihm.png"></kbd></p>
<br>

27
how_to_schedule.md

@ -1,27 +0,0 @@
# How to schedule a script in Synology Task Scheduler
To schedule a script to run on your Synology at boot-up or shut-down follow these steps:
**Note:** You can setup a schedule task and leave it disabled, so it only runs when you select the task in the Task Scheduler and click on the Run button.
1. Go to **Control Panel** > **Task Scheduler** > click **Create** > and select **Triggered Task**.
2. Select **User-defined script**.
3. Enter a task name.
4. Select **root** as the user (The script needs to run as root).
5. Select **Boot-up** as the event that triggers the task.
6. Leave **Enable** ticked.
7. Click **Task Settings**.
8. Optionally you can tick **Send run details by email** and **Send run details only when the script terminates abnormally** then enter your email address.
9. In the box under **User-defined script** type the path to the script.
- e.g. If you saved the script to a shared folder on volume1 called "scripts" you'd type:
- **/volume1/scripts/syno_hdd_db.sh -nr --autoupdate=3**
- For information on the options see [Options](README.md#options)
11. Click **OK** to save the settings.
Here's some screenshots showing what needs to be set:
<p align="leftr"><img src="images/schedule1.png"></p>
<p align="leftr"><img src="images/schedule2.png"></p>
<p align="leftr"><img src="images/schedule3-2.png"></p>

BIN
images/schedule1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

BIN
images/schedule2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

BIN
images/schedule3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

BIN
images/syno_hdd_db.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

BIN
images/syno_hdd_db2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

179
my-other-scripts.md

@ -1,152 +1,239 @@
## All my scripts, tools and guides
## All my scripts, packages, tools and guides
<img src="https://hitscounter.dev/api/hit?url=https%3A%2F%2F007revad.github.io%2F&label=Visitors&icon=github&color=%23198754&message=&style=flat&tz=UTC">
#### Contents
- [Synology Package Source](#synology-package-source)
- [Speed testing](#speed-testing)
- [Plex](#plex)
- [Asustor scripts and packages](#asustor)
- [Synology docker](#synology-docker)
- [Synology recovery](#synology-recovery)
- [Other Synology scripts](#other-synology-scripts)
- [Other Synology scripts and packages](#other-synology-scripts-and-packages)
- [Synology hardware restrictions](#synology-hardware-restrictions)
- [2025 plus models](#2025-plus-models)
- [Synology 2025 plus models](#synology-2025-plus-models)
- [How To Guides](#how-to-guides)
- [Synology dev](#synology-dev)
***
### Synology Package Source
- **<a href="https://github.com/007revad/Synology_package_source">Synology Package Source</a>**
- Synology Package Source adds DSM packages that are available from GitHub to Package Center so users can easily install packages from various GitHub developers and Package Center can update the packages when newer versions are released.
### Speed Testing
- **<a href="https://github.com/007revad/Synology_Ookla_Speedtest">Synology Ookla Speedtest</a>**
- Synology DSM 7 package to install Ookla Speedtest and run it in a GUI to test your Internet speed.
- **<a href="https://github.com/007revad/Synology_Open_Speedtest">Synology Open Speedtest</a>**
- Synology DSM 7 package to install OpenSpeedtest and run it in a GUI to test your LAN speed.
- **<a href="https://github.com/007revad/Synology_Libre_Speedtest">Synology Libre Speedtest</a>**
- Synology DSM 7 package to install Libre Speedtest and run it in a GUI to test your LAN speed.
- **<a href="https://github.com/007revad/Asustor_Ookla_Speedtest">Asustor Ookla Speedtest</a>**
- Asustor ADM 5 package to install Ookla Speedtest and run it in a GUI to test your internet speed.
- **<a href="https://github.com/007revad/Asustor_Open_Speedtest">Asustor Open Speedtest</a>**
- Asustor ADM 5 package to install OpenSpeedtest and run it in a GUI to test your LAN speed.
- **<a href="https://github.com/007revad/Asustor_Libre_Speedtest">Asustor LibreSpeed Speedtest</a>**
- Asustor ADM 5 package to install LibreSpeed Speedtest and run it in a GUI to test your LAN speed.
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Back to Contents](#contents)
### Plex
- **<a href="https://github.com/007revad/Synology_Plex_Backup">Synology_Plex_Backup</a>**
- **<a href="https://github.com/007revad/Synology_Plex_Backup">Synology Plex Backup</a>**
- A script to backup Plex to a tgz file foror DSM 7 and DSM 6.
- Works for Plex Synology package and Plex in docker.
- **<a href="https://github.com/007revad/Asustor_Plex_Backup">Asustor_Plex_Backup</a>**
- **<a href="https://github.com/007revad/Asustor_Plex_Backup">Asustor Plex Backup</a>**
- Backup your Asustor's Plex Media Server settings and database.
- **<a href="https://github.com/007revad/Linux_Plex_Backup">Linux_Plex_Backup</a>**
- **<a href="https://github.com/007revad/Linux_Plex_Backup">Linux Plex Backup</a>**
- Backup your Linux Plex Media Server's settings and database.
- **<a href="https://github.com/007revad/Plex_Server_Sync">Plex_Server_Sync</a>**
- **<a href="https://github.com/007revad/Plex_Server_Sync">Plex Server Sync</a>**
- Sync your main Plex server database & metadata to a backup Plex server.
- Works for Synology, Asustor, Linux and supports Plex package or Plex in docker.
- **<a href="https://github.com/007revad/Transcode_for_x25">Transcode for x25</a>**
- Installs the modules needed for Plex or Jellyfin hardware transcoding on Synology DS425+ and DS225+.
- Available as a package and a script.
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Back to Contents](#contents)
### Asustor
- **<a href="https://github.com/007revad/Asustor_Ookla_Speedtest">Asustor Ookla Speedtest</a>**
- Asustor ADM 5 package to install Ookla Speedtest and run it in a GUI to test your internet speed.
- **<a href="https://github.com/007revad/Asustor_Open_Speedtest">Asustor Open Speedtest</a>**
- Asustor ADM 5 package to install OpenSpeedtest and run it in a GUI to test your LAN speed.
- **<a href="https://github.com/007revad/Asustor_Libre_Speedtest">Asustor LibreSpeed Speedtest</a>**
- Asustor ADM 5 package to install LibreSpeed Speedtest and run it in a GUI to test your LAN speed.
- **<a href="https://github.com/007revad/Asustor_SMART_info">Asustor SMART info</a>**
- Show Asustor smart health and attributes. Can also email you when important values change.
- **<a href="https://github.com/007revad/Asustor_Plex_Backup">Asustor Plex Backup</a>**
- Backup your Asustor's Plex Media Server settings and database.
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Back to Contents](#contents)
### Synology docker
- **<a href="https://github.com/007revad/Synology_Docker_Export">Synology_Docker_export</a>**
- **<a href="https://github.com/007revad/Synology_Docker_Export">Synology Docker export</a>**
- Export all Synology Container Manager or Docker containers' settings as json files to your docker shared folder.
- **<a href="https://github.com/007revad/Synology_ContainerManager_IPv6">Synology_ContainerManager_IPv6</a>**
- **<a href="https://github.com/007revad/Synology_ContainerManager_IPv6">Synology Container Manager IPv6</a>**
- Enable IPv6 for Container Manager's bridge network.
- **<a href="https://github.com/007revad/ContainerManager_for_all_armv8">ContainerManager_for_all_armv8</a>**
- **<a href="https://github.com/007revad/ContainerManager_for_all_armv8">Container Manager for all armv8</a>**
- Script to install Container Manager on a RS819, DS119j, DS418, DS418j, DS218, DS218play or DS118.
- **<a href="https://github.com/007revad/Docker_Autocompose">Docker_Autocompose</a>**
- **<a href="https://github.com/007revad/Docker_Autocompose">Docker Auto compose</a>**
- Create .yml files from your docker existing containers.
- **<a href="https://github.com/007revad/Synology_docker_cleanup">Synology_docker_cleanup</a>**
- **<a href="https://github.com/007revad/Synology_docker_cleanup">Synology docker cleanup</a>**
- Remove orphan docker btrfs subvolumes and images in Synology DSM 7 and DSM 6.
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Back to Contents](#contents)
### Synology recovery
- **<a href="https://github.com/007revad/Synology_DSM_reinstall">Synology_DSM_reinstall</a>**
- **<a href="https://github.com/007revad/Synology_DSM_reinstall">Synology DSM reinstall</a>**
- Easily re-install the same DSM version without losing any data or settings.
- **<a href="https://github.com/007revad/Synology_Recover_Data">Synology_Recover_Data</a>**
- **<a href="https://github.com/007revad/Synology_Recover_Data">Synology Recover Data</a>**
- A script to make it easy to recover your data from your Synology's drives using a computer.
- **<a href="https://github.com/007revad/Synology_clear_drive_error">Synology clear drive error</a>**
- Clear drive critical errors so DSM will let you use the drive.
- **<a href="https://github.com/007revad/Synology_DSM_Telnet_Password">Synology_DSM_Telnet_Password</a>**
- **<a href="https://github.com/007revad/Synology_DSM_Telnet_Password">Synology DSM Telnet Password</a>**
- Synology DSM Recovery Telnet Password of the Day generator.
- **<a href="https://github.com/007revad/Syno_DSM_Extractor_GUI">Syno_DSM_Extractor_GUI</a>**
- **<a href="https://github.com/007revad/Syno_DSM_Extractor_GUI">Syno DSM Extractor GUI</a>**
- Windows GUI for extracting Synology DSM 7 pat files and spk package files.
- **<a href="https://github.com/007revad/Synoboot_backup">Synoboot_backup</a>**
- **<a href="https://github.com/007revad/Synoboot_backup">Synoboot backup</a>**
- Back up synoboot after each DSM update so you can recover from a corrupt USBDOM.
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Back to Contents](#contents)
### Other Synology scripts
### Other Synology scripts and packages
- **<a href="https://github.com/007revad/Synology_drive_info">Synology Dive Info</a>**
- Synology package to show drive device id, DSM drive number, location, model, serial number, health and S.M.A.R.T. values for all drives in all your Synology NAS.
- **<a href="https://github.com/007revad/Syno_Package_Source_Managero">Syno Package Source Manager</a>**
- Synology package that allows you to disable and enable community package sources you have added to Package Center. It also allows adding known, working, package sources without having to type and paste anything in Package Center's settings.
- **<a href="https://github.com/007revad/Syno_CPU_Temperature">Syno CPU Temperature</a>**
- Synology package to log CPU temperature to help troubleshooting Synology randomly shutting down due to overheating.
- **<a href="https://github.com/007revad/Synology_fix_size_units">Synology fix size units</a>**
- Make DSM show the correct TiB, GiB, MiB and KiB IEC labels instead of TB, GB, MB and KB binary labels.
- **<a href="https://github.com/007revad/Check_UPS_Connected">Check UPS Connected</a>**
- Script to email you the USP status. Also works for Synology NAS that are UPS clients.
- **<a href="https://github.com/007revad/DSM_Notify">DSM Notify</a>**
- Synology package to allow my scheduled scripts to send notifications to DSM 7.
- **<a href="https://github.com/007revad/DSM_Update">DSM Update</a>**
- Script to automatically download the correct pat file and update DSM using the downloaded pat file.
- **<a href="https://github.com/007revad/Synology_Ookla_Speedtest">Synology Ookla Speedtest</a>**
- Synology DSM 7 package to install Ookla Speedtest and run it in a GUI to test your internet speed.
- **<a href="https://github.com/007revad/Synology_Open_Speedtest">Synology Open Speedtest</a>**
- Synology DSM 7 package to install OpenSpeedtest and run it in a GUI to test your LAN speed.
- **<a href="https://github.com/007revad/Synology_Libre_Speedtest">Synology Libre Speedtest</a>**
- Synology DSM 7 package to install Libre Speedtest and run it in a GUI to test your LAN speed.
- **<a href="https://github.com/007revad/Synology_app_mover">Synology_app_mover</a>**
- **<a href="https://github.com/007revad/Synology_app_mover">Synology app mover</a>**
- Easily move Synology packages from one volume to another volume.
- **<a href="https://github.com/007revad/Video_Station_for_DSM_722">Video_Station_for_DSM_722</a>**
- **<a href="https://github.com/007revad/Video_Station_for_DSM_722">Video Station for DSM 722</a>**
- Script to install Video Station in DSM 7.2.2
- **<a href="https://github.com/007revad/SS_Motion_Detection">SS_Motion_Detection</a>**
- **<a href="https://github.com/007revad/SS_Motion_Detection">SS Motion Detection</a>**
- Installs previous Surveillance Station and Advanced Media Extensions versions so motion detection and HEVC are supported.
- **<a href="https://github.com/007revad/Synology_Config_Backup">Synology_Config_Backup</a>**
- **<a href="https://github.com/007revad/Synology_Config_Backup">Synology Config Backup</a>**
- Backup and export your Synology DSM configuration.
- **<a href="https://github.com/007revad/Synology_CPU_temperature">Synology_CPU_temperature</a>**
- **<a href="https://github.com/007revad/Synology_CPU_temperature">Synology CPU temperature</a>**
- Get and log Synology NAS CPU temperature via SSH.
- **<a href="https://github.com/007revad/Synology_SMART_info">Synology_SMART_info</a>**
- Show Synology smart test progress or smart health and attributes.
- **<a href="https://github.com/007revad/Synology_SMART_info">Synology SMART info</a>**
- Show Synology smart test progress or smart health and attributes. Can also email you when important values change.
- **<a href="https://github.com/007revad/Synology_Cleanup_Coredumps">Synology_Cleanup_Coredumps</a>**
- **<a href="https://github.com/007revad/Synology_Cleanup_Coredumps">Synology Cleanup Coredumps</a>**
- Cleanup memory core dumps from crashed processes.
- **<a href="https://github.com/007revad/Synology_toggle_reset_button">Synology_toggle_reset_button</a>**
- **<a href="https://github.com/007revad/Synology_toggle_reset_button">Synology toggle reset button</a>**
- Script to disable or enable the reset button and show current setting.
- **<a href="https://github.com/007revad/Synology_Download_Station_Chrome_Extension">Synology_Download_Station_Chrome_Extension</a>**
- **<a href="https://github.com/007revad/Synology_Download_Station_Chrome_Extension">Synology Download Station Chrome Extension</a>**
- Download Station Chrome Extension.
- **<a href="https://github.com/007revad/Seagate_lowCurrentSpinup">Seagate_lowCurrentSpinup</a>**
- **<a href="https://github.com/007revad/Seagate_lowCurrentSpinup">Seagate low Current Spinup</a>**
- This script avoids the need to buy and install a higher wattage power supply when using multiple large Seagate SATA HDDs.
- **<a href="https://github.com/007revad/Synology_created_date">Synology_created_date</a>**
- **<a href="https://github.com/007revad/Synology_created_date">Synology created date</a>**
- Script to show you the created year and month of your Synology NAS or expansion unit.
- **<a href="https://github.com/007revad/Restore_RS3621_Fan_Speed">Restore RS3621 Fan Speed</a>**
- Script to restore RS3621xs+ and RS3621RPxs Quiet mode and Cool mode fan speeds back to how it was before DSM 7.3.2.
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Back to Contents](#contents)
### Synology hardware restrictions
- **<a href="https://github.com/007revad/Synology_HDD_db">Synology_HDD_db</a>**
- **<a href="https://github.com/007revad/Synology_HDD_db">Synology HDD db</a>**
- Add your SATA or SAS HDDs and SSDs plus SATA and NVMe M.2 drives to your Synology's compatible drive databases, including your Synology M.2 PCIe card and Expansion Unit databases.
- **<a href="https://github.com/007revad/Synology_enable_M2_volume">Synology_enable_M2_volume</a>**
- **<a href="https://github.com/007revad/Synology_enable_M2_volume">Synology enable M2 volume</a>**
- Enable creating volumes with non-Synology M.2 drives.
- Enable Health Info for non-Synology NVMe drives (not in DSM 7.2.1 or later).
- **<a href="https://github.com/007revad/Synology_M2_volume">Synology_M2_volume</a>**
- **<a href="https://github.com/007revad/Synology_M2_volume">Synology M2 volume</a>**
- Easily create an M.2 volume on Synology NAS.
- **<a href="https://github.com/007revad/Synology_enable_M2_card">Synology_enable_M2_card</a>**
- **<a href="https://github.com/007revad/Synology_enable_M2_card">Synology enable M2 card</a>**
- Enable Synology M.2 PCIe cards in Synology NAS that don't officially support them.
- **<a href="https://github.com/007revad/Synology_enable_eunit">Synology_enable_eunit</a>**
- **<a href="https://github.com/007revad/Synology_enable_eunit">Synology enable eunit</a>**
- Enable an unsupported Synology eSATA Expansion Unit models.
- **<a href="https://github.com/007revad/Synology_enable_Deduplication">Synology_enable_Deduplication</a>**
- **<a href="https://github.com/007revad/Synology_enable_Deduplication">Synology enable Deduplication</a>**
- Enable deduplication with non-Synology SSDs and unsupported NAS models.
- **<a href="https://github.com/007revad/Synology_SHR_switch">Synology_SHR_switch</a>**
- **<a href="https://github.com/007revad/Synology_SHR_switch">Synology SHR switch</a>**
- Easily switch between SHR and RAID Groups, or enable RAID F1.
- **<a href="https://github.com/007revad/Synology_enable_sequential_IO">Synology_enable_sequential_IO</a>**
- **<a href="https://github.com/007revad/Synology_enable_sequential_IO">Synology enable sequential IO</a>**
- Enables sequential I/O for your SSD caches, like DSM 6 had.
- **<a href="https://github.com/007revad/Synology_Information_Wiki">Synology_Information_Wiki</a>**
- **<a href="https://github.com/007revad/Synology_Information_Wiki">Synology Information Wiki</a>**
- Information about Synology hardware.
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Back to Contents](#contents)
### 2025 plus models
### Synology 2025 plus models
- **<a href="https://github.com/007revad/Transcode_for_x25">Transcode_for_x25</a>**
- Installs the modules needed for Plex or Jellyfin hardware transcoding in DS425+ and DS225+.
- **<a href="https://github.com/007revad/Transcode_for_x25">Transcode for x25</a>**
- Installs the modules needed for Plex or Jellyfin hardware transcoding on Synology DS425+ and DS225+.
- Available as a package and a script.
- **<a href="https://github.com/007revad/Synology_HDD_db/blob/main/2025_plus_models.md">2025 series or later Plus models</a>**
- Unverified 3rd party drive limitations and unofficial solutions.
@ -161,23 +248,23 @@ ### 2025 plus models
### How To Guides
- **<a href="https://github.com/007revad/Synology_SSH_key_setup">Synology_SSH_key_setup</a>**
- **<a href="https://github.com/007revad/Synology_SSH_key_setup">Synology SSH key setup</a>**
- How to setup SSH key authentication for your Synology.
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Back to Contents](#contents)
### Synology dev
- **<a href="https://github.com/007revad/Download_Synology_Archive">Download_Synology_Archive</a>**
- **<a href="https://github.com/007revad/Download_Synology_Archive">Download Synology Archive</a>**
- Download all or part of the Synology archive.
- **<a href="https://github.com/007revad/Syno_DSM_Extractor_GUI">Syno_DSM_Extractor_GUI</a>**
- **<a href="https://github.com/007revad/Syno_DSM_Extractor_GUI">Syno DSM Extractor GUI</a>**
- Windows GUI for extracting Synology DSM 7 pat files and spk package files.
- **<a href="https://github.com/007revad/ScriptNotify">ScriptNotify</a>**
- DSM 7 package to allow your scripts to send DSM notifications.
- **<a href="https://github.com/007revad/DTC_GUI_for_Windows">DTC_GUI_for_Windows</a>**
- **<a href="https://github.com/007revad/DTC_GUI_for_Windows">DTC GUI for Windows</a>**
- GUI for DTC.exe for Windows.
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Back to Contents](#contents)

512
syno_hdd_db.sh

@ -29,7 +29,7 @@
# /var/packages/StorageManager/target/ui/storage_panel.js
scriptver="v3.6.124"
scriptver="v3.6.137"
script=Synology_HDD_db
repo="007revad/Synology_HDD_db"
scriptname=syno_hdd_db
@ -258,18 +258,21 @@ if [[ $( whoami ) != "root" ]]; then
exit 1
fi
detect_scheduler(){
# Check if stdin is a terminal (interactive)
[ ! -t 0 ] && return 0
# Check parent process
local parent
parent=$(ps -p $PPID -o comm=)
[[ "$parent" =~ (systemd-run|sched|crond) ]] && return 0
# SYNO.Core.TaskS is regular scheduled task
# SYNO.Core.Event is triggered scheduled task
local pid=$PPID
local comm
while [[ "$pid" != "1" && -n "$pid" ]]; do
comm=$(ps -p "$pid" -o comm=)
[[ "$comm" =~ (SYNO.Core.TaskS|SYNO.Core.Event|crond) ]] && return 0
pid=$(ps -p "$pid" -o ppid= | tr -d ' ')
done
return 1
}
# Get DSM major version
dsm=$(/usr/syno/bin/synogetkeyvalue /etc.defaults/VERSION majorversion)
if [[ $dsm -gt "6" ]]; then
@ -282,8 +285,9 @@ minor=$(/usr/syno/bin/synogetkeyvalue /etc.defaults/VERSION minorversion)
dsmversion="$major$minor"
# Get Synology model
model=$(cat /proc/sys/kernel/syno_hw_version)
modelname="$model"
#model=$(cat /proc/sys/kernel/syno_hw_version)
#modelname="$model"
modelname=$(/usr/syno/bin/synogetkeyvalue /etc.defaults/synoinfo.conf upnpmodelname)
# Get CPU platform_name
#platform_name=$(/usr/syno/bin/synogetkeyvalue /etc.defaults/synoinfo.conf platform_name)
@ -305,22 +309,24 @@ smallfixnumber=$(/usr/syno/bin/synogetkeyvalue /etc.defaults/VERSION smallfixnum
# Show DSM full version and model
if [[ $buildphase == GM ]]; then buildphase=""; 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
model=${model,,}
#model=${model,,}
model=${modelname,,}
# Check for dodgy characters after model number
if [[ $model =~ 'pv10-j'$ ]]; then # GitHub issue #10
modelname=${modelname%??????}+ # replace last 6 chars with +
model=${model%??????}+ # replace last 6 chars with +
echo -e "\nUsing model: $model"
elif [[ $model =~ '-j'$ ]]; then # GitHub issue #2
modelname=${modelname%??} # remove last 2 chars
model=${model%??} # remove last 2 chars
echo -e "\nUsing model: $model"
fi
#if [[ $model =~ 'pv10-j'$ ]]; then # GitHub issue #10
# modelname=${modelname%??????}+ # replace last 6 chars with +
# model=${model%??????}+ # replace last 6 chars with +
# echo -e "\nUsing model: $model"
#elif [[ $model =~ '-j'$ ]]; then # GitHub issue #2
# modelname=${modelname%??} # remove last 2 chars
# model=${model%??} # remove last 2 chars
# echo -e "\nUsing model: $model"
#fi
# Get StorageManager version
storagemgrver=$(/usr/syno/bin/synopkg version StorageManager)
@ -339,9 +345,13 @@ if [[ $dsmversion -gt "72" ]]; then
else
SOPinfo="/var/packages/SynoOnlinePack/INFO"
fi
SOPpkgver="$(/usr/syno/bin/synogetkeyvalue $SOPinfo version)"
#echo -e "SynoOnlinePack$v2 version $SOPpkgver\n"
echo "- SynoOnlinePack$v2 version $SOPpkgver"
if [[ -f "$SOPinfo" ]]; then
SOPpkgver="$(/usr/syno/bin/synogetkeyvalue $SOPinfo version)"
#echo -e "SynoOnlinePack$v2 version $SOPpkgver\n"
echo "- SynoOnlinePack$v2 version $SOPpkgver"
else
echo "- SynoOnlinePack$v2 version not found"
fi
#else
# echo ""
fi
@ -350,12 +360,12 @@ fi
if [[ -f "/var/lib/disk-compatibility/${model}_host_v7.version" ]]; then
echo -n "- ${model}_host_v7 version "
cat "/var/lib/disk-compatibility/${model}_host_v7.version"
echo -e "\n"
#echo -e "\n"
fi
if [[ -f "/var/lib/disk-compatibility/${model}_host.version" ]]; then
echo -n "- ${model}_host version "
cat "/var/lib/disk-compatibility/${model}_host.version"
echo -e "\n"
#echo -e "\n"
fi
@ -367,6 +377,19 @@ fi
#echo "" # To keep output readable
# Check if script is running in an interactive shell or from schedule
if [[ -t 1 ]]; then # Running in terminal
echo -e "- Running in an interactive shell (user terminal).\n"
else
# Check if running via task scheduler
if detect_scheduler; then
sch_task="yes"
color="no"
fi
echo -e "- Running from a scheduled task.\n"
fi
# shellcheck disable=SC2317 # Don't warn about unreachable commands in this function
pause(){
# When debugging insert pause command where needed
@ -630,11 +653,14 @@ get_script_vol() {
vol_name=$(df --output=source "/$script_root" | sed 1d) # sed 1d = delete first line
fi
}
get_script_vol # sets $vol_name to /dev/whatever
if grep -qE "^${vol_name#/dev/} .+ nvme" /proc/mdstat; then
ding
echo -e "\n${Yellow}WARNING${Off} Don't store this script on an NVMe volume!"
exit 3
if which lvm >/dev/null; then
# Single bay Synology NAS don't have lvm
get_script_vol # sets $vol_name to /dev/whatever
if grep -qE "^${vol_name#/dev/} .+ nvme" /proc/mdstat; then
ding
echo -e "\n${Yellow}WARNING${Off} Don't store this script on an NVMe volume!"
exit 3
fi
fi
@ -678,7 +704,7 @@ reboot_file="${scriptpath}/syno_hdd_reboot.txt"
if [[ ! -f "$reboot_file" ]]; then
echo "Do NOT delete this file!" > "$reboot_file"
echo "It is used to track if DSM has updated." >> "$reboot_file"
synosetkeyvalue "$reboot_file" dsm_build "$buildnumber"
/usr/syno/bin/synosetkeyvalue "$reboot_file" dsm_build "$buildnumber"
fi
@ -732,11 +758,7 @@ set_writemostly(){
# Restore changes from backups
if [[ $restore == "yes" ]]; then
dbbaklist=($(find $dbpath -maxdepth 1 \( -name "*.db.new.bak" -o -name "*.db.bak" \)))
# Sort array
IFS=$'\n'
dbbakfiles=($(sort <<<"${dbbaklist[*]}"))
unset IFS
readarray -t dbbakfiles < <(find "$dbpath" -maxdepth 1 \( -name "*.db.new.bak" -o -name "*.db.bak" \) ! -name "rule_*" | sort)
echo ""
if [[ ${#dbbakfiles[@]} -gt "0" || -f ${synoinfo}.bak ||\
@ -762,6 +784,35 @@ if [[ $restore == "yes" ]]; then
sed -i "/drive_db_test_url=*/d" "$synoinfo"
sed -i "/drive_db_test_url=*/d" /etc/synoinfo.conf
# Restore SynoOnlinePack version
if [[ $dsmversion -ge "73" ]]; then
# Is DSM 7.3 or later
if [[ -f /var/packages/SynoOnlinePack_v3/INFO ]]; then
SOPinfo="/var/packages/SynoOnlinePack_v3/INFO"
elif [[ -f /var/packages/SynoOnlinePack_v2/INFO ]]; then
SOPinfo="/var/packages/SynoOnlinePack_v2/INFO"
else
SOPinfo="/var/packages/SynoOnlinePack/INFO"
fi
SOPpkgver="$(/usr/syno/bin/synogetkeyvalue $SOPinfo version)"
# Re-enable drive db updates
if [[ ${SOPpkgver:0:4} == "9999" ]]; then
# Remove 9999 from version
/usr/syno/bin/synosetkeyvalue "$SOPinfo" version "${SOPpkgver:4}"
# Check if we re-enabled drive db auto updates
SOPpkgver2="$(/usr/syno/bin/synogetkeyvalue $SOPinfo version)"
if [[ ${SOPpkgver2:0:4} != "9999" ]]; then
echo -e "Re-enabled drive db auto updates."
else
echo -e "${Error}ERROR${Off} Failed to enable drive db auto updates!"
fi
else
echo -e "Drive db auto updates already enabled."
fi
fi
# Restore adapter_cards.conf from backup
# /usr/syno/etc.defaults/adapter_cards.conf
if [[ -f ${adapter_cards}.bak ]]; then
@ -781,8 +832,8 @@ if [[ $restore == "yes" ]]; then
# Make sure they don't lose E10M20-T1 network connection
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_cards2} 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" yes
fi
# Restore model.dtb from backup
@ -847,6 +898,7 @@ if [[ $restore == "yes" ]]; then
done
# Update .db files from Synology
echo -e "\nUpdating .db files from Synology"
/usr/syno/bin/syno_disk_db_update --update
# Enable SynoMemCheck.service if disabled
@ -939,7 +991,7 @@ vendor_from_id(){
echo "$vidlist" >&2
fi
else
echo -e "\n${Error}ERROR{OFF} $vidlist not found!" >&2
echo -e "\n${Error}ERROR${OFF} $vidlist not found!" >&2
fi
;;
esac
@ -1013,20 +1065,22 @@ fixdrivemodel(){
hdmodel=${hdmodel#"FUJISTU "} # Remove "FUJISTU " from start of model name
# Remove any leading spaces
var=$(echo "$var" | sed -e 's/^[[:space:]]*//')
hdmodel=$(echo "$hdmodel" | sed -e 's/^[[:space:]]*//')
elif [[ $1 =~ ^'APPLE HDD '.* ]]; then
# Old drive brands
hdmodel=${hdmodel#"APPLE HDD "} # Remove "APPLE HDD " from start of model name
# Remove any leading spaces
var=$(echo "$var" | sed -e 's/^[[:space:]]*//')
hdmodel=$(echo "$hdmodel" | sed -e 's/^[[:space:]]*//')
fi
}
get_size_gb(){
# $1 is /sys/block/sata1 or /sys/block/nvme0n1 etc
local disk_size_gb
disk_size_gb=$(synodisk --info /dev/"$(basename -- "$1")" 2>/dev/null | grep 'Total capacity' | awk '{print int($4 * 1.073741824)}')
#disk_size_gb=$(/usr/syno/bin/synodisk --info /dev/"$(basename -- "$1")" 2>/dev/null | grep 'Total capacity' | awk '{print int($4 * 1.073741824)}')
# Prevent 6 TB drives getting rounded up to 6001 !!!
disk_size_gb=$(/usr/syno/bin/synodisk --info /dev/"$(basename -- "$1")" 2>/dev/null | grep 'Total capacity' | awk '{gb = $4 * 1.073741824; printf "%d\n", int(gb / 4 + 0.5) * 4}')
echo "$disk_size_gb"
}
@ -1308,8 +1362,32 @@ if [[ $m2 != "no" ]]; then
fi
get_eunit_container_aliases(){
# DSM can report one expansion unit with different model names.
# For example, detection can return RX1217RP while the attached disks'
# runtime container is RX1217-1 and DSM reads the rx1217 drive database.
local ebox_info="$1"
local runtime_root="${2:-/run/synostorage/disks}"
local disk
local container
while IFS= read -r disk; do
[[ -n $disk ]] || continue
container=$(cat "$runtime_root/${disk##*/}/container" 2>/dev/null)
container=$(printf "%s" "$container" | sed -E 's/-[0-9]+$//')
if printf "%s\n" "$container" |
grep -Eqi '^([FRD]XD?[0-9]{3,4})(rp|ii|sas)?$';
then
printf "%s\n" "$container"
fi
done < <(printf "%s\n" "$ebox_info" | awk '/Disk path:/ {print $NF}')
}
# Expansion units
ebox_conected=$(synodisk --enum -t ebox)
ebox_conected=$(/usr/syno/bin/synodisk --enum -t ebox)
if [[ $ebox_conected ]]; then
# Only device tree models have syno_slot_mapping
# eSATA and InfiniBand ports both appear in syno_slot_mapping as:
@ -1317,7 +1395,7 @@ if [[ $ebox_conected ]]; then
# Eunit port 1 - RX1214
if which syno_slot_mapping >/dev/null; then
# syno_slot_mapping does not find SAS eunits
eunitlist=($(syno_slot_mapping | grep 'Eunit port' | awk '{print $5}'))
eunitlist=($(/usr/syno/bin/syno_slot_mapping | grep 'Eunit port' | awk '{print $5}'))
fi
if [[ ${#eunitlist[@]} -eq "0" ]]; then
# Create new /var/log/diskprediction log to ensure newly connected ebox is in latest log
@ -1330,6 +1408,12 @@ if [[ $ebox_conected ]]; then
file=$(ls $path | tail -n1)
eunitlist=($(grep -Eowi "([FRD]XD?[0-9]{3,4})(rp|ii|sas){0,2}" "$path/$file" | uniq))
fi
# Include the model name DSM uses for each expansion disk's runtime
# container. The existing sort below removes duplicates.
while IFS= read -r eunit_alias; do
[[ -n $eunit_alias ]] && eunitlist+=("$eunit_alias")
done < <(get_eunit_container_aliases "$ebox_conected")
fi
# Sort eunitlist array into new eunits array to remove duplicates
@ -1358,27 +1442,37 @@ fi
# Check databases and add our drives if needed
# Host db files
db1list=($(find "$dbpath" -maxdepth 1 -name "*_host*.db"))
db2list=($(find "$dbpath" -maxdepth 1 -name "*_host*.db.new"))
#db1list=($(find "$dbpath" -maxdepth 1 -regextype posix-extended\
# -iregex ".*_host(_v7)?.db"))
#db2list=($(find "$dbpath" -maxdepth 1 -regextype posix-extended\
# -iregex ".*_host(_v7)?.db.new"))
readarray -t db1list < <(find "$dbpath" -maxdepth 1 -name "*_host*.db" ! -name "rule_*" | sort)
readarray -t db2list < <(find "$dbpath" -maxdepth 1 -name "*_host*.db.new" ! -name "rule_*" | sort)
find_eunit_db_files(){
# Match an exact expansion-unit model family while allowing Synology's
# "_v7" and space-delimited filename suffixes. Do not let RX1217 also
# select RX1217RP or RX1217SAS.
local db_dir="$1"
local extension="$2"
local eunit
shift 2
for eunit in "$@"; do
find "$db_dir" -maxdepth 1 -type f \
\( -name "${eunit,,}${extension}" \
-o -name "${eunit,,}_*${extension}" \
-o -name "${eunit,,} *${extension}" \)
done | sort -u
}
# Expansion Unit db files
for i in "${!eunits[@]}"; do
#eunitdb1list+=($(find "$dbpath" -maxdepth 1 -name "${eunits[i],,}*.db"))
eunitdb1list+=($(find "$dbpath" -maxdepth 1 -regextype posix-extended\
-iregex ".*${eunits[i],,}(_v7)?.db"))
#eunitdb2list+=($(find "$dbpath" -maxdepth 1 -name "${eunits[i],,}*.db.new"))
eunitdb2list+=($(find "$dbpath" -maxdepth 1 -regextype posix-extended\
-iregex ".*${eunits[i],,}(_v7)?.db.new"))
done
readarray -t eunitdb1list < <(find_eunit_db_files "$dbpath" ".db" "${eunits[@]}")
readarray -t eunitdb2list < <(find_eunit_db_files "$dbpath" ".db.new" "${eunits[@]}")
# M.2 Card db files
for i in "${!m2cards[@]}"; do
m2carddb1list+=($(find "$dbpath" -maxdepth 1 -name "*_${m2cards[i],,}*.db"))
m2carddb2list+=($(find "$dbpath" -maxdepth 1 -name "*_${m2cards[i],,}*.db.new"))
m2card_db1=$(find "$dbpath" -maxdepth 1 -name "${model}_${m2cards[i],,}*.db")
m2card_db2=$(find "$dbpath" -maxdepth 1 -name "${model}_${m2cards[i],,}*.db.new")
[[ -n "$m2card_db1" ]] && m2carddb1list+=("$m2card_db1")
[[ -n "$m2card_db2" ]] && m2carddb2list+=("$m2card_db2")
done
@ -1392,14 +1486,16 @@ fi
getdbtype(){
# Detect drive db type
# Synology misspelt compatibility as compatbility
if grep -q -F '{"disk_compatbility_info":' "$1"; then
# DSM 7 drive db files start with {"disk_compatbility_info":
if jq -e 'has("disk_compatbility_info")' "$1" >/dev/null 2>&1; then
# DSM 7 drive db files have a top-level disk_compatbility_info key
dbtype=7
elif grep -q -F '{"success":1,"list":[' "$1"; then
# DSM 6 drive db files start with {"success":1,"list":[
elif jq -e '.success == 1 and (.list | type == "array")' "$1" >/dev/null 2>&1; then
# DSM 6 drive db files have success:1 and a list array
dbtype=6
elif [[ ! $1 =~ .*'.db.new' ]]; then
if [[ $(stat -c%s "$1") -eq "0" ]]; then
# .db.new files are legitimately absent/empty on new installs, so only
# warn for .db files
if [[ ! -s "$1" ]]; then
echo -e "${Error}ERROR${Off} $(basename -- "${1}") is 0 bytes!" >&2
else
echo -e "${Error}ERROR${Off} Unknown database type $(basename -- "${1}")!" >&2
@ -1412,25 +1508,79 @@ getdbtype(){
}
sanitize_smart_quotes(){
# Fix manually edited db files edited in iOS or Word. Issue #591
# Replace curly/smart quotes with straight ASCII quotes
# Fixes db files that were hand-edited with an editor/app that
# auto-converts straight quotes to curly quotes, breaking the JSON
local file="$1"
if grep -q $'\xe2\x80\x9c\|\xe2\x80\x9d' "$file" 2>/dev/null; then
sed -i $'s/\xe2\x80\x9c/"/g; s/\xe2\x80\x9d/"/g' "$file"
echo -e "Fixed smart quotes in ${Cyan}$(basename -- "$file")${Off}" >&2
fi
}
backupdb(){
# Backup database file if needed
local bakversion newversion fname
[[ -z "$1" || ! -f "$1" ]] && return 1 # Don't try to backup non-existent files
if [[ $2 == "long" ]]; then
fname="$1"
else
fname=$(basename -- "${1}")
fi
# Fix smart quotes before backing up or using the file, so the
# backup (and every later jq call) sees clean JSON
if [[ "$1" =~ \.db$ || "$1" =~ \.db\.new$ ]]; then
sanitize_smart_quotes "$1"
fi
if [[ ! -f "$1.bak" ]]; then
# No existing backup
if [[ $(basename "$1") == "synoinfo.conf" ]]; then
echo "" >&2 # Formatting for stdout
fi
if [[ $2 == "long" ]]; then
fname="$1"
else
fname=$(basename -- "${1}")
fi
if cp -p "$1" "$1.bak"; then
echo -e "Backed up ${fname}" >&2
if [[ "${1##*.}" == "db" ]]; then
# Backup db version file as well
if [[ -f "${1%.db}.version" ]]; then
cp -p "${1%.db}.version" "${1%.db}.bakver"
fi
fi
else
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%.db}.bakver" ]]; then
# Existing backup has no .bakver file, create one
if [[ -f "${1%.db}.version" ]]; then
cp -p "${1%.db}.version" "${1%.db}.bakver"
fi
fi
bakversion=$(cat "${1%.db}.bakver" 2>/dev/null)
newversion=$(cat "${1%.db}.version" 2>/dev/null)
if [[ "$newversion" -gt "$bakversion" ]]; then
# Newer version db files have been installed
if cp -p "$1" "$1.bak"; then
echo -e "Backed up ${fname}" >&2
# Update db version backup as well
if [[ -f "${1%.db}.version" ]]; then
cp -p "${1%.db}.version" "${1%.db}.bakver"
fi
else
echo -e "${Error}ERROR 5${Off} Failed to backup ${fname}!" >&2
return 1
fi
fi
fi
# Fix permissions if needed
local octal
octal=$(stat -c "%a %n" "$1" | cut -d" " -f1)
if [[ ! $octal -eq 644 ]]; then
chmod 644 "$1"
@ -1575,51 +1725,62 @@ editcount(){
editdb7(){
if [[ $1 == "append" ]]; then # model not in db file
#if sed -i "s/}}}/}},\"$hdmodel\":{$fwstrng$default/" "$2"; then # append
if sed -i "s/}}}/}},\"${hdmodel//\//\\/}\":{$fwstrng$default/" "$2"; then # append
if jq -e --arg hdmodel "$hdmodel" --arg fwrev "$fwrev" \
'.disk_compatbility_info[$hdmodel] | has($fwrev)' "$2" > /dev/null; then
echo -e "Added ${Yellow}$hdmodel ($fwrev)${Off} to ${Cyan}$(basename -- "$2")${Off}"
editcount "$2"
else
echo -e "\n${Error}ERROR{Off} Failed to add $hdmodel ($fwrev) to $(basename -- "$2")${Off}"
fi
else
echo -e "\n${Error}ERROR 6a${Off} Failed to add $hdmodel ($fwrev) to $(basename -- "$2")${Off}"
#exit 6
fi
# $1 is the db file
local dbfile="$1" tmpfile existed
tmpfile="$(mktemp "${dbfile}.XXXXXX")" || {
echo -e "\n${Error}ERROR${Off} Failed to create tmp file for $(basename -- "$dbfile")"
return 1
}
# Was the model already in the db? Determines "Added" vs "Updated" wording
# and whether we also need to write the "default" block.
if jq -c -e --arg model "$hdmodel" '.disk_compatbility_info[$model]' "$dbfile" >/dev/null; then
existed=yes
fi
elif [[ $1 == "insert" ]]; then # model and default exists
#if sed -i "s/\"$hdmodel\":{/\"$hdmodel\":{$fwstrng/" "$2"; then # insert firmware
if sed -i "s/\"${hdmodel//\//\\/}\":{/\"${hdmodel//\//\\/}\":{$fwstrng/" "$2"; then # insert firmware
if jq -e --arg hdmodel "$hdmodel" --arg fwrev "$fwrev" \
'.disk_compatbility_info[$hdmodel] | has($fwrev)' "$2" > /dev/null; then
echo -e "Updated ${Yellow}$hdmodel ($fwrev)${Off} in ${Cyan}$(basename -- "$2")${Off}"
#editcount "$2"
else
echo -e "\n${Error}ERROR{Off} Failed to update $hdmodel for ($fwrev) in $(basename -- "$2")"
fi
if jq -c --arg model "$hdmodel" --arg fw "$fwrev" --argjson fwbn 1 --argjson size_gb "$size_gb" '
def interval:
{
compatibility: "support",
not_yet_rolling_status: "support",
fw_dsm_update_status_notify: false,
barebone_installable: true,
barebone_installable_v2: "auto",
smart_test_ignore: false,
smart_attr_ignore: false
};
if (.disk_compatbility_info[$model] == null) then
.disk_compatbility_info[$model] = {
($fw): { fw_buildnumber: $fwbn, compatibility_interval: [interval] },
default: { size_gb: $size_gb, compatibility_interval: [interval] }
}
else
echo -e "\n${Error}ERROR 6b${Off} Failed to update $hdmodel for ($fwrev) in $(basename -- "$2")"
#exit 6
fi
elif [[ $1 == "empty" ]]; then # db file only contains {}
#if sed -i "s/{}/{\"$hdmodel\":{$fwstrng${default}}/" "$2"; then # empty
#if sed -i "s/{}/{\"${hdmodel//\//\\/}\":{$fwstrng${default}}/" "$2"; then # empty
if sed -i "s/{}/{\"${hdmodel//\//\\/}\":{$fwstrng${default}/" "$2"; then # empty
if jq -e --arg hdmodel "$hdmodel" --arg fwrev "$fwrev" \
'.disk_compatbility_info[$hdmodel] | has($fwrev)' "$2" > /dev/null; then
echo -e "Added ${Yellow}$hdmodel ($fwrev)${Off} to ${Cyan}$(basename -- "$2")${Off}"
editcount "$2"
.disk_compatbility_info[$model][$fw] = { fw_buildnumber: $fwbn, compatibility_interval: [interval] }
end
' "$dbfile" > "$tmpfile"; then
if jq -c -e --arg hdmodel "$hdmodel" --arg fwrev "$fwrev" \
'.disk_compatbility_info[$hdmodel] | has($fwrev)' "$tmpfile" > /dev/null; then
if mv "$tmpfile" "$dbfile"; then
chmod 644 "$dbfile"
if [[ $existed == "yes" ]]; then
echo -e "Updated ${Yellow}$hdmodel ($fwrev)${Off} in ${Cyan}$(basename -- "$dbfile")${Off}"
else
echo -e "Added ${Yellow}$hdmodel ($fwrev)${Off} to ${Cyan}$(basename -- "$dbfile")${Off}"
editcount "$dbfile"
fi
else
echo -e "\n${Error}ERROR{Off} Failed to add $hdmodel ($fwrev) to $(basename -- "$2")"
echo -e "\n${Error}ERROR${Off} Failed to save $(basename -- "$dbfile")"
rm -f "$tmpfile"
fi
else
echo -e "\n${Error}ERROR 6c${Off} Failed to add $hdmodel ($fwrev) to $(basename -- "$2")"
#exit 6
echo -e "\n${Error}ERROR${Off} Failed to add $hdmodel ($fwrev) to $(basename -- "$dbfile")"
rm -f "$tmpfile"
fi
else
echo -e "\n${Error}ERROR${Off} jq failed editing $(basename -- "$dbfile")"
rm -f "$tmpfile"
fi
}
@ -1629,57 +1790,26 @@ updatedb(){
fwrev=$(printf "%s" "$1" | cut -d"," -f 2)
size_gb=$(printf "%s" "$1" | cut -d"," -f 3)
#echo arg1 "$1" >&2 # debug
#echo arg2 "$2" >&2 # debug
#echo hdmodel "$hdmodel" >&2 # debug
#echo fwrev "$fwrev" >&2 # debug
# Check if db file is new or old style
getdbtype "$2"
if [[ $dbtype -gt "6" ]]; then
# db type 7 used from DSM 7.1 and later
if jq -e --arg hdmodel "$hdmodel" --arg fwrev "$fwrev" \
if jq -c -e --arg hdmodel "$hdmodel" --arg fwrev "$fwrev" \
'.disk_compatbility_info[$hdmodel] | has($fwrev)' "$2" > /dev/null; then
echo -e "${Yellow}$hdmodel ($fwrev)${Off} already exists in ${Cyan}$(basename -- "$2")${Off}" >&2
else
#common_string=\"size_gb\":$size_gb,
#common_string="$common_string"\"compatibility_interval\":[{
common_string=\"compatibility_interval\":[{
common_string="$common_string"\"compatibility\":\"support\",
common_string="$common_string"\"not_yet_rolling_status\":\"support\",
common_string="$common_string"\"fw_dsm_update_status_notify\":false,
common_string="$common_string"\"barebone_installable\":true,
common_string="$common_string"\"barebone_installable_v2\":\"auto\",
common_string="$common_string"\"smart_test_ignore\":false,
common_string="$common_string"\"smart_attr_ignore\":false
fwstrng=\"$fwrev\":{
fwstrng="$fwstrng$common_string"
fwstrng="$fwstrng"}]},
#default=\"default\":{
default=\"default\":{\"size_gb\":$size_gb,
default="$default$common_string"
default="$default"}]}}}
# Synology misspelt compatibility as compatbility
if grep -q '"disk_compatbility_info":{}' "$2"; then
# Replace "disk_compatbility_info":{} with
# "disk_compatbility_info":{"WD40PURX-64GVNY0":{"80.00A80":{ ... }}},"default":{ ... }}}}
#echo "Edit empty db file:" # debug
editdb7 "empty" "$2"
elif jq -e --arg hdmodel "$hdmodel" '.disk_compatbility_info[$hdmodel]' "$2" >/dev/null; then
# Replace "WD40PURX-64GVNY0":{ with "WD40PURX-64GVNY0":{"80.00A80":{ ... }}},
#echo "Insert firmware version:" # debug
editdb7 "insert" "$2"
# Entry exists. Check it has fw_buildnumber (added by the #585 fix).
# Entries written by older script versions may be missing it, which
# stops synostgdisk generating compatibility_action for that disk. Issue #598
if jq -c -e --arg hdmodel "$hdmodel" --arg fwrev "$fwrev" \
'.disk_compatbility_info[$hdmodel][$fwrev] | has("fw_buildnumber") | not' \
"$2" > /dev/null; then
backfill_fw_buildnumber "$hdmodel" "$fwrev" "$2"
else
# Add "WD40PURX-64GVNY0":{"80.00A80":{ ... }}},"default":{ ... }}}
#echo "Append drive and firmware:" # debug
editdb7 "append" "$2"
echo -e "${Yellow}$hdmodel ($fwrev)${Off} already exists in ${Cyan}$(basename -- "$2")${Off}" >&2
fi
else
editdb7 "$2"
fi
# Edit existing drives in db with compatibility:unverified # Issue #224
@ -1701,6 +1831,10 @@ updatedb(){
fi
elif [[ $dbtype -eq "6" ]]; then
# db type 6 used up to DSM 7.0.1
local hdmodel_sed
hdmodel_sed="${hdmodel//\"/\\\"}" # escape " for sed/JSON
hdmodel_sed="${hdmodel_sed//\//\\/}" # escape / for sed
if grep -q "$hdmodel" "$2"; then
echo -e "${Yellow}$hdmodel${Off} already exists in ${Cyan}$(basename -- "$2")${Off}" >&2
else
@ -1708,7 +1842,8 @@ updatedb(){
# {"model":"WD60EFRX-68MYMN1","firmware":"82.00A82","rec_intvl":[1]},
# Don't need to add firmware version?
#string="{\"model\":\"${hdmodel}\",\"firmware\":\"${fwrev}\",\"rec_intvl\":\[1\]},"
string="{\"model\":\"${hdmodel}\",\"firmware\":\"\",\"rec_intvl\":\[1\]},"
#string="{\"model\":\"${hdmodel}\",\"firmware\":\"\",\"rec_intvl\":\[1\]},"
string="{\"model\":\"${hdmodel_sed}\",\"firmware\":\"\",\"rec_intvl\":\[1\]},"
# {"success":1,"list":[
startstring="{\"success\":1,\"list\":\["
# example:
@ -1716,7 +1851,7 @@ updatedb(){
#if sed -i "s/$startstring/$startstring$string/" "$2"; then
#if sed -i "s/${startstring//\//\\/}/${startstring//\//\\/}$string/" "$2"; then
if sed -i "s/$startstring/$startstring${string//\//\\/}/" "$2"; then
echo -e "Added ${Yellow}$hdmodel$ ($fwrev){Off} to ${Cyan}$(basename -- "$2")${Off}"
echo -e "Added ${Yellow}$hdmodel$ ($fwrev)${Off} to ${Cyan}$(basename -- "$2")${Off}"
else
ding
echo -e "\n${Error}ERROR 8${Off} Failed to update $(basename -- "$2")${Off}" >&2
@ -1727,15 +1862,48 @@ updatedb(){
}
backfill_fw_buildnumber(){
# $1 hdmodel, $2 fwrev, $3 db file
local dbfile="$3" tmpfile
tmpfile="$(mktemp "${dbfile}.XXXXXX")" || {
echo -e "\n${Error}ERROR${Off} Failed to create tmp file for $(basename -- "$dbfile")"
return 1
}
if jq -c --arg model "$1" --arg fw "$2" --argjson fwbn 1 \
'.disk_compatbility_info[$model][$fw].fw_buildnumber = $fwbn' \
"$dbfile" > "$tmpfile" && mv "$tmpfile" "$dbfile"; then
chmod 644 "$dbfile"
echo -e "Updated ${Yellow}$1 ($2)${Off} in ${Cyan}$(basename -- "$dbfile")${Off} (added missing fw_buildnumber)"
else
echo -e "\n${Error}ERROR${Off} Failed to backfill fw_buildnumber for $1 ($2) in $(basename -- "$dbfile")"
rm -f "$tmpfile"
fi
}
# Fix "size_gb": 6001, for 6 TB drives caused by v3.5.104 to v3.6.126
if [[ "${#db1list[@]}" -gt "0" ]]; then
for i in "${!db1list[@]}"; do
sed -i 's/"size_gb": 6001/"size_gb": 6000/g' "${db1list[i]}"
sed -i 's/"size_gb":6001/"size_gb":6000/g' "${db1list[i]}"
done
fi
if [[ "${#db2list[@]}" -gt "0" ]]; then
for i in "${!db2list[@]}"; do
sed -i 's/"size_gb": 6001/"size_gb": 6000/g' "${db2list[i]}"
sed -i 's/"size_gb":6001/"size_gb":6000/g' "${db2list[i]}"
done
fi
# Fix ,, instead of , bug caused by v3.3.75
if [[ "${#db1list[@]}" -gt "0" ]]; then
for i in "${!db1list[@]}"; do
sed -i "s/,,/,/" "${db1list[i]}"
sed -i "s/,,/,/" "${db1list[i]}"
done
fi
if [[ "${#db2list[@]}" -gt "0" ]]; then
for i in "${!db2list[@]}"; do
sed -i "s/,,/,/" "${db2list[i]}"
sed -i "s/,,/,/" "${db2list[i]}"
done
fi
@ -1828,7 +1996,7 @@ enable_card(){
# /usr/syno/etc/adapter_cards.conf
/usr/syno/bin/set_section_key_value "$adapter_cards2" "$2" "$modelrplowercase" yes
echo -e "Enabled ${Yellow}$3${Off} for ${Cyan}$modelname${Off}" >&2
rebootmsg=yes
rebootmsg=yes # Show reboot message at end
else
echo -e "${Error}ERROR 9${Off} Failed to enable $3 for ${modelname}!" >&2
fi
@ -2060,7 +2228,7 @@ edit_modeldtb(){
chmod a+r "$dtb_file"
chown root:root "$dtb_file"
cp -pu "$dtb_file" "$dtb2_file" # Copy dtb file to /etc
rebootmsg=yes
rebootmsg=yes # Show reboot message at end
else
echo -e "${Error}ERROR${Off} Missing /usr/sbin/dtc or not executable!" >&2
fi
@ -2119,11 +2287,15 @@ 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"
for idrive in "${internal_drives[@]}"; do
if [[ ! ${ssds_writemostly[*]} =~ $idrive ]]; then
set_writemostly writemostly "$idrive"
fi
done
if [[ ${ssds_writemostly[*]} =~ "nvme" ]]; then
echo "NVMe drives don't have DSM system or swap partitions"
else
for idrive in "${internal_drives[@]}"; do
if [[ ! ${ssds_writemostly[*]} =~ $idrive ]]; then
set_writemostly writemostly "$idrive"
fi
done
fi
else
# Get list of internal HDDs and qty of SSDs
@ -2148,6 +2320,8 @@ if [[ $ssd == "yes" ]]; then
for idrive in "${internal_hdds[@]}"; do
set_writemostly writemostly "$idrive"
done
else
echo -e "\nNo internal 2.5 inch SSDs found so not setting write mostly on the HDDs"
fi
fi
fi
@ -2666,15 +2840,16 @@ if [[ $show_trim_warning == "yes" ]]; then
echo "https://tinyurl.com/ssd-trim"
fi
# Show reboot message or reboot cleanly once if needed
if [[ $do_reboot == "yes" && $sch_task == "yes" ]];then
if [[ $do_reboot == "yes" && $sch_task == "yes" ]]; then
# Reboot cleanly after DSM update if needed
previous_build="$(synogetkeyvalue "$reboot_file" dsm_build)"
previous_build="$(/usr/syno/bin/synogetkeyvalue "$reboot_file" dsm_build)"
if [[ $buildnumber -gt "$previous_build" ]]; then
synosetkeyvalue "$reboot_file" dsm_build "$buildnumber" # Update buildnumber
/usr/syno/bin/synosetkeyvalue "$reboot_file" dsm_build "$buildnumber" # Update buildnumber
echo -e "\nDSM has updated from build $previous_build to $buildnumber"
echo "Rebooting..."
synoshutdown --reboot # Reboot cleanly
/usr/syno/sbin/synoshutdown --reboot # Reboot cleanly
exit
fi
elif [[ $dsm -eq "6" || $rebootmsg == "yes" ]]; then
@ -2683,4 +2858,3 @@ elif [[ $dsm -eq "6" || $rebootmsg == "yes" ]]; then
fi
exit

92
tests/test_expansion_unit_db_selection.sh

@ -0,0 +1,92 @@
#!/usr/bin/env bash
set -euo pipefail
repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
script="$repo_root/syno_hdd_db.sh"
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT
extract_function() {
local function_name="$1"
sed -n "/^${function_name}(){/,/^}/p" "$script"
}
eval "$(extract_function get_eunit_container_aliases)"
eval "$(extract_function find_eunit_db_files)"
mkdir -p "$tmpdir/runtime/sata13" "$tmpdir/db"
printf '%s\n' "RX1217-1" > "$tmpdir/runtime/sata13/container"
ebox_info=$(cat <<'EOF'
************ Disk Info ***************
>> Disk id: 1
>> Slot id: -1
>> Disk path: /dev/sata13
>> Disk model: ST4000VN006-3CW104
EOF
)
mapfile -t runtime_aliases < <(
get_eunit_container_aliases "$ebox_info" "$tmpdir/runtime"
)
if [[ ${runtime_aliases[*]} != "RX1217" ]]; then
echo "Expected runtime alias RX1217, got: ${runtime_aliases[*]-<none>}" >&2
exit 1
fi
eunitlist=("RX1217rp" "${runtime_aliases[@]}")
mapfile -t eunits < <(printf '%s\n' "${eunitlist[@]}" | sort -u)
touch \
"$tmpdir/db/rx1217.db" \
"$tmpdir/db/rx1217 module_v7.db" \
"$tmpdir/db/rx1217_v7.db" \
"$tmpdir/db/rx1217rp.db" \
"$tmpdir/db/rx1217rp_v7.db" \
"$tmpdir/db/rx1217sas_v7.db" \
"$tmpdir/db/rx1217.db.new" \
"$tmpdir/db/rx1217rp.db.new" \
"$tmpdir/db/rx1217sas_v7.db.new"
mapfile -t selected < <(
find_eunit_db_files "$tmpdir/db" ".db" "${eunits[@]}" |
while IFS= read -r file; do basename "$file"; done |
sort
)
expected=(
"rx1217 module_v7.db"
"rx1217.db"
"rx1217_v7.db"
"rx1217rp.db"
"rx1217rp_v7.db"
)
if [[ ${selected[*]} != "${expected[*]}" ]]; then
echo "Unexpected expansion-unit database selection" >&2
printf 'Expected: %s\n' "${expected[*]}" >&2
printf 'Actual: %s\n' "${selected[*]-<none>}" >&2
exit 1
fi
mapfile -t selected_new < <(
find_eunit_db_files "$tmpdir/db" ".db.new" "${eunits[@]}" |
while IFS= read -r file; do basename "$file"; done |
sort
)
expected_new=(
"rx1217.db.new"
"rx1217rp.db.new"
)
if [[ ${selected_new[*]} != "${expected_new[*]}" ]]; then
echo "Unexpected expansion-unit .db.new selection" >&2
printf 'Expected: %s\n' "${expected_new[*]}" >&2
printf 'Actual: %s\n' "${selected_new[*]-<none>}" >&2
exit 1
fi
echo "PASS: runtime aliases select RX1217 and RX1217RP databases without RX1217SAS"
Loading…
Cancel
Save