Greg, very much appreciated you taking the time to post the walk through for installing your script!
However.com, All bonjour advertised services from my unRAID box are dying 30-40 seconds after the box has gone to sleep .
Its been a very quick trial as I only have an hour before starting work, however this is where I'm at so far...
Copied the required packaged both PythonDNS and Python to /boot/extras and installed without reboot.
Installed your script to /boot/scripts/.
Installed your modified WebGUI and S3Sleep addon.
Added the script call line to the Sleep Settings with eth0 <myip> and <my-unRAID-HW-ADD>.
Rebooted.
Selected Sleep Now from the WebGUI, sever went to sleep after 5-8 seconds.
Tried connecting from my Mac... No connection.
Checked Bonjour Browser... Saw services advertised for 30 seconds, then the disappeared.
Woke my Server and ran the script from console to see any errors... Saw none.
Restarted my Airport Express ( for info the APEx is showing the sleep proxy service on BonjourBrowser)
Tried Sleep again, same issues...
Wrote this and now heading to work! haha
Any ideas?
UPDATE:
Well, I've never looked at a python script in my life never mind debugged one, but i ran :
python -m trace --trace /boot/scripts/sleepproxyclient.py eth0 192.168.1.67 00:25:90:38:2d:a4 | grep sleepproxyclient.py > debug.txt
I hoped to get an output of where the script is failing, as it brings up no error message or issue when I run it. It seems to end on the "No sleep proxy" arguement, although I can defo confirm there is one showing on the network on my BonjourBrowser.
Hope this helps cause I'm way out of my depth! haha
sleepproxyclient.py(22): import dns.update
sleepproxyclient.py(23): import dns.query
sleepproxyclient.py(24): import dns.rdtypes
sleepproxyclient.py(25): import dns.rdata
sleepproxyclient.py(26): import dns.edns
sleepproxyclient.py(27): import dns.rrset
sleepproxyclient.py(28): from dns.exception import DNSException
sleepproxyclient.py(30): import struct
sleepproxyclient.py(31): import sys
sleepproxyclient.py(32): import subprocess
sleepproxyclient.py(33): import socket
sleepproxyclient.py(42): DEVICE_MODEL = "unRAID"
sleepproxyclient.py(47): TTL_long = 7200 # 2 h
sleepproxyclient.py(51): TTL_short = 120
sleepproxyclient.py(54): def main() :
sleepproxyclient.py(63): def sendUpdateForInterface(interface) :
sleepproxyclient.py(145): def discoverServices(ip):
sleepproxyclient.py(172): def discoverSleepProxies(interface):
sleepproxyclient.py(194): main()
sleepproxyclient.py(56): iface = sys.argv[1]
sleepproxyclient.py(57): try:
sleepproxyclient.py(58): sendUpdateForInterface(iface)
sleepproxyclient.py(66): proxies = discoverSleepProxies(interface)
sleepproxyclient.py(175): proxies = []
sleepproxyclient.py(176): cmd = "avahi-browse --resolve --parsable --no-db-lookup --terminate _sleep-proxy._udp 2>/dev/null | grep '=;.*;IPv4;'"
sleepproxyclient.py(178): p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
sleepproxyclient.py(179): for line in p.stdout.readlines():
sleepproxyclient.py(180): lineArr = line.rsplit(";")
sleepproxyclient.py(183): if (len(lineArr) < 10) :
sleepproxyclient.py(187): ip = lineArr[7]
sleepproxyclient.py(188): port = lineArr[8]
sleepproxyclient.py(189): proxies.append({ "ip" : ip, "port" : port})
sleepproxyclient.py(179): for line in p.stdout.readlines():
sleepproxyclient.py(191): retval = p.wait()
sleepproxyclient.py(192): return proxies
sleepproxyclient.py(67): if (len(proxies) == 0) :
sleepproxyclient.py(71): ip4Addr = sys.argv[2]
sleepproxyclient.py(72): hwAddr = sys.argv[3]
sleepproxyclient.py(75): ip4Arr = ip4Addr.rsplit(".")
sleepproxyclient.py(76): ip4ArrInv = ip4Arr[:]
sleepproxyclient.py(77): ip4ArrInv.reverse()
sleepproxyclient.py(78): ip4Inv = ".".join(ip4ArrInv)
sleepproxyclient.py(80): host = socket.gethostname()
sleepproxyclient.py(81): host_local = host + ".local"
sleepproxyclient.py(84): update = dns.update.Update("")
sleepproxyclient.py(87): update.add(ip4Inv + '.in-addr.arpa', TTL_short, dns.rdatatype.PTR, host_local)
sleepproxyclient.py(88): update.add(host_local, TTL_short, dns.rdatatype.A, ip4Addr)
sleepproxyclient.py(91): for service in discoverServices(ip4Addr) :
sleepproxyclient.py(148): services = []
sleepproxyclient.py(149): cmd = "avahi-browse --all --resolve --parsable --no-db-lookup --terminate 2>/dev/null | grep '=;.*;IPv4;' | grep ';" + ip + ";'"
sleepproxyclient.py(151): p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
sleepproxyclient.py(91): for service in discoverServices(ip4Addr) :
sleepproxyclient.py(148): services = []
sleepproxyclient.py(149): cmd = "avahi-browse --all --resolve --parsable --no-db-lookup --terminate 2>/dev/null | grep '=;.*;IPv4;' | grep ';" + ip + ";'"
sleepproxyclient.py(151): p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
sleepproxyclient.py(152): for line in p.stdout.readlines():
sleepproxyclient.py(153): lineArr = line.rsplit(";")
sleepproxyclient.py(156): if (len(lineArr) < 10) :
sleepproxyclient.py(161): if (lineArr[7] == ip) :
sleepproxyclient.py(162): service = lineArr[4]
sleepproxyclient.py(163): port = lineArr[8]
sleepproxyclient.py(164): txtRecords = lineArr[9].replace('" "', ';').replace('\n', '').replace('"', '').rsplit(';')
sleepproxyclient.py(165): services.append([service, port] + txtRecords)
sleepproxyclient.py(152): for line in p.stdout.readlines():
sleepproxyclient.py(153): lineArr = line.rsplit(";")
sleepproxyclient.py(156): if (len(lineArr) < 10) :
sleepproxyclient.py(161): if (lineArr[7] == ip) :
sleepproxyclient.py(162): service = lineArr[4]
sleepproxyclient.py(163): port = lineArr[8]
sleepproxyclient.py(164): txtRecords = lineArr[9].replace('" "', ';').replace('\n', '').replace('"', '').rsplit(';')
sleepproxyclient.py(165): services.append([service, port] + txtRecords)
sleepproxyclient.py(152): for line in p.stdout.readlines():
sleepproxyclient.py(153): lineArr = line.rsplit(";")
sleepproxyclient.py(156): if (len(lineArr) < 10) :
sleepproxyclient.py(161): if (lineArr[7] == ip) :
sleepproxyclient.py(162): service = lineArr[4]
sleepproxyclient.py(163): port = lineArr[8]
sleepproxyclient.py(164): txtRecords = lineArr[9].replace('" "', ';').replace('\n', '').replace('"', '').rsplit(';')
sleepproxyclient.py(165): services.append([service, port] + txtRecords)
sleepproxyclient.py(152): for line in p.stdout.readlines():
sleepproxyclient.py(153): lineArr = line.rsplit(";")
sleepproxyclient.py(156): if (len(lineArr) < 10) :
sleepproxyclient.py(161): if (lineArr[7] == ip) :
sleepproxyclient.py(162): service = lineArr[4]
sleepproxyclient.py(163): port = lineArr[8]
sleepproxyclient.py(164): txtRecords = lineArr[9].replace('" "', ';').replace('\n', '').replace('"', '').rsplit(';')
sleepproxyclient.py(165): services.append([service, port] + txtRecords)
sleepproxyclient.py(152): for line in p.stdout.readlines():
sleepproxyclient.py(153): lineArr = line.rsplit(";")
sleepproxyclient.py(156): if (len(lineArr) < 10) :
sleepproxyclient.py(161): if (lineArr[7] == ip) :
sleepproxyclient.py(162): service = lineArr[4]
sleepproxyclient.py(163): port = lineArr[8]
sleepproxyclient.py(164): txtRecords = lineArr[9].replace('" "', ';').replace('\n', '').replace('"', '').rsplit(';')
sleepproxyclient.py(165): services.append([service, port] + txtRecords)
sleepproxyclient.py(152): for line in p.stdout.readlines():
sleepproxyclient.py(153): lineArr = line.rsplit(";")
sleepproxyclient.py(156): if (len(lineArr) < 10) :
sleepproxyclient.py(161): if (lineArr[7] == ip) :
sleepproxyclient.py(162): service = lineArr[4]
sleepproxyclient.py(163): port = lineArr[8]
sleepproxyclient.py(164): txtRecords = lineArr[9].replace('" "', ';').replace('\n', '').replace('"', '').rsplit(';')
sleepproxyclient.py(165): services.append([service, port] + txtRecords)
sleepproxyclient.py(152): for line in p.stdout.readlines():
sleepproxyclient.py(153): lineArr = line.rsplit(";")
sleepproxyclient.py(156): if (len(lineArr) < 10) :
sleepproxyclient.py(161): if (lineArr[7] == ip) :
sleepproxyclient.py(162): service = lineArr[4]
sleepproxyclient.py(163): port = lineArr[8]
sleepproxyclient.py(164): txtRecords = lineArr[9].replace('" "', ';').replace('\n', '').replace('"', '').rsplit(';')
sleepproxyclient.py(165): services.append([service, port] + txtRecords)
sleepproxyclient.py(152): for line in p.stdout.readlines():
sleepproxyclient.py(167): retval = p.wait()
sleepproxyclient.py(168): return services
sleepproxyclient.py(92): type = service[0] + ".local"
sleepproxyclient.py(93): type_host = host + "." + type
sleepproxyclient.py(94): port = service[1]
sleepproxyclient.py(97): txtrecord = ""
sleepproxyclient.py(98): if (len(service) == 2 or service[2] == "") :
sleepproxyclient.py(101): for i in range(2,len(service)) :
sleepproxyclient.py(102): txtrecord += " " + service[i]
sleepproxyclient.py(101): for i in range(2,len(service)) :
sleepproxyclient.py(102): txtrecord += " " + service[i]
sleepproxyclient.py(101): for i in range(2,len(service)) :
sleepproxyclient.py(102): txtrecord += " " + service[i]
sleepproxyclient.py(101): for i in range(2,len(service)) :
sleepproxyclient.py(104): update.add(type_host, TTL_long, dns.rdatatype.TXT, txtrecord)
sleepproxyclient.py(105): update.add('_services._dns-sd._udp.local', TTL_long, dns.rdatatype.PTR, type + ".local")
sleepproxyclient.py(106): update.add(type, TTL_long, dns.rdatatype.PTR, type_host)
sleepproxyclient.py(107): update.add(type_host, TTL_short, dns.rdatatype.SRV, "0 0 " + port + " " + host_local)
sleepproxyclient.py(91): for service in discoverServices(ip4Addr) :
sleepproxyclient.py(92): type = service[0] + ".local"
sleepproxyclient.py(93): type_host = host + "." + type
sleepproxyclient.py(94): port = service[1]
sleepproxyclient.py(97): txtrecord = ""
sleepproxyclient.py(98): if (len(service) == 2 or service[2] == "") :
sleepproxyclient.py(99): txtrecord = chr(0)
sleepproxyclient.py(104): update.add(type_host, TTL_long, dns.rdatatype.TXT, txtrecord)
sleepproxyclient.py(105): update.add('_services._dns-sd._udp.local', TTL_long, dns.rdatatype.PTR, type + ".local")
sleepproxyclient.py(106): update.add(type, TTL_long, dns.rdatatype.PTR, type_host)
sleepproxyclient.py(107): update.add(type_host, TTL_short, dns.rdatatype.SRV, "0 0 " + port + " " + host_local)
sleepproxyclient.py(91): for service in discoverServices(ip4Addr) :
sleepproxyclient.py(92): type = service[0] + ".local"
sleepproxyclient.py(93): type_host = host + "." + type
sleepproxyclient.py(94): port = service[1]
sleepproxyclient.py(97): txtrecord = ""
sleepproxyclient.py(98): if (len(service) == 2 or service[2] == "") :
sleepproxyclient.py(99): txtrecord = chr(0)
sleepproxyclient.py(104): update.add(type_host, TTL_long, dns.rdatatype.TXT, txtrecord)
sleepproxyclient.py(105): update.add('_services._dns-sd._udp.local', TTL_long, dns.rdatatype.PTR, type + ".local")
sleepproxyclient.py(106): update.add(type, TTL_long, dns.rdatatype.PTR, type_host)
sleepproxyclient.py(107): update.add(type_host, TTL_short, dns.rdatatype.SRV, "0 0 " + port + " " + host_local)
sleepproxyclient.py(91): for service in discoverServices(ip4Addr) :
sleepproxyclient.py(92): type = service[0] + ".local"
sleepproxyclient.py(93): type_host = host + "." + type
sleepproxyclient.py(94): port = service[1]
sleepproxyclient.py(97): txtrecord = ""
sleepproxyclient.py(98): if (len(service) == 2 or service[2] == "") :
sleepproxyclient.py(99): txtrecord = chr(0)
sleepproxyclient.py(104): update.add(type_host, TTL_long, dns.rdatatype.TXT, txtrecord)
sleepproxyclient.py(105): update.add('_services._dns-sd._udp.local', TTL_long, dns.rdatatype.PTR, type + ".local")
sleepproxyclient.py(106): update.add(type, TTL_long, dns.rdatatype.PTR, type_host)
sleepproxyclient.py(107): update.add(type_host, TTL_short, dns.rdatatype.SRV, "0 0 " + port + " " + host_local)
sleepproxyclient.py(91): for service in discoverServices(ip4Addr) :
sleepproxyclient.py(92): type = service[0] + ".local"
sleepproxyclient.py(93): type_host = host + "." + type
sleepproxyclient.py(94): port = service[1]
sleepproxyclient.py(97): txtrecord = ""
sleepproxyclient.py(98): if (len(service) == 2 or service[2] == "") :
sleepproxyclient.py(101): for i in range(2,len(service)) :
sleepproxyclient.py(102): txtrecord += " " + service[ i ]
sleepproxyclient.py(101): for i in range(2,len(service)) :
sleepproxyclient.py(104): update.add(type_host, TTL_long, dns.rdatatype.TXT, txtrecord)
sleepproxyclient.py(105): update.add('_services._dns-sd._udp.local', TTL_long, dns.rdatatype.PTR, type + ".local")
sleepproxyclient.py(106): update.add(type, TTL_long, dns.rdatatype.PTR, type_host)
sleepproxyclient.py(107): update.add(type_host, TTL_short, dns.rdatatype.SRV, "0 0 " + port + " " + host_local)
sleepproxyclient.py(91): for service in discoverServices(ip4Addr) :
sleepproxyclient.py(92): type = service[0] + ".local"
sleepproxyclient.py(93): type_host = host + "." + type
sleepproxyclient.py(94): port = service[1]
sleepproxyclient.py(97): txtrecord = ""
sleepproxyclient.py(98): if (len(service) == 2 or service[2] == "") :
sleepproxyclient.py(101): for i in range(2,len(service)) :
sleepproxyclient.py(102): txtrecord += " " + service[i]
sleepproxyclient.py(101): for i in range(2,len(service)) :
sleepproxyclient.py(104): update.add(type_host, TTL_long, dns.rdatatype.TXT, txtrecord)
sleepproxyclient.py(105): update.add('_services._dns-sd._udp.local', TTL_long, dns.rdatatype.PTR, type + ".local")
sleepproxyclient.py(106): update.add(type, TTL_long, dns.rdatatype.PTR, type_host)
sleepproxyclient.py(107): update.add(type_host, TTL_short, dns.rdatatype.SRV, "0 0 " + port + " " + host_local)
sleepproxyclient.py(91): for service in discoverServices(ip4Addr) :
sleepproxyclient.py(92): type = service[0] + ".local"
sleepproxyclient.py(93): type_host = host + "." + type
sleepproxyclient.py(94): port = service[1]
sleepproxyclient.py(97): txtrecord = ""
sleepproxyclient.py(98): if (len(service) == 2 or service[2] == "") :
sleepproxyclient.py(101): for i in range(2,len(service)) :
sleepproxyclient.py(102): txtrecord += " " + service[i]
sleepproxyclient.py(101): for i in range(2,len(service)) :
sleepproxyclient.py(104): update.add(type_host, TTL_long, dns.rdatatype.TXT, txtrecord)
sleepproxyclient.py(105): update.add('_services._dns-sd._udp.local', TTL_long, dns.rdatatype.PTR, type + ".local")
sleepproxyclient.py(106): update.add(type, TTL_long, dns.rdatatype.PTR, type_host)
sleepproxyclient.py(107): update.add(type_host, TTL_short, dns.rdatatype.SRV, "0 0 " + port + " " + host_local)
sleepproxyclient.py(91): for service in discoverServices(ip4Addr) :
sleepproxyclient.py(111): update.add(host + '._device-info._tcp.local.', TTL_long, dns.rdatatype.TXT, "model=" + DEVICE_MODEL + " state=sleeping")
sleepproxyclient.py(117): leaseTimeOption = dns.edns.GenericOption(2, struct.pack("!L", 7200))
sleepproxyclient.py(121): cleanMAC = hwAddr.replace(":", "")
sleepproxyclient.py(122): ownerOption = dns.edns.GenericOption(4, ("0000" + cleanMAC).decode('hex_codec'))
sleepproxyclient.py(127): update.use_edns(0, TTL_long, 1440, None, [leaseTimeOption, ownerOption])
sleepproxyclient.py(130): for proxy in proxies :
sleepproxyclient.py(131): try:
sleepproxyclient.py(132): errStr = "Unable to register with SleepProxy " + proxy['ip'] + ":" + proxy['port']
sleepproxyclient.py(134): response = dns.query.udp(update, proxy['ip'], timeout=10, port=int(proxy['port']))
sleepproxyclient.py(140): except DNSException, e:
sleepproxyclient.py(141): print e
sleepproxyclient.py(130): for proxy in proxies :