Skip to content

Instantly share code, notes, and snippets.

Created May 16, 2012 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2713401 to your computer and use it in GitHub Desktop.
Save anonymous/2713401 to your computer and use it in GitHub Desktop.
ip="1.2.3.4"
netmask="4.3.2.1"
gateway="8.8.8.8"
interfaces = IO.readlines('interfaces').map do |line|
if line.start_with?("iface eth0")
"iface eth0 inet static\n"
"\taddress #{ip}\n"
"\tnetmask #{netmask}\n"
"\tgateway #{gateway}\n"
else
line
end
end
File.open('interfaces.new', 'w') do |file|
file.puts interfaces
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment