[GH-ISSUE #27] Script trying to update from root dir instead of working directory where file is located #518

Closed
opened 2026-03-11 11:38:13 +03:00 by kerem · 13 comments
Owner

Originally created by @sthulin on GitHub (Mar 22, 2023).
Original GitHub issue: https://github.com/007revad/Synology_HDD_db/issues/27

There is a newer version of this script available. Current version: v1.2.19 Latest version: v1.2.20 Do you want to download v1.2.20 now? {y/n] y % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 239k 0 239k 0 0 497k 0 --:--:-- --:--:-- --:--:-- 931k curl: Saved to filename 'Synology_HDD_db-1.2.20.tar.gz' ERROR /root/Synology_HDD_db-1.2.20.tar.gz not found!

Perhaps you can have it download to the directory the script is in instead? Or maybe /tmp?

Originally created by @sthulin on GitHub (Mar 22, 2023). Original GitHub issue: https://github.com/007revad/Synology_HDD_db/issues/27 `There is a newer version of this script available. Current version: v1.2.19 Latest version: v1.2.20 Do you want to download v1.2.20 now? {y/n] y % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 239k 0 239k 0 0 497k 0 --:--:-- --:--:-- --:--:-- 931k curl: Saved to filename 'Synology_HDD_db-1.2.20.tar.gz' ERROR /root/Synology_HDD_db-1.2.20.tar.gz not found!` Perhaps you can have it download to the directory the script is in instead? Or maybe /tmp?
kerem 2026-03-11 11:38:13 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@007revad commented on GitHub (Mar 22, 2023):

Are you running the script as root or as a user with sudo

<!-- gh-comment-id:1480390472 --> @007revad commented on GitHub (Mar 22, 2023): Are you running the script as root or as a user with sudo <script>? We definitely don't want to be downloading stuff to /root because if it gets to full it can cause DSM updates to fail. Since I download the new version's tar.gz release then untar it and delete the .tar.gz file I should be downloading it to /tmp. And unpacking it to the script's location is a good idea because then I don't have to check if the person has home services enabled.
Author
Owner

@007revad commented on GitHub (Mar 22, 2023):

curl: Saved to filename 'Synology_HDD_db-1.2.20.tar.gz' ERROR /root/Synology_HDD_db-1.2.20.tar.gz not found!

This raises the question of where did curl save the file to? You must have a copy of Synology_HDD_db-1.2.20.tar.gz somewhere. It might be in / or in /var/services/homes

<!-- gh-comment-id:1480392626 --> @007revad commented on GitHub (Mar 22, 2023): > curl: Saved to filename 'Synology_HDD_db-1.2.20.tar.gz' ERROR /root/Synology_HDD_db-1.2.20.tar.gz not found! This raises the question of where did curl save the file to? You must have a copy of Synology_HDD_db-1.2.20.tar.gz somewhere. It might be in / or in /var/services/homes
Author
Owner

@sthulin commented on GitHub (Mar 23, 2023):

i'm logged in as a user using sudo. It downloaded the file to the working directory i was in (just also happens to be the script directory). So why it's going to /root/ to find it is beyond me since that's not where it is.

<!-- gh-comment-id:1480418187 --> @sthulin commented on GitHub (Mar 23, 2023): i'm logged in as a user using sudo. It downloaded the file to the working directory i was in (just also happens to be the script directory). So why it's going to /root/ to find it is beyond me since that's not where it is.
Author
Owner

@007revad commented on GitHub (Mar 23, 2023):

I just updated the script to v1.2.23 https://github.com/007revad/Synology_HDD_db

  • Changed 'latest version check' to download to /tmp and extract files to the script's location.
<!-- gh-comment-id:1480547254 --> @007revad commented on GitHub (Mar 23, 2023): I just updated the script to v1.2.23 https://github.com/007revad/Synology_HDD_db - Changed 'latest version check' to download to /tmp and extract files to the script's location.
Author
Owner

@sthulin commented on GitHub (Mar 23, 2023):

ok thanks, i've downloaded that but i need to wait until v1.2.24 to check

<!-- gh-comment-id:1481718481 --> @sthulin commented on GitHub (Mar 23, 2023): ok thanks, i've downloaded that but i need to wait until v1.2.24 to check
Author
Owner

@007revad commented on GitHub (Mar 23, 2023):

If you have a text editor that won't change the line endings (like Notepad++) you can edit line 92 of the script to make it think it's an earlier version.

Change this line: scriptver="v1.2.23" to scriptver="v1.2.22" then save the change and run the script.

<!-- gh-comment-id:1482017986 --> @007revad commented on GitHub (Mar 23, 2023): If you have a text editor that won't change the line endings (like Notepad++) you can edit line 92 of the script to make it think it's an earlier version. Change this line: `scriptver="v1.2.23"` to `scriptver="v1.2.22"` then save the change and run the script.
Author
Owner

@sthulin commented on GitHub (Mar 24, 2023):

so i did that on a 1.2.23 and its not overwriting my file. I see a .23 folder and contents in /tmp, so it's just not overwriting the file i was executing.

/volume1/Stuff/Stuff/Scripts$ sudo ./syno_hdd_db.sh 
Password: 
Synology_HDD_db v1.2.22
DS1817+-j DSM 6.2.4 
Using model: ds1817+

There is a newer version of this script available.
Current version: v1.2.22
Latest version:  v1.2.23
Do you want to download v1.2.23 now? {y/n]
y
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  239k    0  239k    0     0   373k      0 --:--:-- --:--:-- --:--:--  373k
curl: Saved to filename 'Synology_HDD_db-1.2.23.tar.gz'

v1.2.23 and changes.txt are in  ./Synology_HDD_db-1.2.23
Do you want to stop this script so you can run the new one? {y/n]
y

/volume1/Stuff/Stuff/Scripts$ sudo ./syno_hdd_db.sh 
Synology_HDD_db v1.2.22
DS1817+-j DSM 6.2.4 
Using model: ds1817+

There is a newer version of this script available.
Current version: v1.2.22
Latest version:  v1.2.23
Do you want to download v1.2.23 now? {y/n]

<!-- gh-comment-id:1482098900 --> @sthulin commented on GitHub (Mar 24, 2023): so i did that on a 1.2.23 and its not overwriting my file. I see a .23 folder and contents in /tmp, so it's just not overwriting the file i was executing. ``` /volume1/Stuff/Stuff/Scripts$ sudo ./syno_hdd_db.sh Password: Synology_HDD_db v1.2.22 DS1817+-j DSM 6.2.4 Using model: ds1817+ There is a newer version of this script available. Current version: v1.2.22 Latest version: v1.2.23 Do you want to download v1.2.23 now? {y/n] y % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 239k 0 239k 0 0 373k 0 --:--:-- --:--:-- --:--:-- 373k curl: Saved to filename 'Synology_HDD_db-1.2.23.tar.gz' v1.2.23 and changes.txt are in ./Synology_HDD_db-1.2.23 Do you want to stop this script so you can run the new one? {y/n] y /volume1/Stuff/Stuff/Scripts$ sudo ./syno_hdd_db.sh Synology_HDD_db v1.2.22 DS1817+-j DSM 6.2.4 Using model: ds1817+ There is a newer version of this script available. Current version: v1.2.22 Latest version: v1.2.23 Do you want to download v1.2.23 now? {y/n] ```
Author
Owner

@007revad commented on GitHub (Mar 24, 2023):

The .tar.gz file in /tmp should have been deleted after it was unpacked. If you're using WinSCP make sure to refresh the directory contents (Ctrl+R).

It currently does not replace the existing script. I thought the user may want to keep both the old version and the new version.
I did want to replace the existing script with the new one and automatically launch it in the shell but I couldn't figure out how to make the script exit and launch itself.

Your copy and paste just made me realise that once the script closes after updating all the user has to do is press the up arrow and press enter to launch the updated script. So I need a way to overwrite the script without it affecting the currently running old script (so it exits cleanly without error. I have a few thoughts.

<!-- gh-comment-id:1482266761 --> @007revad commented on GitHub (Mar 24, 2023): The .tar.gz file in /tmp should have been deleted after it was unpacked. If you're using WinSCP make sure to refresh the directory contents (Ctrl+R). It currently does not replace the existing script. I thought the user may want to keep both the old version and the new version. I did want to replace the existing script with the new one and automatically launch it in the shell but I couldn't figure out how to make the script exit and launch itself. Your copy and paste just made me realise that once the script closes after updating all the user has to do is press the up arrow and press enter to launch the updated script. So I need a way to overwrite the script without it affecting the currently running old script (so it exits cleanly without error. I have a few thoughts.
Author
Owner

@007revad commented on GitHub (Mar 26, 2023):

The latest version, v1.2.27, now:

  1. Downloads the .tar.gz file to /tmp
  2. Unpacks it to /tmp/Synology_HDD_db-
  3. Copies the syno_hdd_db.sh and README.txt to running script's location, overwriting the existing syno_hdd_db.sh and README.txt files.
  4. Deletes the /tmp/Synology_HDD_db-.tar.gz file and /tmp/Synology_HDD_db- folder.
<!-- gh-comment-id:1483969857 --> @007revad commented on GitHub (Mar 26, 2023): The latest version, v1.2.27, now: 1. Downloads the .tar.gz file to /tmp 2. Unpacks it to /tmp/Synology_HDD_db-<version> 3. Copies the syno_hdd_db.sh and README.txt to running script's location, overwriting the existing syno_hdd_db.sh and README.txt files. 4. Deletes the /tmp/Synology_HDD_db-<version>.tar.gz file and /tmp/Synology_HDD_db-<version> folder.
Author
Owner

@sthulin commented on GitHub (Mar 26, 2023):

so i grabbed the latest file and modified it to think it's .26 ... i'm not sure where its copying the file to, but it didn't overwrite it and there was no new readme file

/volume1/Stuff/Stuff/Scripts$ sudo ./syno_hdd_db.sh 
Synology_HDD_db v1.2.26
DS1817+-j DSM 6.2.4-25556 
Using model: ds1817+

There is a newer version of this script available.
Current version: v1.2.26
Latest version:  v1.2.27
Do you want to download v1.2.27 now? [y/n]
y
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  247k    0  247k    0     0   409k      0 --:--:-- --:--:-- --:--:--  409k
curl: Saved to filename 'Synology_HDD_db-1.2.27.tar.gz'

v1.2.27 and changes.txt downloaded to: .
Do you want to stop this script so you can run the new one? [y/n]
y

/volume1/Stuff/Stuff/Scripts$ ls
syno_hdd_db.sh

/volume1/Stuff/Stuff/Scripts$ sudo ./syno_hdd_db.sh 
Synology_HDD_db v1.2.26
DS1817+-j DSM 6.2.4-25556 
Using model: ds1817+

There is a newer version of this script available.
Current version: v1.2.26
Latest version:  v1.2.27
Do you want to download v1.2.27 now? [y/n]

<!-- gh-comment-id:1483974541 --> @sthulin commented on GitHub (Mar 26, 2023): so i grabbed the latest file and modified it to think it's .26 ... i'm not sure where its copying the file to, but it didn't overwrite it and there was no new readme file ``` /volume1/Stuff/Stuff/Scripts$ sudo ./syno_hdd_db.sh Synology_HDD_db v1.2.26 DS1817+-j DSM 6.2.4-25556 Using model: ds1817+ There is a newer version of this script available. Current version: v1.2.26 Latest version: v1.2.27 Do you want to download v1.2.27 now? [y/n] y % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 247k 0 247k 0 0 409k 0 --:--:-- --:--:-- --:--:-- 409k curl: Saved to filename 'Synology_HDD_db-1.2.27.tar.gz' v1.2.27 and changes.txt downloaded to: . Do you want to stop this script so you can run the new one? [y/n] y /volume1/Stuff/Stuff/Scripts$ ls syno_hdd_db.sh /volume1/Stuff/Stuff/Scripts$ sudo ./syno_hdd_db.sh Synology_HDD_db v1.2.26 DS1817+-j DSM 6.2.4-25556 Using model: ds1817+ There is a newer version of this script available. Current version: v1.2.26 Latest version: v1.2.27 Do you want to download v1.2.27 now? [y/n] ```
Author
Owner

@sthulin commented on GitHub (Mar 27, 2023):

so it just seems to be that it can't handle . as the directory. If i type out the full path it downloads and overwrites the file.

:sudo /volume1/Stuff/Stuff/Scripts/syno_hdd_db.sh 
Synology_HDD_db v1.2.28
DS1817+-j DSM 6.2.4-25556 
Using model: ds1817+

There is a newer version of this script available.
Current version: v1.2.28
Latest version:  v1.2.29
Do you want to download v1.2.29 now? [y/n]
y
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  247k    0  247k    0     0   647k      0 --:--:-- --:--:-- --:--:--  647k
curl: Saved to filename 'Synology_HDD_db-1.2.29.tar.gz'

v1.2.29 and changes.txt downloaded to: /volume1/Stuff/Stuff/Scripts
Do you want to stop this script so you can run the new one? [y/n]
y

:/volume1/Stuff/Stuff/Scripts$ ls
CHANGES.txt  syno_hdd_db.sh

:/volume1/Stuff/Stuff/Scripts$ sudo /volume1/Stuff/Stuff/Scripts/syno_hdd_db.sh 
Synology_HDD_db v1.2.29
DS1817+-j DSM 6.2.4-25556 
Using model: ds1817+
<!-- gh-comment-id:1484286608 --> @sthulin commented on GitHub (Mar 27, 2023): so it just seems to be that it can't handle . as the directory. If i type out the full path it downloads and overwrites the file. ``` :sudo /volume1/Stuff/Stuff/Scripts/syno_hdd_db.sh Synology_HDD_db v1.2.28 DS1817+-j DSM 6.2.4-25556 Using model: ds1817+ There is a newer version of this script available. Current version: v1.2.28 Latest version: v1.2.29 Do you want to download v1.2.29 now? [y/n] y % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 247k 0 247k 0 0 647k 0 --:--:-- --:--:-- --:--:-- 647k curl: Saved to filename 'Synology_HDD_db-1.2.29.tar.gz' v1.2.29 and changes.txt downloaded to: /volume1/Stuff/Stuff/Scripts Do you want to stop this script so you can run the new one? [y/n] y :/volume1/Stuff/Stuff/Scripts$ ls CHANGES.txt syno_hdd_db.sh :/volume1/Stuff/Stuff/Scripts$ sudo /volume1/Stuff/Stuff/Scripts/syno_hdd_db.sh Synology_HDD_db v1.2.29 DS1817+-j DSM 6.2.4-25556 Using model: ds1817+ ```
Author
Owner

@007revad commented on GitHub (Mar 27, 2023):

Yes. I just noticed the ./ in your comment a few of hours ago.

I've now got it working correctly when run with ./ and when run run via a symlink (in case someone creates a symlink in /usr/bin etc that points to where the .sh file is). I also added some error checking and error messages if any step in the download/update process fails.

Can you try v1.2.30
https://github.com/007revad/Synology_HDD_db/releases

You'll need to edit the scriptver="v1.2.30" on line 95 to a lower number to test it.

<!-- gh-comment-id:1484374624 --> @007revad commented on GitHub (Mar 27, 2023): Yes. I just noticed the `./` in your comment a few of hours ago. I've now got it working correctly when run with ./ and when run run via a symlink (in case someone creates a symlink in /usr/bin etc that points to where the .sh file is). I also added some error checking and error messages if any step in the download/update process fails. Can you try v1.2.30 https://github.com/007revad/Synology_HDD_db/releases You'll need to edit the `scriptver="v1.2.30"` on line 95 to a lower number to test it.
Author
Owner

@sthulin commented on GitHub (Mar 27, 2023):

looks like its working now. this is great stuff!

/volume1/Stuff/Stuff/Scripts$ sudo ./syno_hdd_db.sh 
Synology_HDD_db v1.2.29
DS1817+-j DSM 6.2.4-25556 
Using model: ds1817+

There is a newer version of this script available.
Current version: v1.2.29
Latest version:  v1.2.30
Do you want to download v1.2.30 now? [y/n]
y
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  248k    0  248k    0     0   526k      0 --:--:-- --:--:-- --:--:--  526k
curl: Saved to filename 'Synology_HDD_db-1.2.30.tar.gz'

v1.2.30 and changes.txt downloaded to: /volume1/Stuff/Stuff/Scripts
Do you want to stop this script so you can run the new one? [y/n]
y

:/volume1/Stuff/Stuff/Scripts$ ls
CHANGES.txt  syno_hdd_db.sh

:/volume1/Stuff/Stuff/Scripts$ sudo ./syno_hdd_db.sh 
Synology_HDD_db v1.2.30
DS1817+-j DSM 6.2.4-25556 
Using model: ds1817+

<!-- gh-comment-id:1484382785 --> @sthulin commented on GitHub (Mar 27, 2023): looks like its working now. this is great stuff! ``` /volume1/Stuff/Stuff/Scripts$ sudo ./syno_hdd_db.sh Synology_HDD_db v1.2.29 DS1817+-j DSM 6.2.4-25556 Using model: ds1817+ There is a newer version of this script available. Current version: v1.2.29 Latest version: v1.2.30 Do you want to download v1.2.30 now? [y/n] y % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 248k 0 248k 0 0 526k 0 --:--:-- --:--:-- --:--:-- 526k curl: Saved to filename 'Synology_HDD_db-1.2.30.tar.gz' v1.2.30 and changes.txt downloaded to: /volume1/Stuff/Stuff/Scripts Do you want to stop this script so you can run the new one? [y/n] y :/volume1/Stuff/Stuff/Scripts$ ls CHANGES.txt syno_hdd_db.sh :/volume1/Stuff/Stuff/Scripts$ sudo ./syno_hdd_db.sh Synology_HDD_db v1.2.30 DS1817+-j DSM 6.2.4-25556 Using model: ds1817+ ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Synology_HDD_db#518
No description provided.