#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-378ad31fedc9remotes/github/oglive
parent
676447c65a
commit
c5e1aa79df
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue