aboutsummaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-10-09 21:40:55 +0000
committerOmar Polo <op@omarpolo.com>2021-10-09 21:40:55 +0000
commitf0a01fc742e83b3f4736b5d64af3ab18148afc5a (patch)
treeb0f9e815f8b7692787bc95fa70d896b648095abf /parse.y
parent5eb3fc905f5e3bd2f2d586fb1e0ceda879500b3e (diff)
two -n to dump the parsed configuration
This adds a barebone dumping of the parsed configuration. It is not complete, but I'm interested in dumping the full path to `cert' and `key' in order to write some scripts that can inspect the configuration, extract the certificates and renew them when expired automatically. It's not easy to parse gmid configuration otherwise because the syntax is flexible and users can use macros. Instead, the idea is to run gmid and let it dump the configuration once it's been parsed in a static and predictable format. Now is possible to parse gmid configuration with, say, awk or perl.
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y27
1 files changed, 27 insertions, 0 deletions
diff --git a/parse.y b/parse.y
index 54282a3..255be76 100644
--- a/parse.y
+++ b/parse.y
@@ -811,6 +811,33 @@ parse_conf(const char *filename)
exit(1);
}
+void
+print_conf(void)
+{
+ struct vhost *h;
+ /* struct location *l; */
+ /* struct envlist *e; */
+ /* struct alist *a; */
+
+ if (conf.chroot != NULL)
+ printf("chroot \"%s\"\n", conf.chroot);
+ printf("ipv6 %s\n", conf.ipv6 ? "on" : "off");
+ /* XXX: defined mimes? */
+ printf("port %d\n", conf.port);
+ printf("prefork %d\n", conf.prefork);
+ /* XXX: protocols? */
+ if (conf.user != NULL)
+ printf("user \"%s\"\n", conf.user);
+
+ TAILQ_FOREACH(h, &hosts, vhosts) {
+ printf("\nserver \"%s\" {\n", h->domain);
+ printf(" cert \"%s\"\n", h->cert);
+ printf(" key \"%s\"\n", h->key);
+ /* TODO: print locations... */
+ printf("}\n");
+ }
+}
+
int
symset(const char *name, const char *val, int persist)
{