Skip to content

Instantly share code, notes, and snippets.

@raphink
Last active January 1, 2016 00:39
Show Gist options
  • Save raphink/8067585 to your computer and use it in GitHub Desktop.
Save raphink/8067585 to your computer and use it in GitHub Desktop.
Augeas.open do |aug|
aug.match('/files/etc/default//#comment').each_with_index do |p, i|
aug.set("/comments/raw/#{i}", "#{aug.get(p)}\n")
aug.text_store('Shellvars.lns', "/comments/raw/#{i}", "/comments/tree/#{i}")
end
end
def uncomment(variable)
Augeas.open do |aug|
matches = aug.match("/files/etc/default/grub/#comment[.=~regexp('.*#{variable}.*')]")
unless matches.empty?
aug.insert(matches.first, variable, false)
aug.set('/comment/raw', "#{aug.get(matches.first)}\n")
aug.text_store('Shellvars.lns', '/comment/raw', '/comment/tree')
aug.mv("/comment/tree/#{variable}", "/files/etc/default/grub/#{variable}")
aug.save!
end
end
end
uncomment 'GRUB_GFXMODE'
Augeas.open do |aug|
value = aug.get("/files/etc/default/grub/GRUB_GFXMODE")
puts "value: #{value}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment