summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2009-07-07 02:28:18 (GMT)
committerJames Meyer <james.meyer@operamail.com>2009-07-07 02:28:18 (GMT)
commitb5cfd91270e2d8fe458b020d115cd6720c2aa9dd (patch)
tree2a2afe4c5edac53cc2d9b40741bb569dcba84043
parent7302f47f1619232391cbefcf92c536777d17edb4 (diff)
downloadlinhes_pkgbuild-b5cfd91270e2d8fe458b020d115cd6720c2aa9dd.zip
linhes_pkgbuild-b5cfd91270e2d8fe458b020d115cd6720c2aa9dd.tar.gz
linhes_pkgbuild-b5cfd91270e2d8fe458b020d115cd6720c2aa9dd.tar.bz2
LinHES-config: write udev rules for network interfaces based on mac address.
Only done during install.
-rwxr-xr-xabs/core-testing/LinHES-config/PKGBUILD4
-rwxr-xr-xabs/core-testing/LinHES-config/mv_install.py8
-rwxr-xr-xabs/core-testing/LinHES-config/mv_network.py44
-rwxr-xr-xabs/core-testing/LinHES-config/systemconfig.py2
4 files changed, 43 insertions, 15 deletions
diff --git a/abs/core-testing/LinHES-config/PKGBUILD b/abs/core-testing/LinHES-config/PKGBUILD
index 56cbd1a..1775cb2 100755
--- a/abs/core-testing/LinHES-config/PKGBUILD
+++ b/abs/core-testing/LinHES-config/PKGBUILD
@@ -1,9 +1,9 @@
pkgname=LinHES-config
pkgver=2.0
-pkgrel=44
+pkgrel=49
conflicts=(MythVantage-config MythVantage-config-dev LinHES-config-dev )
pkgdesc="Install and configure your system"
-depends=(bc libstatgrab mysql-python expect curl dnsutils parted sg3_utils nmbscan system-templates rsync python-parted ddcxinfo python-pexpect)
+depends=(bc libstatgrab mysql-python expect curl dnsutils parted sg3_utils nmbscan system-templates rsync python-parted ddcxinfo python-pexpect python-netifaces)
arch=('i686')
source=(mv_install.py mv_config.py mythinstall.bin myth_user_call file_time_offset.py install-ui.xml install_proxy.sh install_functions.sh systemconfig.sh install_db_chroot.sh restore_default_settings.sh xconfig.sh timezip.py soundconfig.sh LinHES-release issue MythVantage.sh create_master.sh build_diskless.sh networkconfig.sh autocard.py restore_km_db_chroot.sh README mv_advanced.py mv_common.py mv_ir.py mv_misc.py mv_network.py mv_screensaver.py mv_smolt.py mv_software.py mv_webuser.py mv_hostype.py systemconfig.py myth_user_call.py)
diff --git a/abs/core-testing/LinHES-config/mv_install.py b/abs/core-testing/LinHES-config/mv_install.py
index efee91e..ab7c644 100755
--- a/abs/core-testing/LinHES-config/mv_install.py
+++ b/abs/core-testing/LinHES-config/mv_install.py
@@ -995,7 +995,7 @@ def full_install(hostoptions):
runcmd(cmd)
logging.info("Running systemconfig in chroot")
#cmd = " chroot %s %s/bin/systemconfig.sh misc, hostype, network, advanced, user, this_is_install" %(data_config.MOUNTPOINT, MVROOT)
- cmd = "chroot %s %s/bin/systemconfig.sh all , this_is_install" %(data_config.MOUNTPOINT, MVROOT)
+ cmd = "chroot %s %s/bin/systemconfig.sh all,this_is_install" %(data_config.MOUNTPOINT, MVROOT)
rc = runcmd(cmd)[0]
if rc != 0 :
error_out("Running systemconfig")
@@ -1017,7 +1017,7 @@ def full_install(hostoptions):
logging.debug("touching /tmp/.dbsysfailed")
else:
#cmd = " chroot %s %s/bin/systemconfig.sh misc, hostype, network, advanced, user, this_is_install" %(data_config.MOUNTPOINT, MVROOT)
- cmd = "chroot %s %s/bin/systemconfig.sh all , this_is_install" %(data_config.MOUNTPOINT, MVROOT)
+ cmd = "chroot %s %s/bin/systemconfig.sh all,this_is_install" %(data_config.MOUNTPOINT, MVROOT)
rc = runcmd(cmd)[0]
if rc != 0 :
error_out("Running systemconfig")
@@ -1224,7 +1224,7 @@ def upgrade(hostoptions):
mount_bind_chroot()
logging.info("Running systemconfig in chroot")
#cmd = " chroot %s %s/bin/systemconfig.sh misc, hostype, network, advanced, user, this_is_install" %(data_config.MOUNTPOINT, MVROOT)
- cmd = "chroot %s %s/bin/systemconfig.sh all , this_is_install" %(data_config.MOUNTPOINT, MVROOT)
+ cmd = "chroot %s %s/bin/systemconfig.sh all,this_is_install" %(data_config.MOUNTPOINT, MVROOT)
rc = runcmd(cmd)[0]
if rc != 0 :
error_out("Running systemconfig")
@@ -1253,7 +1253,7 @@ def upgrade(hostoptions):
logging.info("Running systemconfig in chroot 2nd time")
#cmd = " chroot %s %s/bin/systemconfig.sh misc, hostype, network, advanced, user, this_is_install" %(data_config.MOUNTPOINT, MVROOT)
- cmd = "chroot %s %s/bin/systemconfig.sh all , this_is_install" %(data_config.MOUNTPOINT, MVROOT)
+ cmd = "chroot %s %s/bin/systemconfig.sh all,this_is_install" %(data_config.MOUNTPOINT, MVROOT)
rc = runcmd(cmd)[0]
if rc != 0 :
error_out("Running systemconfig")
diff --git a/abs/core-testing/LinHES-config/mv_network.py b/abs/core-testing/LinHES-config/mv_network.py
index ae7f861..526faae 100755
--- a/abs/core-testing/LinHES-config/mv_network.py
+++ b/abs/core-testing/LinHES-config/mv_network.py
@@ -1,8 +1,9 @@
-# -*- coding: utf-8 -*-
+ # -*- coding: utf-8 -*-
import sys , os, commands , glob, time, re
import logging
import mv_common
import socket, fcntl, struct, array
+import netifaces
global etcnetdir
etcnetdir = "/etc/net/ifaces"
@@ -291,22 +292,49 @@ def devcheck(netdev):
else:
return False
-def find_active(systemconfig):
+def udev_rules(netdev):
+ filename = "/etc/udev/rules.d/net.rules"
+ if devcheck(netdev):
+ logging.info(" Finding macaddress for %s",netdev)
+ try:
+ macaddress = netifaces.ifaddresses(netdev)[netifaces.AF_LINK][0]['addr']
+ logging.debug(" Macaddress: %s",macaddress)
+ except:
+ logging.debug(" Couldn't find mac address for %s",netdev)
+ return
+ try:
+ f = open(filename,'a')
+ except:
+ logging.debug(" Couldn't open %s for writing", filename)
+ return
+ if netdev.startswith('eth'):
+ line = '''KERNEL=="eth*", SYSFS{address}=="%s", NAME="%s"''' % ( macaddress , netdev)
+ elif netdev.startswith('wlan'):
+ line = '''KERNEL=="wlan*", SYSFS{address}=="%s", NAME="%s"'''% ( macaddress , netdev)
+ elif netdev.startswith('ath'):
+ line = '''KERNEL=="ath*", SYSFS{address}=="%s", NAME="%s"''' % ( macaddress , netdev)
+ logging.debug(" adding to net.rules ")
+ logging.debug(" %s",line)
+ f.write(line)
+ f.write("\n")
+ f.close()
+
+
+
+def find_active(systemconfig,this_is_install):
interfacelist=('eth0', 'eth1', 'wlan0', 'wlan1', 'ath0')
logging.debug(" _Start of find_active")
if systemconfig["mythdhcp"] == "1":
mv_common.remove_file("/etc/resolv.conf")
- #try:
- #os.remove("/etc/resolv.conf")
- #except:
- #logging.debug(" couldn't remove /etc/resolv.conf")
cmd = ''' echo search lan > /etc/resolv.conf '''
mv_common.runcmd(cmd)
cmd = ''' echo nameserver 127.0.0.1 >> /etc/resolv.conf '''
mv_common.runcmd(cmd)
for netdev in interfacelist:
+ if this_is_install:
+ udev_rules(netdev)
currentnet = "HostActive" + netdev
try:
systemconfig[currentnet]
@@ -398,12 +426,12 @@ def hostname_change_check(systemconfig):
-def setup_network (systemconfig):
+def setup_network (systemconfig,this_is_install):
logging.info("____Start of network____")
logging.info(" Setting up the network")
restartfe = hostname_change_check(systemconfig)
setup_hostname(systemconfig)
- find_active(systemconfig)
+ find_active(systemconfig,this_is_install)
start_network()
logging.info("__End of network\n")
return restartfe
diff --git a/abs/core-testing/LinHES-config/systemconfig.py b/abs/core-testing/LinHES-config/systemconfig.py
index 4d69a1f..4418003 100755
--- a/abs/core-testing/LinHES-config/systemconfig.py
+++ b/abs/core-testing/LinHES-config/systemconfig.py
@@ -100,7 +100,7 @@ def main(argv):
cmdmodule["smolt"] = True
if cmdmodule["network"]:
- restartfe = mv_network.setup_network(systemconfig)
+ restartfe = mv_network.setup_network(systemconfig, cmdmodule["this_is_install"])
if restartfe == True :
logging.debug(" Setting the frontend to restart due to network change")
cmdmodule["restartfe"] = True