Skip to content

Instantly share code, notes, and snippets.

@raphink
Last active August 29, 2015 14:25
Show Gist options
  • Save raphink/2af3b0cd2a7f5f37fa31 to your computer and use it in GitHub Desktop.
Save raphink/2af3b0cd2a7f5f37fa31 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="utf-8"?><tomcat-users><role rolename="manager"></role>
<user username="tcadmin" password="password" roles="manager"></user>
</tomcat-users>
#!/usr/bin/augtool -Asf
transform Xml.lns incl /tmp/test.xml
load
set /augeas/context /files/tmp/test.xml
# header
set "#declaration/#attribute/version" "1.0"
set "#declaration/#attribute/encoding" "utf-8"
# role
set tomcat-users/role[#attribute/rolename="manager"]/#attribute/rolename "manager"
# user
defnode user tomcat-users/user[#attribute/username="tcadmin"]
set $user/#attribute/username "tcadmin"
set $user/#attribute/password "password"
set $user/#attribute/roles "manager"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment