March 12, 201016 yr Hi there. The past week I've been toying with creating a startup and a shutdown script for my unRAID server. The holy grail to switch both on and off my server via two scripts was what I wanted. This makes like easy for those who need to use your unRAID server, to be able to power it on and off without any intervention, or getting an inexperienced person to log on unRAID web gui, shutting down, etc... The 'startup' script works assuming WOL works fine for your server. Below is the 'startup' script, which you simply copy the text, paste into a blank Notepad session, edit according to your setup and save as a 'start_unraid.bat'. For WOL, I use "mc-wol.exe", which is a free download and can easily be Googled, but feel free to use any DOS-based WOL utility if you like. @echo off echo . echo =========================================== echo = Now Powering on the "YOUR_SERVER_NAME" Server. = echo =========================================== echo = To cancel, TERMINATE THIS SCRIPT NOW! = echo =========================================== ping -n 5 localhost >nul C:\path\to\the\wolfile\mc-wol.exe aa:bb:cc:dd:ee:ff echo . echo ============================= echo = The server will be ready in 2 mins. = echo ============================= ping -n 5 localhost >nul Below is a VB Script, with all thanks and credits going to "StevenD" and "barrettj" for creating, amending and assisting me with it. Simply copy the text, paste into a blank Notepad session, edit according to your setup and save as a 'stutdown_unraid.vbs': ServerName = "YOUR_SERVER_NAME" UserName = "root" 'Admin name' Passwd = "YOUR_PASSWORD" 'Password' Power = "powerdown" 'call powerdown script' ExitCommand = "exit" 'exit command' 'SyncCommand = "sync" 'sync command' DELAY = 500 ' Minimum 500ms recommended; 1000 works well. ' -------------------------------------------------------------------- ' SECTION B: Start a Shell ' -------------------------------------------------------------------- Set WshShell = WScript.CreateObject("WScript.Shell") ' -------------------------------------------------------------------- ' SECTION C: Start the TELNET ' -------------------------------------------------------------------- WshShell.Run "cmd.exe /c telnet.exe " + ServerName ' -------------------------------------------------------------------- ' SECTION D: Login. ("Sleep" pauses are needed delays.) ' -------------------------------------------------------------------- WScript.Sleep DELAY WshShell.SendKeys Username + vbLf WScript.Sleep DELAY WshShell.SendKeys Passwd + vbLf ' Send sync command 'WScript.Sleep DELAY 'WshShell.SendKeys SyncCommand + vbLf ' send power down command WScript.Sleep DELAY WshShell.SendKeys Power + vbLf ' Wait for the previous command to be sent then exit the telnet session, then exit the command prompt WScript.Sleep DELAY WScript.Sleep DELAY WshShell.SendKeys ExitCommand + vbLf WScript.Sleep DELAY WshShell.SendKeys ExitCommand + vbLf Just copy the startup and shutdown scripts to your PC, create shortcuts to them to your desktop and change the icon to something distinguishable, if you like. You could even set these as part of your startup/shutdown scripts to be excuted when your media PC Starts up/Shutdown, so no intervention what so ever is required, and your Media PC and server will be up and running by only turning on just the media PC.
March 14, 201016 yr Hi, what does the ping -n 5 localhost >nul command do? Thanks Easy... it delays 5 seconds. ( we really don't care about the command other than it will issue 5 pings, separated by a second each) windows has no easier way to sleep for 5 seconds.
March 14, 201016 yr Author Correct. I set it to 5 seconds to give the user enough time to view the message. Anything with the 'echo' command can be left out, it isn't really required obviously.
Archived
This topic is now archived and is closed to further replies.