libgluonutil: merge custom.json into site
This commit is contained in:
parent
dd94e84f77
commit
9aae9cf3a1
@ -253,6 +253,11 @@ bool gluonutil_has_domains(void) {
|
|||||||
return (access("/lib/gluon/domains/", F_OK) == 0);
|
return (access("/lib/gluon/domains/", F_OK) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool gluonutil_has_custom(void) {
|
||||||
|
return (access("/lib/gluon/custom.json", F_OK) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
char * gluonutil_get_domain(void) {
|
char * gluonutil_get_domain(void) {
|
||||||
if (!gluonutil_has_domains())
|
if (!gluonutil_has_domains())
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -328,15 +333,13 @@ char * gluonutil_get_primary_domain(void) {
|
|||||||
|
|
||||||
struct json_object * gluonutil_load_site_config(void) {
|
struct json_object * gluonutil_load_site_config(void) {
|
||||||
char *domain_code = NULL;
|
char *domain_code = NULL;
|
||||||
struct json_object *site = NULL, *domain = NULL;
|
struct json_object *site = NULL, *domain = NULL, *custom = NULL;
|
||||||
|
|
||||||
site = json_object_from_file("/lib/gluon/site.json");
|
site = json_object_from_file("/lib/gluon/site.json");
|
||||||
if (!site)
|
if (!site)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!gluonutil_has_domains())
|
if (gluonutil_has_domains()) {
|
||||||
return site;
|
|
||||||
|
|
||||||
domain_code = gluonutil_get_domain();
|
domain_code = gluonutil_get_domain();
|
||||||
if (!domain_code)
|
if (!domain_code)
|
||||||
goto err;
|
goto err;
|
||||||
@ -352,9 +355,23 @@ struct json_object * gluonutil_load_site_config(void) {
|
|||||||
if (!domain)
|
if (!domain)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
return merge_json(site, domain);
|
site = merge_json(site, domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gluonutil_has_custom()) {
|
||||||
|
custom = json_object_from_file("/lib/gluon/custom.json");
|
||||||
|
if (!custom)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
site = merge_json(site, custom);
|
||||||
|
}
|
||||||
|
|
||||||
|
return site;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
if (domain)
|
||||||
|
json_object_put(domain);
|
||||||
|
|
||||||
json_object_put(site);
|
json_object_put(site);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user