diff options
author | ramon <ramongomez@us.es> | 2017-02-20 09:20:06 +0000 |
---|---|---|
committer | ramon <ramongomez@us.es> | 2017-02-20 09:20:06 +0000 |
commit | 96b942ac408f5afb4f68184dbd42c50c794006e9 (patch) | |
tree | 9a6a317d98b96109a7d086f36b3c0bb72ffea0d4 | |
parent | 744d1929e3a6c12b5cdb3bbe29741ef408054457 (diff) |
#718: OGAgent para macOS: inicio automático y detección de datos de red.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5206 a21b9725-9963-47de-94b9-378ad31fedc9
3 files changed, 23 insertions, 5 deletions
diff --git a/admin/Sources/Clients/ogagent/macos/Makefile b/admin/Sources/Clients/ogagent/macos/Makefile index 526d7108..3ef254dd 100644 --- a/admin/Sources/Clients/ogagent/macos/Makefile +++ b/admin/Sources/Clients/ogagent/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/admin/Sources/Clients/ogagent/macos/scripts/es.opengnsys.ogagent.plist b/admin/Sources/Clients/ogagent/macos/scripts/es.opengnsys.ogagent.plist new file mode 100644 index 00000000..1ea8dd07 --- /dev/null +++ b/admin/Sources/Clients/ogagent/macos/scripts/es.opengnsys.ogagent.plist @@ -0,0 +1,19 @@ +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> + <dict> + <key>Label</key> + <string>es.opengnsys.ogagent</string> + <key>ProgramArguments</key> + <array> + <string>/usr/local/bin/ogagent</string> + <string>start</string> + </array> + <key>RunAtLoad</key> + <true/> + <key>StandardOutPath</key> + <string>/var/log/ogagent.log</string> + <key>StandardErrorPath</key> + <string>/var/log/ogagent.err</string> + </dict> +</plist> + diff --git a/admin/Sources/Clients/ogagent/src/opengnsys/macos/operations.py b/admin/Sources/Clients/ogagent/src/opengnsys/macos/operations.py index 12e2231c..bb1ccaff 100644 --- a/admin/Sources/Clients/ogagent/src/opengnsys/macos/operations.py +++ b/admin/Sources/Clients/ogagent/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) |