Shutdown unRAID from shortcut


Recommended Posts

To shutdown unRAID from a shortcut(without using a web browser), I used Telnet Scripting Tool.

If its not available from the above link Google it.

 

The shortcut is:

TST10.exe /r:script.txt

 

where the contents of script.txt are:

192.168.1.6 23

WAIT "login:"

SEND "root\m"

WAIT ":~#"

SEND "stop\m"

WAIT "cmdResult=ok"

SEND "poweroff\m"

WAIT "Broadcast message from root"

 

Replace 192.168.1.6 with the IP of your unRAID server.

 

I hope this is of use to someone.

Link to comment

To shutdown unRAID from a shortcut(without using a web browser), I used Telnet Scripting Tool.

If its not available from the above link Google it.

 

The shortcut is:

TST10.exe /r:script.txt

 

where the contents of script.txt are:

192.168.1.6 23

WAIT "login:"

SEND "root\m"

WAIT ":~#"

SEND "stop\m"

WAIT "cmdResult=ok"

SEND "poweroff\m"

WAIT "Broadcast message from root"

 

Replace 192.168.1.6 with the IP of your unRAID server.

 

I hope this is of use to someone.

 

Thanks so much!

Link to comment
  • 8 months later...

This thread is so old, I had forgotten about it, but perhaps this is the time to update it, merging adelias work with WeeboTech's powerdown scripts.  I have attached powerdown.zip which contains powerdown, init-powerdown, PowerdownScript.txt, and 'Power down unRAID server.lnk'.

 

My particular interest is having an 'Emergency shutdown' button, to avoid the current delays of 30 to 45 seconds after pressing the Stop button, and waiting for all drives to spin up, before I can finally press the Power down button, and run upstairs to shut down other computers.  This provides a Click and Go solution, just double-click the desktop icon or press Ctrl-Alt-Del on the server keyboard, and it will shut down by itself, with no further need for user interaction.  I live in an area of frequent thunderstorms about a third of the year.  We hear thunder in the distance so often, we tend to ignore it, until a clap overhead shakes the house, and we scurry around shutting things down and pulling plugs.

 

For more info on the powerdown scripts, see this thread:  http://lime-technology.com/forum/index.php?topic=1485.

 

Steps to install: (unRAID server name will be assumed to be tower, change as needed)

1.  Unpack powerdown.zip to a temporary folder.  (Either use a file manager that displays

    files with hidden and system attributes, or make sure that Windows is configured to

    show them.)

2.  Copy powerdown and init-powerdown to the root of the flash, \\tower\flash.

3.  Open the go file (/boot/config/go or \\tower\flash\config\go) for editing with

    WordPad, and add the line '/boot/init-powerdown'.  Note on editing 'go':  use Microsoft

    WordPad or an editor that can be configured to use Unix end-of-line's.  Do not use

    Notepad, Microsoft Word, or any editor that you can not adjust the end-of-line character.

4.  [Optional]At a console prompt, type /boot/init-powerdown, and powerdown will now be

    ready to use.  The powerdown script will automatically be available after each boot.

5.  Download TST10.zip from the Telnet Scripting Tool link in the first post, and unzip its

    contents (TST10.EXE and TST1.TXT) into your Windows folder.

6.  Copy PowerdownScript.txt to your Windows folder.  You can move PowerdownScript.txt

    and TST10.EXE to a different folder of your choice, but you will need to create your own

    shortcut.  The included shortcut (Power down unRAID server.lnk) is designed to work

    with the files copied to C:\Windows.

7.  If your unRAID server name is not tower, then edit PowerdownScript.txt (with any text

    editor, NotePad, WordPad, etc) and change the first line to be the correct server name

    or the server IP.  If needed, edit the login name, and if there is a password, see Note 2

    below.

8.  Either copy the included shortcut (Power down unRAID server.lnk) to your desktop or

    desired location, or create one.  Edit its Properties as needed, to ensure the 'Target:'

    and 'Start in:' paths are correct, and point to the location of TST10.EXE.  The 'Target:'

    box should contain something like:  C:\Windows\TST10.exe /r:PowerdownScript.txt

 

Notes:

(1) By installing the above, you will have several new ways to quickly shut down your unRAID server.  You can press the Ctrl-Alt-Del key combination on the server (monitor not required), or type powerdown at the console (if you have a monitor and keyboard attached), or double-click the desktop shortcut above.

 

(2) The Telnet script PowerdownScript.txt assumes the default setup of server name tower, no password, and login name of root.  The file can be easily edited for the correct values for server name and login name.  The password is more complicated, and since I don't have one, did not test.  I think there are 2 ways, one being to add a 'Wait "Password:"' line, followed by a 'Send "YourPassword\m"' line (replace YourPassword with your password).  If someone will try it, and confirm or correct the syntax of the Password prompt, I will update it here.  The other choice requires someone to confirm also.  The TST10 tool claims that it will allow typing in its Telnet session.  I could not test this, or its usefulness, but I think it is possible that when the password prompt appears, you can enter your password and press enter, and execution of the script will continue when it sees the following prompt, matching the next Wait command.  Please let me know, and I'll update this post and the zip attached.

 

(3) I added an echo to each of the scripts, to increase their operational visibility.  On my first trial of powerdown, absolutely nothing visible happened, no drive lights flickered, no console messages, and I therefore thought perhaps I mis-typed, so I pressed the Ctrl-Alt-Del key combination a second time, which caused multiple executions, without apparent harm THIS time.  It might be wise to add something to the start of powerdown like: (unfortunately I am only a Bash beginner)

  if exist /var/powerdown_flag exit

  echo xxx >/var/powerdown_flag

 

(4) Because I stripped the carriage returns out of both scripts and flagged them System and Hidden (which makes them executable on the unRAID server), I think that the init-powerdown script could be simplified, perhaps removing the fromdos procedure and chmod?  I would prefer WeeboTech to make whatever changes he deems appropriate, and I will update this post accordingly.

 

(5) I added a copy of the syslog to the flash in the powerdown script.  I've always thought it might be nice to have a Logs folder on the flash with the entire syslog for each session.  It would probably be even better if the name included a timestamp, and was created automatically by the system at the last possible moment.

 

Credit goes to adelias for his work here, and to WeeboTech for the powerdown scripts.

 

I know the above is too long, too technical, unclear in parts, and incomplete.  I just had to include one last link, to a recent post elsewhere discussing a new product and how to use it with SageTV.  It is very long, but I am awed by the terrific work the poster had put into it, perhaps the finest presentation-style post I have ever seen.  I would love to put this guy in charge of many companies technical writing departments.  Here it is:  http://forums.freytechnologies.com/forums/showthread.php?t=31524.

 

Link to comment

I think that the init-powerdown script could be simplified, perhaps removing the fromdos procedure and chmod?

 

I would love to, only thing is, if someone edits it ascript with a DOS based text editor and puts the CRLF back in, the script will not work.

Rene and I hard some issues with the init.mt-daapd script and found we have to do it just to be sure.

Believe me, I don't want to have the whole fromdos thing there. LOL.

 

As for logging/echoing, I'll put that in.

 

As for saving syslog. I think it's a good idea too.

 

I will post a new script sometime today.

 

Link to comment

So kind of every one to refrain from mentioning my beginner mistake, forgetting to add the attachment!  I was too tired, especially after all the revisions I had made.  Unfortunately, attachments do not seem to be working yet with the new forum site.  I'll add it when it is possible, and update it with any of WeeboTech's changes.  Thank you very much.

 

I would love to, only thing is, if someone edits it ascript with a DOS based text editor and puts the CRLF back in, the script will not work.

Rene and I hard some issues with the init.mt-daapd script and found we have to do it just to be sure.

Believe me, I don't want to have the whole fromdos thing there. LOL.

 

So true, so true, safer to leave it in.

 

I wonder, what happens if you press the actual power button on unraid though... can it be made to call a specific script (your script for that matter)? does it do anything at all?

 

Good idea, but I don't believe there is any way to hook the power button.  The next best thing is to use the Ctrl-Alt-Del key combo, which HAS been hooked, but that requires a keyboard.

 

Edit:  Attachments are working, have added my first powerdown.zip to the post above.  Will update it as needed.

 

Link to comment
  • 7 months later...

I should warn you that this is old, and I have never gotten back to it, to update it with WeeboTech's latest powerdown script.  Check here for his latest, although it has changed somewhat, and is packaged, and I'm not sure how it will work with the above.  Not sure when I'll get around to updating this...

 

It should still work as is, but without the extensive improvements he added.

Link to comment
  • 2 weeks later...

Rob, thanks for posting instructions.  I now have remote start-up and shutdown via desktop icons.  :)

 

I never managed to get the password part working with TST10, so I dropped it from the server.  In what manner has the powerdown script changed?  I am using the version whereby the go script is modified to copy across to /sbin directory at boot time.  WRT packages, does this mean that I can install it permanently and no longer need to mess around with the go script?

 

Next I want to get the power button script working since the server is headless.

 

Cheers, Matt.

Link to comment
  • 1 month later...

Does the Telnet scripting tool work with x64? I keep getting errors when trying to run it. I double click the shortcut and I get a popup explaining usage. If I press the close button, an error pops up "Abnormal termination".

 

I couldn't get the scripting tool to work, so I found a vb script and adopted it to work.

 

Link to comment
  • 6 months later...

Does the Telnet scripting tool work with x64? I keep getting errors when trying to run it. I double click the shortcut and I get a popup explaining usage. If I press the close button, an error pops up "Abnormal termination".

 

I couldn't get the scripting tool to work, so I found a vb script and adopted it to work.

 

 

I know this is an old thread, but I just wanted to say "Thank you!"  My UPS that I had on my unRAID server fried over the weekend. I have it plugged into the UPS on one of my WIndows servers.  Since I can only run the monitoring software from one server, I used your vbscript to shutdown unRAID from the Windows servers when the power level hits 50%.

Link to comment
  • 7 years later...

Pulling from the depths on this one ^^; Apologies ahead of time on the necro, but since I'm looking for updated information with only a slight tweak I didn't really see a need to make a whole new thread about it. I'm not sure how to go about this, nor how much has changed in the instructions above, and with the only relevant posts being so old I thought I had better ask first. /end necro disclaimer....

 

 

 

I would like to have a shortcut on my win10 laptop, that can send a poweroff command to my unRAID server. (A separate reboot shortcut would be nice too.)

 

Also, not sure if it's important, but for clarity of use -  I use Putty for all my SSH, mc-wol bat to start up the server, and have Bergware's Dynamix System Buttons installed already. As I don't leave her running 24/7, and regularly shutdown the server when I'm not using it, the shortcut would be really convenient for me.

 

Thanks in advance!

Link to comment

This really is old!

 

Garycase has an updated method for doing it from Windows, search for posts about shutdown from Windows, user=garycase.

 

Awesome, thank you for pointing me in the right direction as always RobJ!

 

 

Just in case anyone else ever has this question and finds their way to this post, I'll toss in the quote from bonienl that answered both garycase and my question on how to do this.

 

I ended up make a bat file in my putty directory containing this text, then just put a shortcut on my desktop  :)

plink.exe -ssh -pw passwordhere useridhere@serveriphere powerdown

 

 

 

 

 

That works fine if you execute it from the UnRAID console; but what I'm looking for is a command line you can run on a Windows box that will shutdown the UnRAID server.

Putty will accept command line parameters. I think what you want would be something along the lines of c:\pathtoputty\putty -ssh root@tower -pw password -m c:\pathto\textfilewithshutdowncommand.txt or something like that. I haven't actually tried it, so it may create a black hole and implode the universe, ymmv.

 

plink is the better option to automate remote execution of commands, it comes together with putty.

 

plink -ssh -pw <password> root@<hostaddr> powerdown

Link to comment
  • 3 weeks later...

Garycase has an updated method for doing it from Windows, search for posts about shutdown from Windows, user=garycase.

Awesome, thank you for pointing me in the right direction as always RobJ!

 

Just in case anyone else ever has this question and finds their way to this post, I'll toss in the quote from bonienl that answered both garycase and my question on how to do this.

 

I ended up make a bat file in my putty directory containing this text, then just put a shortcut on my desktop  :)

plink.exe -ssh -pw passwordhere useridhere@serveriphere powerdown

I was feeling a little lazy at the time, didn't go looking for it, glad you found it in spite of my misdirection.  ;)

 

I've added it to the FAQ:  Is there a way to create a Windows shortcut for shutting down the unRAID server?

 

Appreciate any corrections or suggestions.  I've also reworked and corrected the old Telnet page, renamed to Terminal Access, with Telnet, PuTTY, and SSH sections.  It also needs review and corrections and suggestions.

  • Upvote 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.