NASLite Network Attached Storage

www.serverelements.com
Task-specific simplicity with low hardware requirements.
It is currently Thu Mar 28, 2024 8:46 am

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 31 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: Sat Mar 18, 2006 12:51 pm 
Offline

Joined: Sat Nov 19, 2005 6:39 pm
Posts: 633
Location: California
Hello fellow forum members:

To Tony: I realize that asking for a feature in the next version of NASLite+ which allows automated and unattended shutdown from commercially available UPS systems ( I use APCC's with USB interface ) is probably unrealistic as it takes to much code. My second preference would be that NASLite+ is APCI2.0 compatible, so that if I push the power-button on the PC it does a graceful shutdown (just like Windows, if properly chosen in BIOS).

To Moderators: Consider making this a STICKY for NASLite+, NASLITE+ USB, may be even NASLite ( I have NOT tested with the FREE version ).

To all: I have a setup where a Windows PC and the NASLite server hang off the same APCC UPS. Trouble is, although the PC can, NASLite can't shutdown automatically. This means after some time unattended in a power-outage the NASLite server will eventually crash.

Here's my solution. Feel free to use and modify for your needs. I offer no warranties ... it is use AS-IS. And be aware of some limitations. If you are running Microsoft Anti-Spyware (or others') user-intervention may be required to allow the script to run. I have only tested on Windows XP/SP2. You can run this script manually, or incorporate it into your Windows PC shutdown procedure ... on a regular basis using Task Scheduler or in an emergency triggered by your UPS. I have not yet tested the later part, but I believe I can have the APCC UPS execute a script during shutdown. I'll have some time to test that part next week.

Paste the script below into a text file, change name to "nas_shut.vbs", and try it. For safety it performs an "EXIT" as shown ... test it until it works for you then substitute "SHUT" for "XIT" in SECTION E. Also DELAY is set pretty high so you can see the action as it happens; 1000 works fine.

When pre-viewing the below I noticed it does not format as well as in my text editor. When you copy/paste you can clean it up ... but make sure you leave the single and double quote-marks as-is, especially in SECTION A.


' --------------------------------------------------------------------
'
' NAS_SHUT.VBS
'
' A script for Windows PC to remotely shutdown NASLite+ via the
' telnet login. Works with NASLite+ USB v1.5 under Windows XP/SP2
' both HomeEdition and Pro. Should work with other versions, even
' NASLite Free.
'
' Make sure to substitute the proper responses in Section A and
' the correct sequence in Section E and F.
'
' Originally 17March2006 by georg for the ServerElements Forum users.
'
' --------------------------------------------------------------------

' --------------------------------------------------------------------
' SECTION A: Some parameters ... for login and the NASLite+ Menu.
' --------------------------------------------------------------------

ServerName = "192.168.1.24" ' Use IP or name here (in quotes).

Username = "admin" ' Current Username
Passwd = "nas" ' Current Password

XIT = "E" ' Used to "EXIT" from NAS. (upper-case E)
YES = "y" ' Used to confirm an option. (lower-case Y)
SHUT = "8" ' Used to SHUTDOWN NAS. (number eight)

DELAY = 2000 ' Minimum 500ms recommended; 1000 works well.


' --------------------------------------------------------------------
' SECTION B: Start a Shell
' --------------------------------------------------------------------
Set WshShell = WScript.CreateObject("WScript.Shell")


' --------------------------------------------------------------------
' SECTION C: Start the TELNET
' --------------------------------------------------------------------
WshShell.Run "telnet " + ServerName

' --------------------------------------------------------------------
' SECTION D: Login. ("Sleep" pauses are needed delays.)
' --------------------------------------------------------------------
WScript.Sleep DELAY
WshShell.SendKeys Username + vbLf
WScript.Sleep DELAY
WshShell.SendKeys Passwd + vbLf


' --------------------------------------------------------------------
' SECTION E: NASLite+ Menu do a SHUTDOWN (or an XIT during testing)
' --------------------------------------------------------------------
WScript.Sleep DELAY
WshShell.SendKeys XIT + vbLf ' Change XIT to desired option.

' --------------------------------------------------------------------
' SECTION F: Confirm the selection.
' --------------------------------------------------------------------
WScript.Sleep DELAY
WshShell.SendKeys YES + vbLf


' OPTIONAL: (remove the comment tick mark to activate)
' MsgBox "NASLite+ Shutdown Started"

WScript.Quit



Hope this helps someone ...


:) Georg


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 19, 2006 10:05 am 
Offline

Joined: Wed Oct 26, 2005 8:42 am
Posts: 135
Location: Arkansas, USA
Georg: quick feedback ... the script works just fine on my servers ... thank you for taking the time to share your work.


Top
 Profile  
 
 Post subject: Thanks Georg
PostPosted: Mon Mar 20, 2006 2:13 am 
Offline

Joined: Sat Dec 17, 2005 9:16 pm
Posts: 16
Thanks for sharing your script Georg!

It works for me too. My UPS software allows for alert program execution.

Thanks again!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 20, 2006 11:06 pm 
Offline

Joined: Sun Mar 05, 2006 10:15 am
Posts: 52
Thanks for this, it works brilliantly.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 27, 2006 11:48 pm 
Offline

Joined: Fri Mar 17, 2006 12:37 am
Posts: 31
Georg, this was just the trick I needed for my UPS script. Thanks a million - it works wonderfully.


Top
 Profile  
 
 Post subject: HELP...not a programer
PostPosted: Wed Apr 05, 2006 9:42 pm 
Offline

Joined: Sun Nov 06, 2005 4:03 pm
Posts: 37
can some one in easy terms explain what and how to do this script.

where to put it and how to get it to work...

i have 2 battery backups
1 is connected to my main pc
and the other to my naslite
this way i can run the program that came with it to shut it down but i want to tell my naslite through telnet to shut down to
im the stupid one.....lol


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 06, 2006 6:43 pm 
Offline

Joined: Sat Nov 19, 2005 6:39 pm
Posts: 633
Location: California
Hello wpappas:

After writing the script above I found out my USB-connected UPS from APCC with "PowerChute Personal Edition" software does not support execution of additional programs during shutdown. An old APCC UPS I had some years ago did ... it was using Serial Port connection and the old APCC software that allowed it. Contacting APCC via online support suggested my upgrading to a new (expensive) UPS. I am not prepared to do that right now. I am thinking of acquiring on Ebay an old cheap (even with dead battery) APCC serial-port UPS, which (without even powering my Windows PC) will trigger a shut-down alarm. So much for my tribulations ...

But to help you ... it depends on what your UPS is capable of. What manufacturer and model do you have ? And the software that comes with it will determine whether you can end up doing what you want.

Also you could try this alternative: on your Windows PC under "Start\ControlPanel\PowerOptions" there should be a "UPS" tab. Under "Details" click "Select" and choose your manufacturer. Unfortunately, again, Windows only seems to support serial port (COMx). But if that is what you have, the next step is simple. After you click "Finish" you can use "Configure" and "When the alarm occurs, run this program:". The path and name of the program should point to my VBS script I have supplied in this discussion thread. Finally click "OK" and (in the UPS tab window) "Apply".

Now when the power goes out and an alarm is triggered on your Windows PC, the "NAS_SHUT.VBS" script executes and this results in the NASLite box going through its shutdown routine. The second UPS you have connected to NASLite will still protect the NASLite box, but (during a long power outage) it will eventually crash ... but since your NASLite box has been shut down (although the power button was never used to turn it off) your data on the disks is safe.

Hope this helps ... post back if you have more questions.

:) Georg


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 07, 2006 5:33 am 
Offline

Joined: Sun Nov 06, 2005 4:03 pm
Posts: 37
ok that part i understand
now on the script after i cut and paste where do i apply it
this is where im having problems
your right though the other battery backup is just to hold power long enough to shut down from my main comp( that was the plan)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 07, 2006 12:03 pm 
Offline

Joined: Sat Nov 19, 2005 6:39 pm
Posts: 633
Location: California
Hello wpappas:

As it states in the original post: "Paste the script below into a text file, change name to "nas_shut.vbs", and try it.".

Basically create a new TXT file -- by, for example, on the desktop, do a right-click, choose "New", then choose "New Text Document". Accept the default name ("New Text Document.txt"). Open this TXT file by double-clicking, then paste the script into it. Save and exit from the file. Rename the file to (for example) "NAS_SHUT.vbs" via a right-click & "rename". You can shoose any filename you want, just make sure to place a ".vbs" extension on it. You can move this new VBS file to any folder you like later.

Also, re-read all instructions in the original post (about "XIT" and DELAY" for example).

Hope this gets you where you want to be. Glad to help.

:) Georg


Top
 Profile  
 
 Post subject: almost there
PostPosted: Fri Apr 07, 2006 3:57 pm 
Offline

Joined: Sun Nov 06, 2005 4:03 pm
Posts: 37
ok the script i got, now what actually causes the script to run


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 08, 2006 12:42 am 
Offline

Joined: Sat Nov 19, 2005 6:39 pm
Posts: 633
Location: California
Hello wpappas:

Sorry ... not sure if I misunderstood ... please refer to the posting above from "Thu Apr 06, 2006 2:43 pm". One of two possibilities:

1] Since I don't know what UPS and related software you have, I can't help until I know more (see 2nd paragraph of the April 6 post);

**OR**

2] In Windows XP. Follow instructions in 3rd paragraph ("Control Panel/...") of above April 6 post. I have tried to attach a screen-shot at bottom. When you use "Configure" in the "UPS Configuration" window, it leads you through what looks like a Task-Scheduler sequence. Just go thru the steps it leads you to, and except for a potential user-name/password and providing the path to the VBS script, it should not require much else.

Post back if still having trouble. In a few days I hope to find time to attach an old APCC UPS with Serial Port to test it myelf. I can post more info then.

:) Georg

Image


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 09, 2006 10:19 pm 
Offline

Joined: Sat Nov 19, 2005 6:39 pm
Posts: 633
Location: California
Ok ... results are in.

I grabbed an old UPS from APCC (Model BACK UPS 500) which uses only Serial (RS-232) communications and connected it to the Windows PC COM1 serial port. The NASLite+ box was connected to a second independent UPS.

I did NOT install any APCC software, instead using purely what Windows XP provides in Start/ ControlPanel/ PowerOptions/ UPS(tab). Under the "Details" section I clicked "Select" and picked "American Power Conversion" as the manufacturer and "Back-UPS" as the model, and COM1 as the port (your port may be different due to modems, etc installed). Under "Configure" I specified 2 minutes and under "When alarm occurs ..." after clicking "Configure" I gave it the full path-name to the "nas_shut.vbs" script in the "Run" box. A password was needed in the "Run As"/"Set password".

And ... IT WORKED just fine. I unplugged the UPS and after two minutes the command window showing the VBS script execution started up ... after the shutdown confirmation ("y") the NASLite+ box beeped and shutdown, and it took a while ("connection lost" plus maybe 30 seconds) for the Windows PC to start its own shutdown, but that's probably because of a time-out from the command window.

Again ... so far the limitation seems to be that Windows handles only Serial Port connected UPS.

If your UPS comes with software, it may have the ability of executing a program (like the Windows PowerOptions UPS feature) before final shutdown. In that case it depends on the software and its features whether it supports only serial or also USB connected UPS systems.

:) Georg


Top
 Profile  
 
 Post subject: got it to work
PostPosted: Mon Apr 10, 2006 9:00 pm 
Offline

Joined: Sun Nov 06, 2005 4:03 pm
Posts: 37
the script works good
nice job to the author.......

and i got it to work with my ups

thanks again


Top
 Profile  
 
 Post subject: Shutdown Question
PostPosted: Sat Apr 22, 2006 9:29 pm 
Offline

Joined: Sat Apr 22, 2006 9:21 pm
Posts: 1
Ok I get how to shutdown and how the telnet and I have yet to try this script but seem easy enuf to use ....

Mu question is -

NASLite-PLUS-Manual.pdf cut out

Quote:
SHUTDOWN - Power may be shut down manually in 5 seconds.



OK - what I want to know is do you have to go to the box and push the off button to shhut down the box - or is my box diffrent

I thought shutdown would powerdown the whole box

EG: not to have to push the button ???

Thanks

Opie


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 22, 2006 11:17 pm 
Offline

Joined: Sat Nov 19, 2005 6:39 pm
Posts: 633
Location: California
Hello Opie:

No, unfortunately NASLite up to current version 1.5 does NOT perform an actual Power-OFF. I am hoping that version 2 will have it, but there's no indication so far that it will.

I wrote the script for a] convenience (manual shutdown -- I still walk over to the box to push the button), and, b] data safety in the case of line-power-outage (unattended automated shutdown -- the UPS supplies power from batteries much longer than needed -- but if I am not around to manually shutdown and then push the power-button, at least the disks are safe).

So ... you still have to push the power-button to turn the box off. But at least NASLite is shut-down (filesystems unmounted) after the script completes ( + 5 seconds per the manual ).

:) Georg


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 31 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group