Created
March 17, 2017 18:13
-
-
Save hectorgool/accde0947a5c4ec7ebbb7c5a5e6074f6 to your computer and use it in GitHub Desktop.
fw_migracion.pl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl -w | |
| system("clear"); | |
| open( F, "objetivos.txt" ) || die "Error al abrir archivo"; | |
| @centros = <F>; | |
| $contador = 0; | |
| foreach ( @centros ) { | |
| @campos=split(/:/, $_); | |
| $alias = $campos[0]; | |
| $ip = $campos[1]; | |
| $contador++; | |
| chop($ip); | |
| $alias = lc $alias; | |
| print "\n"; | |
| print "#$contador:$alias\n"; | |
| print "ssh -p 443 -o StrictHostKeyChecking=no root\@$ip.5\n"; | |
| print "virsh list --all\n"; | |
| print "virsh shutdown fw-$alias\n"; | |
| print "virsh dumpxml fw-$alias >> /root/fw-$alias.xml\n"; | |
| print "virsh undefine fw-$alias\n"; | |
| print "virsh attach-disk fw16-$alias --source /dev/vms/fw-$alias-cache --target vdb --persistent\n"; | |
| print "virsh attach-disk fw16-$alias --source /dev/vms/fw-$alias-logs --target vdc --persistent\n"; | |
| print "exit\n"; | |
| print "\n"; | |
| print "ssh -p 443 -o StrictHostKeyChecking=no root\@$ip.20\n"; | |
| print "fdisk -l\n"; | |
| print "rm -rf /var/{log,spool}/squid/*\n"; | |
| print "e2label /dev/vdb1 cache\n"; | |
| print "e2label /dev/vdc1 logs\n"; | |
| print "blkid\n"; | |
| print "cp -vf /etc/fstab /root/fstab.bk\n"; | |
| print "echo 'LABEL=logs /var/log/squid ext4 defaults,noatime 0 2' >> /etc/fstab\n"; | |
| print "echo 'LABEL=cache /var/spool/squid ext4 defaults,noatime 0 2' >> /etc/fstab\n"; | |
| print "mount -a\n"; | |
| print "mount|grep '/dev/vd'\n"; | |
| print "ls -ld /var/log/squid\n"; | |
| print "ls -ld /var/spool/squid\n"; | |
| print "#vim /etc/network/interfaces\n"; | |
| print "#cambiar el gw\n"; | |
| print "#comentar las lineas LAN\n"; | |
| print "#reboot"; | |
| print "\n"; | |
| print "\n"; | |
| print "\n"; | |
| print "###############################################################################################\n"; | |
| } | |
| print "\n"; | |
| close(F); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| xxx1:nnn.nnn.nnn | |
| xxx2:nnn.nnn.nnn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment