diff --git a/macos/Makefile b/macos/Makefile index 526d710..3ef254d 100644 --- a/macos/Makefile +++ b/macos/Makefile @@ -9,7 +9,7 @@ BINDIR := $(DESTDIR)/bin SBINDIR = $(DESTDIR)/sbin #APPSDIR := $(DESTDIR)/usr/share/applications CFGDIR := $(DESTDIR)/etc/ogagent -#INITDIR := $(DESTDIR)/etc/init.d +INITDIR := /Library/LaunchDaemons #XDGAUTOSTARTDIR := $(DESTDIR)/etc/xdg/autostart #KDEAUTOSTARTDIR := $(DESTDIR)/usr/share/autostart @@ -56,6 +56,7 @@ install-ogagent: cp scripts/ogagent $(BINDIR) cp scripts/OGAgentTool-startup $(BINDIR) cp scripts/OGAgentTool $(BINDIR) + cp scripts/es.opengnsys.ogagent.plist $(INITDIR) # Fix permissions chmod 755 $(BINDIR)/ogagent diff --git a/macos/scripts/es.opengnsys.ogagent.plist b/macos/scripts/es.opengnsys.ogagent.plist new file mode 100644 index 0000000..1ea8dd0 --- /dev/null +++ b/macos/scripts/es.opengnsys.ogagent.plist @@ -0,0 +1,19 @@ + + + + Label + es.opengnsys.ogagent + ProgramArguments + + /usr/local/bin/ogagent + start + + RunAtLoad + + StandardOutPath + /var/log/ogagent.log + StandardErrorPath + /var/log/ogagent.err + + + diff --git a/src/opengnsys/macos/operations.py b/src/opengnsys/macos/operations.py index 12e2231..bb1ccaf 100644 --- a/src/opengnsys/macos/operations.py +++ b/src/opengnsys/macos/operations.py @@ -55,9 +55,7 @@ def _getMacAddr(ifname): if isinstance(ifname, six.text_type): ifname = ifname.encode('utf-8') # If unicode, convert to bytes (or str in python 2.7) try: - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - info = bytearray(fcntl.ioctl(s.fileno(), 0x8927, struct.pack(str('256s'), ifname[:15]))) - return six.text_type(''.join(['%02x:' % char for char in info[18:24]])[:-1]) + return netifaces.ifaddress(ifname)[18][0]['addr'] except Exception: return None @@ -106,7 +104,7 @@ def getNetworkInfo(): ''' for ifname in _getInterfaces(): ip, mac = _getIpAndMac(ifname) - if mac != '00:00:00:00:00:00': # Skips local interfaces + if mac != None: # Skips local interfaces yield utils.Bunch(name=ifname, mac=mac, ip=ip)