#!/bin/bash
authconfig $* --test | sed 's/ is \| are /=/
s/ = /=/
s/ by default\|always \| (.*)//
y/ +/__/
s/^_/ /
s/_or_.*=/=/
/="/! s/=/="/
/"$/! s/$/"/
/.=/! d
s/=/\#/' | awk -- '
BEGIN {
FS="#";
printf("<?xml version=\"1.0\"?>\n");
printf("<authconfig>\n");
printf(" <globals>\n");
SETTING="false";
}
!/^ / {
if (NR>1) {
if (SETTING=="true")
{ printf("/>\n");
printf(" </key>\n") }
else
{ printf("/>\n") }
}
SETTING="false";
printf(" <key name=\"%s\" value=%s",$1,$2)
}
/^ / {
if (SETTING=="false")
{ printf(">\n");
printf(" <settings")
}
printf("%s=%s",$1,$2);
SETTING="true";
}
END {
if (SETTING=="true")
{ printf("/>\n");
printf(" </key>\n") }
else
{ printf("/>\n") }
printf(" </globals>\n");
printf("</authconfig>\n");
}'
Wednesday, 6 August 2014
Printing authconfig output as XML
Just a quick followup to my post about bringing Openfiler up-to-date. Here is a script which takes the output of 'authconfig --test' and formats it as XML.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment