Last active
January 1, 2016 00:39
-
-
Save raphink/8067585 to your computer and use it in GitHub Desktop.
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
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 |
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
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