Req Libreelec Synology Wake on Lan
#1
Hello,
I´m using libreelec 8.0.2 on a NUC and a Synology DS916+ with MySQL. Everything is working, if I start first the NAS and later the NUC. I´m looking for a solution for a WakeOnLan for the DS916+, if I start the NUC.
I´ve found some solutions, but they are 5 years old and not working for me. In Kodi 17.3 you can enable WakeonLan in the Energy-Settings and it exists an WAKe-on-Lan Addon, but the problem is, if Kodi is already started, before the NAS and MYSQL is waked up, the library is empty.
So I want to make WOL with a script in autostart.sh.
I´ve treid these two Versions:

Code:
exec /usr/bin/python -x "$0" "$@"

# Wake-On-LAN
#
# Copyright (C) 2002 by Micro Systems Marc Balmer
# Written by Marc Balmer, [email protected], http://www.msys.ch/
# This code is free software under the GPL

import struct, socket

def WakeOnLan(ethernet_address):

  # Construct a six-byte hardware address

  addr_byte = ethernet_address.split(':')
  hw_addr = struct.pack('BBBBBB', int(addr_byte[0], 16),
    int(addr_byte[1], 16),
    int(addr_byte[2], 16),
    int(addr_byte[3], 16),
    int(addr_byte[4], 16),
    int(addr_byte[5], 16))

  # Build the Wake-On-LAN "Magic Packet"...

  msg = '\xff' * 6 + hw_addr * 16

  # ...and send it to the broadcast address using UDP

  s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
  s.sendto(msg, ('<broadcast>', 9))
  s.close()

WakeOnLan('00:11:32:6D:10:3C)

and

Code:
1. Created autostart.sh with this content

#!/bin/sh

# Wake-On-LAN
#
# Copyright (C) 2002 by Micro Systems Marc Balmer
# Written by Marc Balmer, [email protected], www.msys.ch/
# This code is free software under the GPL

python ~/bin/WakeOnLan.py 'xx:xx:xx:xx:xx:xx'

Change 'xx:xx:xx:xx:xx:xx' to the MAC address of your NAS


2. Created WakeOnLan.py with this content

#!/usr/bin/env python

# Wake-On-LAN
#
# Copyright (C) 2002 by Micro Systems Marc Balmer
# Written by Marc Balmer, [email protected], www.msys.ch/
# This code is free software under the GPL

import struct, socket, time, sys

ethernet_address=sys.argv[1]

# Construct a six-byte hardware address

addr_byte = ethernet_address.split(':')
hw_addr = struct.pack('BBBBBB', int(addr_byte[0], 16),
int(addr_byte[1], 16),
int(addr_byte[2], 16),
int(addr_byte[3], 16),
int(addr_byte[4], 16),
int(addr_byte[5], 16))

# Build the Wake-On-LAN "Magic Packet"...

msg = '\xff' * 6 + hw_addr * 16

# ...and send it to the broadcast address using UDP

time.sleep(2)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
s.sendto(msg, ('<broadcast>', 9))
s.close()
Does anybody know, what´s wrong with this script or can help?

Thank you

'
Reply

Logout Mark Read Team Forum Stats Members Help
Libreelec Synology Wake on Lan0