D-Link Forums

The Graveyard - Products No Longer Supported => D-Link Storage => DNS-323 => Topic started by: AndyB on September 30, 2009, 04:44:09 AM

Title: Shutdown script - provided here ...
Post by: AndyB on September 30, 2009, 04:44:09 AM
Hi,

I assume that I'm not the only one having this problem:

More then DNS-323 and just one UPS (with USB Signalling) so - only the NAS attached to the UPS via USB will shutdown automatically.

I created a simple shutdown script for windows.
It allows you to shutdown the NAS via wget (windows build) and 2 http calls.

Wget (all in one binary - no libraries needed)
Download for Win32: http://users.ugent.be/~bpuype/wget/ (http://users.ugent.be/~bpuype/wget/)
thanks to Bart Puype for the wget build ;-)

When the main server shuts down due to a UPS Command, the script is called by the UPS Software during shutdown.

Cheers,
AndyB

Just copy the following lines to notepad and save as nas_shutdown.bat

Code: [Select]
@echo off
rem --- D-Link DNS-323 Shutdown Script
rem --- created by Andreas Baumgärtner
rem --- version 1.0
rem --- 20090930

rem --- Info:
rem --- don't change the uname!!
rem --- change passwd and ip to your needs
rem --- timeout is in seconds adjust it to your needs - for me 5 seconds where enough
rem --- only one try otherwise the script could delay the shutdown for too long
 
echo Shutting down NAS_002 ...
set UNAME=admin
set PASSWD=yourpassword
set IP=172.17.0.6
wget  --tries=1 --timeout=5 "http://%IP%/goform/formLogin?f_login_type=0&f_LOGIN_NAME=%UNAME%&f_LOGIN_PASSWD=%PASSWD%"
IF %ERRORLEVEL%==0 (
wget --tries=1 --timeout=5 "http://%IP%/goform/sysShutDown?shootdown"
) ELSE (
echo Unable to shutdown NAS_002
)

echo Shutting down NAS_001 ...
set UNAME=admin
set PASSWD=yourpassword2
set IP=172.17.0.5
wget  --tries=1 --timeout=5 "http://%IP%/goform/formLogin?f_login_type=0&f_LOGIN_NAME=%UNAME%&f_LOGIN_PASSWD=%PASSWD%"
IF %ERRORLEVEL%==0 (
wget --tries=1 --timeout=5 "http://%IP%/goform/sysShutDown?shootdown"
) ELSE (
echo Unable to shutdown NAS_001
)

SET IP=
SET PASSWD=
SET UNAME=
Title: Re: Shutdown script - provided here ...
Post by: hilaireg on September 30, 2009, 05:51:09 AM
If there was a usefulness rating on threads in this forum and 10 = Absolutely Amazing ...

I'd give this thread a 8.99.

... I never give out 9's & 10's  ;)


Nicely done,

 :)
Title: Re: Shutdown script - provided here ...
Post by: rsbrace on September 30, 2009, 03:32:39 PM
Nice, I'm going to give it a try tonight.
Title: Re: Shutdown script - provided here ...
Post by: ECF on October 02, 2009, 02:35:34 PM
Sweet!!
Title: Re: Shutdown script - provided here ...
Post by: luckyboy on October 05, 2009, 11:35:35 AM
Fantastic! That's exactly what I'm looking for...
Thank you for this AndyB!
Title: Re: Shutdown script - provided here ...
Post by: Giammi_1963 on December 06, 2009, 02:53:56 PM
Hi,
thank a lot for your suggestion; I'm in a different situation, I have only one DNS-323 and not plugged on the UPS. I tried this script but it doesn't works, even if I put off the line from ") else (" and I changed the name of the NAS (rigth name is NASCasa).
Any suggestions ?
Thanks a lot in advance
Gianni
Title: Re: Shutdown script - provided here ...
Post by: Giammi_1963 on December 10, 2009, 02:01:26 AM
Hi,
thank a lot for your suggestion; I'm in a different situation, I have only one DNS-323 and not plugged on the UPS. I tried this script but it doesn't works, even if I put off the line from ") else (" and I changed the name of the NAS (rigth name is NASCasa).
Any suggestions ?
Thanks a lot in advance
Gianni

...any comment ?
Title: Re: Shutdown script - provided here ...
Post by: AndyB on December 10, 2009, 03:41:02 AM
Hi Gianni,
I sent you an email offline on monday - no reply so far from you ...

Just to be very clear - the script will work with DNS-323 with our without UPS connection. I created the script out of this usecase ...

Requirements:
you need wget downloaded and working (in same directory as the script or in the path).
the name of the nas is irrelevant. you only need to alter 2 lines in the script:

set PASSWD=yourpassword    <--- put your password here (attention to spaces)
set IP=172.17.0.6                 <--- put the IP of the NAS you want to shutdown here

Some additional questions:
DNS-323 Firmware?
What OS are you using?

Cheers,
Andi
Title: Re: Shutdown script - provided here ...
Post by: MichelR on June 21, 2010, 05:25:24 AM
Thanks for this, this is exactly what I had been looking for.

Sorry for revive a 6+ month old thread, but when I tried this it didn't work at first, and the reason was simple: I was logged in through the web interface to the DNS-323.  The output from the script did not indicate any error that I could see though  I did find it weird that there was no delay at all when it was trying to log in.

After I logged off from the web interface, the script successfully shut down the DNS-323.  Just thought this little bit of information could be useful to some people. :)
Title: Re: Shutdown script - provided here ...
Post by: infecticide on November 29, 2013, 12:35:35 PM
I tried this script but it doesn't work for me:

Firmware - 1.10
FFP_VERSION=0.7.1
FFP_ARCH=oarm

Is there a newer one out, or another way to accomplish this?
Title: Re: Shutdown script - provided here ...
Post by: hercules71035 on March 02, 2015, 02:33:49 AM
Hi there,
I'm looking for use your script on Linux machine (raspberry with raspbian), so I tried to convert your script, but I have a problem with variable ERRORLEVEL. My script is:
Code: [Select]
#/bin/bash
echo D-Link DNS-323 Shutdown Script
echo created by Andreas Baumgärtner
echo version 1.0
echo 20090930

#Info:
#don't change the uname!!
#change passwd and ip to your needs
#timeout is in seconds adjust it to your needs - for me 5 seconds where enough
#only one try otherwise the script could delay the shutdown for too long
 
echo Shutting down NAS ...
UNAME=admin
PASSWD=yourpassword
IP=172.17.0.6
wget  --tries=1 --timeout=5 "http://$IP/goform/formLogin?f_login_type=0&f_LOGIN_NAME=$UNAME&f_LOGIN_PASSWD=$PASSWD"
IF $ERRORLEVEL==0 (
wget --tries=1 --timeout=5 "http://$IP/goform/sysShutDown?shootdown"
) ELSE (
echo Unable to shutdown NAS
)

Anyone can help me on converting this script?
It works fine untile the ERRORLEVEL variable.

Thanks.
Title: Re: Shutdown script - provided here ...
Post by: Ctopia on April 26, 2015, 07:18:34 AM
Hi,

I might be able to use this with DNR 322L, but wget is not available from the link anymore.

Quote
wget not available: http://users.ugent.be/~bpuype/wget/ (http://users.ugent.be/~bpuype/wget/)
can I have a copy again, anybody?

Once I got, wget, where do I place it?
and Also where do I place the Script?

Thanks..

Hi,

I assume that I'm not the only one having this problem:

More then DNS-323 and just one UPS (with USB Signalling) so - only the NAS attached to the UPS via USB will shutdown automatically.

I created a simple shutdown script for windows.
It allows you to shutdown the NAS via wget (windows build) and 2 http calls.

Wget (all in one binary - no libraries needed)
Download for Win32: http://users.ugent.be/~bpuype/wget/ (http://users.ugent.be/~bpuype/wget/)
thanks to Bart Puype for the wget build ;-)

When the main server shuts down due to a UPS Command, the script is called by the UPS Software during shutdown.

Cheers,
AndyB

Just copy the following lines to notepad and save as nas_shutdown.bat

Code: [Select]
@echo off
rem --- D-Link DNS-323 Shutdown Script
rem --- created by Andreas Baumgärtner
rem --- version 1.0
rem --- 20090930

rem --- Info:
rem --- don't change the uname!!
rem --- change passwd and ip to your needs
rem --- timeout is in seconds adjust it to your needs - for me 5 seconds where enough
rem --- only one try otherwise the script could delay the shutdown for too long
 
echo Shutting down NAS_002 ...
set UNAME=admin
set PASSWD=yourpassword
set IP=172.17.0.6
wget  --tries=1 --timeout=5 "http://%IP%/goform/formLogin?f_login_type=0&f_LOGIN_NAME=%UNAME%&f_LOGIN_PASSWD=%PASSWD%"
IF %ERRORLEVEL%==0 (
wget --tries=1 --timeout=5 "http://%IP%/goform/sysShutDown?shootdown"
) ELSE (
echo Unable to shutdown NAS_002
)

echo Shutting down NAS_001 ...
set UNAME=admin
set PASSWD=yourpassword2
set IP=172.17.0.5
wget  --tries=1 --timeout=5 "http://%IP%/goform/formLogin?f_login_type=0&f_LOGIN_NAME=%UNAME%&f_LOGIN_PASSWD=%PASSWD%"
IF %ERRORLEVEL%==0 (
wget --tries=1 --timeout=5 "http://%IP%/goform/sysShutDown?shootdown"
) ELSE (
echo Unable to shutdown NAS_001
)

SET IP=
SET PASSWD=
SET UNAME=
Title: Re: Shutdown script - provided here ...
Post by: simgambu on January 31, 2016, 08:33:59 AM
Linux script:

Code: [Select]
#!/bin/sh
#
# --- D-Link DNS-323 Shutdown Script
# --- created by Andreas Baumgärtner
# --- version 1.0
# --- 20090930
#
# --- Info:
# --- don't change the uname!!
# --- change passwd and ip to your needs
# --- timeout is in seconds adjust it to your needs - for me 5 seconds where enough
# --- only one try otherwise the script could delay the shutdown for too long
 
echo Shutting down DS-323 ...

UNAME=admin
PASSWD=password
IP=172.10.34.223

echo "http://$IP/goform/formLogin?f_login_type=0&f_LOGIN_NAME=$UNAME&f_LOGIN_PASSWD=$PASSWD"
wget  --tries=1 --timeout=5 "http://$IP/goform/formLogin?f_login_type=0&f_LOGIN_NAME=$UNAME&f_LOGIN_PASSWD=$PASSWD"
if [ $? -eq 0 ]
 then
    echo "http://$IP/goform/sysShutDown?shutdown"
    wget --tries=1 --timeout=5 "http://$IP/goform/sysShutDown?shutdown"
 else
    echo Unable to shutdown NAS_002
 fi

IP=
PASSWD=
UNAME=
Title: Re: Shutdown script - provided here ...
Post by: la72pt on July 05, 2016, 12:04:34 PM
hi,
there are any possibility to adapt this script to dns320l?
i tried without success.
allways get error in 'wget' login.

"
Connecting to 192.168.1.99:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2016-07-05 19:58:00 ERROR 404: Not Found.

errorlevel="8"
"

thank you.