diff options
author | David Cantrell <dcantrell@redhat.com> | 2007-05-14 19:00:04 +0000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2007-05-14 19:00:04 +0000 |
commit | b7ecd1e6f929f76db9687bec66d310b01427565b (patch) | |
tree | d765600b3024f2ba3e3d303df1904e575be56b1d /command-stubs | |
parent | 5c62514a0abdc043155bcdf9d4432262284072e8 (diff) | |
download | anaconda-b7ecd1e6f929f76db9687bec66d310b01427565b.tar.gz anaconda-b7ecd1e6f929f76db9687bec66d310b01427565b.tar.xz anaconda-b7ecd1e6f929f76db9687bec66d310b01427565b.zip |
* command-stubs/pump-stub: Removed (#239427).
* command-stubs/dhcpclient-stub: Wrote new command to provide an IPv4
and IPv6 dhcp/auto client at the command line in rescue mode (#239427).
* scripts/upd-instroot: Install dhcpclient-stub, symlink /usr/bin/pump
to /usr/bin/dhcpclient (#239427).
Diffstat (limited to 'command-stubs')
-rwxr-xr-x | command-stubs/dhcpclient-stub | 98 | ||||
-rwxr-xr-x | command-stubs/pump-stub | 36 |
2 files changed, 98 insertions, 36 deletions
diff --git a/command-stubs/dhcpclient-stub b/command-stubs/dhcpclient-stub new file mode 100755 index 000000000..ac8fbc999 --- /dev/null +++ b/command-stubs/dhcpclient-stub @@ -0,0 +1,98 @@ +#!/usr/bin/python + +import os +import sys +import getopt + +# for testing +if (os.path.exists('isys')): + sys.path.append('isys') + +sys.path.append('/usr/lib/anaconda') + +import isys +from sys import argv + +import network +from network import NetworkDevice + +def showusage(): + print "Usage: dhcpclient [-4] [-6] [-a] [-i device] [-c class]" + +def showhelp(): + showusage() + print "Options:" + print " -4 Configure IPv4 stack via DHCP" + print " -6 Configure IPv6 stack (DHCPv6 unless -a given)" + print " -a Use IPv6 auto neighbor discovery" + print " -i device Device to configure (e.g., eth0)" + print " -c class Optional DHCP class name" + print "Defaults:" + print " dhcpclient -4 -6 -a -i eth0" + +if __name__ == "__main__": + dev = NetworkDevice('eth0') + dev.set(('bootproto', 'dhcp')) + + auto = False + stacks = 0 + + help = False + unknown = False + + try: + opts, args = getopt.getopt(sys.argv[1:], '46ai:c:', + ['ipv4', 'ipv6', 'auto', 'interface', + 'class', 'help']) + except getopt.GetoptError: + help = True + + for o, a in opts: + if o in ('-4', '--ipv4'): + stacks += 4 + elif o in ('-6', '--ipv6'): + stacks += 6 + elif o in ('-a', '--auto'): + auto = True + elif o in ('-i', '--interface'): + dev.set(('device', a)) + elif o in ('-c', '--class'): + dev.set(('dhcpclass', a)) + elif o in ('--help'): + help = True + else: + unknown = True + + if help: + showhelp() + sys.exit(0) + + if unknown: + showusage() + sys.exit(1) + + if auto: + dev.set(('ipv6_autoconf', 'yes')) + else: + dev.set(('ipv6_autoconf', 'no')) + + if stacks == 10: + dev.set(('useipv4', True)) + dev.set(('useipv6', True)) + elif stacks == 6: + dev.set(('useipv4', False)) + dev.set(('useipv6', True)) + elif stacks == 4: + dev.set(('useipv4', True)) + dev.set(('useipv6', False)) + + try: + ns = isys.dhcpNetDevice(dev) + if ns: + f = open('/etc/resolv.conf', 'w') + f.write("nameserver %s\n" % ns) + f.close() + except: + print "Error configuring device %s." % (dev.get('device'),) + + sys.exit(0) diff --git a/command-stubs/pump-stub b/command-stubs/pump-stub deleted file mode 100755 index 63f093be6..000000000 --- a/command-stubs/pump-stub +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/python - -import os -import sys - -# for testing -if (os.path.exists('isys')): - sys.path.append('isys') - -sys.path.append('/usr/lib/anaconda') - -import isys -from sys import argv - -def usage(): - print "usage: pump [-i device]" - sys.exit(1) - -iface = "eth0" - -argv = argv[1:] -while (argv): - if argv[0] == "-i": - if len(argv) < 2: usage() - iface = argv[1] - argv = argv[2:] - else: - usage() - -ns = isys.pumpNetDevice(iface, None) -if ns: - f = open("/etc/resolv.conf", "w") - f.write("nameserver %s\n" % ns) - f.close() - -sys.exit(0) |