From 780bf9cf72d4d3a2ef5b8ea2a5b8582bbda2d855 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Mon, 4 Jul 2005 21:31:36 +0000 Subject: [PATCH] =?utf8?q?M=C3=83as=20comandos=20y=20boludeces=20del=20scr?= =?utf8?q?ipt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- makeroute | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/makeroute b/makeroute index 1cd184b..0c00402 100755 --- a/makeroute +++ b/makeroute @@ -1,7 +1,7 @@ #!/usr/bin/env python # vim: set et sw=4 sts=4 : -import sys +import sys, os def get_campos(line): r = [] @@ -50,20 +50,33 @@ def up(host): hosts = parse(sys.stdin) for iface in hosts[host]['ifaces']: if not iface['iface'].startswith('ppp'): - print 'ifconfig %(iface)s %(ip)s broadcast %(broadcast)s netmask %(mascara)s' % iface + print 'UP: ifconfig %(iface)s %(ip)s broadcast %(broadcast)s netmask %(mascara)s' % iface + os.system('ifconfig %(iface)s %(ip)s broadcast %(broadcast)s netmask %(mascara)s' % iface) for ruta in hosts[host]['rutas']: if ruta['metrica'] <> "0": - print 'route add -net %(ip)s gw %(gateway)s netmask %(mascara)s dev %(iface)s metric %(metrica)s' % ruta + print 'UP: route add -net %(ip)s gw %(gateway)s netmask %(mascara)s dev %(iface)s metric %(metrica)s' % ruta + os.system('route add -net %(ip)s gw %(gateway)s netmask %(mascara)s dev %(iface)s metric %(metrica)s' % ruta) def down(host): hosts = parse(sys.stdin) for iface in hosts[host]['ifaces']: if not iface['iface'].startswith('ppp'): - print 'ifconfig %(iface)s down' % iface + print 'DOWN: ifconfig %(iface)s down' % iface + os.system('ifconfig %(iface)s down' % iface) + +def list(): + hosts = parse(sys.stdin) + for host in hosts.keys(): + print host if __name__ == '__main__': + if len(sys.argv) < 2: + print >>sys.stderr, 'Uso: %s [up|down] host' % sys.argv[0] + sys.exit(1) if sys.argv[1] == 'up': up(sys.argv[2]) elif sys.argv[1] == 'down': down(sys.argv[2]) + elif sys.argv[1] == 'list': + list() -- 2.43.0