Under OS 5 i found script /opt/wd/sbin/send_pending_shutdown.sh - is this the correct script to shutdown (hibernate) the device (works fine using option -s 0) via ssh - or should i use shutdown.sh ?
Which script exactly is executed if i click on “Hibernate” on UI ?
Thank you for supplying a new approach for version OS 5, but it doesn’ really work for me.
First, using: /opt/wd/sbin/send_pending_shutdown.sh -s 0
with plink (puTTy) like: plink -ssh -batch sshd@192.168.0.XXX -pw XXXXXX /opt/wd/sbin/send_pending_shutdown.sh -s 0
doesn’t work for me - I can’t WOL the system afterwards…
Second, in curl -sSL -o /dev/null -c /home/me/cookie.dat --header 'Content-Type:application/json' --request POST --data '{"username":"admin","password":"XXXXX"}' http://192.168.0.XXX/nas/v1/auth
I get the error
curl: (23) Failed writing body (0 != 31)
can you assist or share your solution? - I believe it is also a batch file…
Thank you very much!
thank you!
I found this out myself, but I am still struggling with the rest. should it be like this?: curl -sSL -o dev.txt -c cookie.txt --header 'Content-Type:application/json' --request POST --data '{"username":"admin","password":"XXX"}' http://192.168.0.XXX/nas/v1/auth
in the output file (dev.txt) i get the output: {"error":"0","eula_status":"1"}
and also no cookie file (cookie.txt) is created.
any idea?
but still no cookie.txt and also {"error":"0","eula_status":"1"} in dev.txt
edit: now I understand that -sSL is something completly different from --ssl
thank you. I actually forgot to do this, but even with the encoded password it doesn’t work either.
Any further suggestions?
current file looks like: curl -sSL -o dev.txt -c C:\cookie.dat --header 'Content-Type:application/json' --request POST --data '{"username":"admin","password":"MGI1dDV[...]EX2FkbWlu"}' http://192.168.0.XXX/nas/v1/auth curl -sSL -b C:\cookie.dat http://192.168.0.XXX/cgi-bin/system_mgr.cgi?cmd=cgi_shutdown
Thank you! It works
I actually had a similar thing to program at work with curl: triggering a flow (microsoft flow) with a HTTP POST, which worked after I changed the quotes as I needed here…
I still think that somethin with using different WOL sources (and ports (7/9)) messed up the system.
Anyhow, it works! hopefully this post is usefull for others as well!
I thought I share my script, which is far away from being optimised, but all necessary aspects should be in it and therefore might inspire some others for creating their own backup batch.
Enjoy:
@echo off
choice /t 60 /d n /m “do you like to shutdown after backup?”
if errorlevel 1 set shutdown=true
if errorlevel 2 set shutdown=false
REM start NAS via WOL and wait till it is available
wolcmd […MAC…] […IP…] […SUBNET…] 9
REM […MAC…] = MAC address, etc. + download Welcome To Depicus - Home of the Geek
for /L %%N IN (1, 1, 30) DO (
timeout /t 10
echo waiting ^(%%N^) for NAS to be available…
if exist “\\MyCloudEX2Ultra\[…]\BACKUP-Info.txt” (
REM choose any file as an indicator (ping doesn’t work as device is still booting while it can be pinged)
goto available
)
)
goto fail
:available
TASKKILL /F /IM “thunderbird.exe”
robocopy “C:\Users[…]” “\\MyCloudEX2Ultra\[…]” /xf *.$_$ /mir /z /r:1 /w:0 /fft /xd C:\[…]
REM xf=exclude file, xd=exclude dir, etc.
goto success
:success
echo succesfully backuped at: %date% >> “\\MyCloudEX2Ultra\[…]\BACKUP-Info.txt”
REM now shutdown NAS again
curl -sSL -c cookie.dat --header “Content-Type:application/json” --request POST --data “{\“username\”:\“admin\”,\“password\”:\”[…pass64…]\“}” http://[…IP…]/nas/v1/auth
REM […pass64…] = Base64 Encoding of "[...pass...]" - Online; […IP…] = like 192.168.X.Y
curl -b cookie.dat http://[…IP…]/cgi-bin/system_mgr.cgi?cmd=cgi_shutdown
REM […IP…] = like 192.168.X.Y
del cookie.dat
echo.
echo.
echo.
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo º User º
echo º backuped! º
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
goto end
:fail
echo failed to reach NAS!
timeout /t 20
goto end
:end
if %shutdown%==true (
echo shutting down PC after timeout ^(with 120s delay to wait for NAS^)!
timeout /t 30
shutdown -s -t 120
)
pause > nul
Hello. Is there a way to insert a script at boot up in OS5 to run RSYNC?. I could launch my script using WDCrack in OS3, but after the upgrade I don’t know how to proceed.
Thanks!