diff -r 3cbd81ea9391 -r d202777ebae5 bmsd/bms.c --- a/bmsd/bms.c Sat Jan 19 20:42:11 2019 +0100 +++ b/bmsd/bms.c Mon Jan 21 20:45:18 2019 +0100 @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (C) 2017-2018 + * Copyright (C) 2017-2019 * * Michiel Broek * @@ -22,6 +22,7 @@ #include "bms.h" #include "xutil.h" +#include "futil.h" #include "rdconfig.h" #include "lock.h" #include "mqtt.h" @@ -32,9 +33,8 @@ int debug = FALSE; static pid_t pgrp, mypid; char *Private_Path = NULL; /* Users data path */ -//char *resource_path = NULL; /* Webserver root */ -//extern struct lws_context *context; +extern sys_config Config; void help(void) @@ -71,6 +71,7 @@ uid_t myuid; struct passwd *mypwd; int rc = 0; + char *tmppath = NULL; myuid = getuid(); mypwd = getpwuid(myuid); @@ -92,6 +93,31 @@ goto endit1; } + if (! Config.web_root) { + rc = 5; + syslog(LOG_NOTICE, "Configuration `web_root' is not set"); + goto endit1; + } + + /* + * Make sure the needed log paths exist. + */ + tmppath = xstrcpy(Config.web_root); + tmppath = xstrcat(tmppath, (char *)"/log/fermentation/"); + if (! mkdirs(tmppath, 0755)) { + rc = 5; + goto endit1; + } + free(tmppath); + tmppath = xstrcpy(Config.web_root); + tmppath = xstrcat(tmppath, (char *)"/log/brews/"); + if (! mkdirs(tmppath, 0755)) { + rc = 5; + goto endit1; + } + free(tmppath); + tmppath = NULL; + if (bms_mysql_init()) { rc = 3; goto endit1;