![]() # print "wait DELAY_TIME seconds, then mount device." # host reached, now loop until it is mounted Print "time elapsed: %.0f seconds." % (time.time() - tstart) Print "wait while NAS is booting up%s" % ("." * k) P.communicate() # we are not interested in the actual output P = subprocess.Popen(, stdout = subprocess.PIPE, stderr=subprocess.PIPE) # we cannot ping based on mAC address here (requires additional packages, i.e. # IP's for known computers is are in /etc/hosts unless a local DNS server exists 50* DELAY_TIME (for DELAY_TIME = 5, these are 4 Minutes) # ping known computers until ping responds. Print "\nDone! The computers should be up and running in a short while." ![]() Print "\nDone! Host %s should be up and running in a short while." % arg Print "\n*** Unknown computer " + arg + "\n" Print "An error occured when building the magic packet!" Print "An error occured when building the magic packet for %s!" % arg If WakeOnLan(known_computers) = WOL_ERROR: Print "\n*** No computer given to power up\n" Soc.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST,1) Soc = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # Send packet to broadcast address using UDP port 9 Hwa = struct.pack('BBBBBB', int(add_oct,16), Further reading: Mounting a NAS drive on Raspberry Piīroadcast = ĭELAY_TIME = 5 # time to wait between ping commands when waiting for the device to power upĭef WakeOnLan(ethernet_address, port=WOL_PORT): A filename alongside the sol binary (i.e., in the same folder) and named sol.Here is a python script that demonstrates how the Wake-on-Lan (WOL) “magic packet” can be generated and sent over the network.(linux only) A filename under /etc/sleep-on-lan.json (if available on disk).(linux only) A filename under /etc/sol.json (if available on disk).The filename manually configured inside the command line with the -config parameter (if available on disk).Order of priority for configuration filenames are : ConfigurationĪn optional configuration file may be used. You can then easily send any computer running Sleep-On-LAN with an HTTP request, with CURL or anything else : curl, for example.Īll other registered custom commands (per configuration) can be triggered in the same way. (all available endpoints are displayed in the logs of the process when it starts) will output the local state of a remoter server for which IP is provided will output the local state of that server, in order to remotely knows if the server is alive or not sends a wake-on-lan magic packet on the network to the provided mac address remotely sleep this computer through this URL If this HTTP listener is activated, the Sleep-On-Lan process then exposes a few REST services, for example : // index page, just shows local IP / mac Wakeonlan 35:78:7a:87:d9:c4 192.168.255.255 // reversed mac address, will trigger the UDP listener of the sleep-on-lan process and will thus remotely sleep the computer Provided you are using a wake-on-lan script like this one : wake-on-lan python script (available as a debian package for example), you may use : wakeonlan c4:d9:87:7a:78:35 192.168.255.255 // regular mac address, will wake an asleep computer Thus, the same wake-on-lan tools may be used for both wake and sleep operations (python wake-on-lan script, OpenHab WoL plugin, Android applications, and so on). Just send a regular wake-on-lan command but with a reversed MAC address. Grab the latest windows + linux release or snapshot : Sleep through UDP Written in go, the code shoud run on linux and windows platforms. Executed commands are fully customizable. Additionnaly, it can also be triggered through a REST endpoint (with something like curl). that will listen the same Wake-On-LAN port and send the computer in sleep mode when the reversed MAC address received matches a local address. Technically, you have to run a little daemon (the sleep-on-lan program on your computeri, server, NAS. It works with the exact same magic packet than for Wake-On-LAN, the only difference is that the MAC address has to be written in reverse order. ![]() This project allows a windows or linux box to be put into sleep from any other device. ![]() At this time, there is not standard to make the opposite and send a computer in sleep mode. Wake-on-LAN is a standard low-level protocol implemented in various hardware. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |