I have recently been doing more of the GNS3Vault labs and have gotten tired of changing the image name each time I do a lab. The script below is the result. I just change into the directory where the topology.net file is located and run this command.
The are a couple of tricks to notice about the sed line. First, I replaced the sed delimiter from “/” to “:” to make it easier to work with directory names. Second, the single quotes around $PWD expands the variable before the command is run.
I hope this helps someone else.
#!/bin/bash # gns3-vault-fix # 2011-05-29 Jud Bishop # Change image file for GNS3Vault topology.net configuration files. PWD=`pwd` SAVE=$PWD/topology.net.0 CONF=$PWD/topology.net # Back up the original topology.net file. mv $CONF $SAVE # A couple of things to notice on this line. # 1. I replaced the sed delimiter from "/" to ":" to # make it easier to work with directory names. # 2. The single quotes around $PWD expands the variable before # sed goes to work. sed -e 's:image .*:image = '$PWD'/c3640-a3js-mz.124-25b.bin:g' <$SAVE >$CONF