007revad / Synology_HDD_db

Add your HDD, SSD and NVMe drives to your Synology's compatible drive database and a lot more

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Script trying to update from root dir instead of working directory where file is located

sthulin opened this issue · comments

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?

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.

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

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.

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.

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

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.

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]

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.

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.

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]

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+

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.

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+