]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
start of "convert conf files to humanly readable"
authorAlan T. DeKok <aland@freeradius.org>
Sat, 9 Jun 2018 15:09:55 +0000 (11:09 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 9 Jun 2018 15:09:55 +0000 (11:09 -0400)
scripts/conf2adoc [new file with mode: 0755]

diff --git a/scripts/conf2adoc b/scripts/conf2adoc
new file mode 100755 (executable)
index 0000000..be96a06
--- /dev/null
@@ -0,0 +1,58 @@
+#!/usr/bin/env perl
+#
+#  $Id$
+#
+#  Convert conf files to Asciidoc
+#
+#
+
+$raw = 0;
+
+while (<>) {
+
+    # Skip ###### banners
+    if (/^##+$/) {
+       next;
+    }
+
+    if (/^\s*$/) {
+       next;
+    }
+
+    #
+    #  Comments in the configuration files get converted to plain
+    #  text.
+    #
+    if (/^\s*#/) {
+       s/^\s*#[\t ]*//;
+
+       #
+       #  If we WERE printing blocks of raw output, end that, and
+       #  reset the "raw" flag.
+       #
+       if ($raw == 1) {
+           print "```\n";
+           $raw = 0;
+       }
+
+       print;
+       next;
+    }
+
+    #
+    #  No comment at the start of the line.  It must be configuration.
+    #  Convert that to raw text.
+    #
+    #  If we were printing normal text, print out the "raw" header.
+    #
+    if ($raw == 0) {
+       print "```\n";
+       $raw = 1;
+    }
+
+    #
+    #  And print out the raw text.
+    #
+    print;
+}
+