X-Git-Url: https://git.llucax.com/z.facultad/75.43/tp2.git/blobdiff_plain/00dfdc2ac6b61b92560a9ed11a090125d03aaec9..94aa4539679949634e8f531dbd3c2c152e89e0a8:/makeroute?ds=sidebyside diff --git a/makeroute b/makeroute index 2316394..65c533d 100755 --- a/makeroute +++ b/makeroute @@ -52,8 +52,12 @@ def up(host, fd): ppp = 0 for iface in hosts[host]['ifaces']: if iface['iface'].startswith('ppp'): - print 'UP: pppd -detach crtscts lock %(ip)s:%(peer)s /dev/ttyS0' % iface - os.system('pppd -detach crtscts lock %(ip)s:%(peer)s /dev/ttyS0 &' % iface) + if host == 'h131' or host == 'h118': + print 'UP: pppd -detach modem crtscts lock %(ip)s:%(peer)s /dev/ttyS0 9600' % iface + os.system('pppd -detach modem crtscts lock %(ip)s:%(peer)s /dev/ttyS0 9600 &' % iface) + else: + print 'UP: pppd -detach crtscts lock %(ip)s:%(peer)s /dev/ttyS0' % iface + os.system('pppd -detach crtscts lock %(ip)s:%(peer)s /dev/ttyS0 &' % iface) ppp = 1 else: print 'UP: ifconfig %(iface)s %(ip)s broadcast %(broadcast)s netmask %(mascara)s' % iface @@ -65,6 +69,10 @@ def up(host, fd): if ruta['metrica'] <> "0": 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) + os.system('cp /etc/hosts /etc/hosts.13.bak') + os.system('cp hosts /etc/hosts') + os.system('cp /etc/networks /etc/networks.13.bak') + os.system('cp networks /etc/networks') def down(host, fd): hosts = parse(fd) @@ -74,6 +82,8 @@ def down(host, fd): os.system('killall pppd') else: os.system('ifconfig %(iface)s down' % iface) + os.system('mv /etc/hosts.13.bak /etc/hosts') + os.system('mv /etc/networks.13.bak /etc/networks') def list(fd): hosts = parse(fd) @@ -89,6 +99,9 @@ if __name__ == '__main__': up(sys.argv[2], fd) elif sys.argv[1] == 'down': down(sys.argv[2], fd) + elif sys.argv[1] == 'restart': + down(sys.argv[2], fd) + up(sys.argv[2], file('routers_labo.csv')) elif sys.argv[1] == 'list': list(fd)