bmsd/bms.c

changeset 194
d202777ebae5
parent 0
033898178630
child 384
442d23455ae4
equal deleted inserted replaced
193:3cbd81ea9391 194:d202777ebae5
1 /***************************************************************************** 1 /*****************************************************************************
2 * Copyright (C) 2017-2018 2 * Copyright (C) 2017-2019
3 * 3 *
4 * Michiel Broek <mbroek at mbse dot eu> 4 * Michiel Broek <mbroek at mbse dot eu>
5 * 5 *
6 * This file is part of the bms (Brewery Management System) 6 * This file is part of the bms (Brewery Management System)
7 * 7 *
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *****************************************************************************/ 21 *****************************************************************************/
22 22
23 #include "bms.h" 23 #include "bms.h"
24 #include "xutil.h" 24 #include "xutil.h"
25 #include "futil.h"
25 #include "rdconfig.h" 26 #include "rdconfig.h"
26 #include "lock.h" 27 #include "lock.h"
27 #include "mqtt.h" 28 #include "mqtt.h"
28 #include "mysql.h" 29 #include "mysql.h"
29 30
30 31
31 int my_shutdown = FALSE; 32 int my_shutdown = FALSE;
32 int debug = FALSE; 33 int debug = FALSE;
33 static pid_t pgrp, mypid; 34 static pid_t pgrp, mypid;
34 char *Private_Path = NULL; /* Users data path */ 35 char *Private_Path = NULL; /* Users data path */
35 //char *resource_path = NULL; /* Webserver root */ 36
36 37 extern sys_config Config;
37 //extern struct lws_context *context;
38 38
39 39
40 void help(void) 40 void help(void)
41 { 41 {
42 fprintf(stdout, "bmsd v%s starting\n\n", VERSION); 42 fprintf(stdout, "bmsd v%s starting\n\n", VERSION);
69 69
70 int server(void) { 70 int server(void) {
71 uid_t myuid; 71 uid_t myuid;
72 struct passwd *mypwd; 72 struct passwd *mypwd;
73 int rc = 0; 73 int rc = 0;
74 char *tmppath = NULL;
74 75
75 myuid = getuid(); 76 myuid = getuid();
76 mypwd = getpwuid(myuid); 77 mypwd = getpwuid(myuid);
77 if (mypwd == NULL) { 78 if (mypwd == NULL) {
78 fprintf(stderr, "[main] Could not find passwd entry\n"); 79 fprintf(stderr, "[main] Could not find passwd entry\n");
89 90
90 if (rdconfig()) { 91 if (rdconfig()) {
91 rc = 2; 92 rc = 2;
92 goto endit1; 93 goto endit1;
93 } 94 }
95
96 if (! Config.web_root) {
97 rc = 5;
98 syslog(LOG_NOTICE, "Configuration `web_root' is not set");
99 goto endit1;
100 }
101
102 /*
103 * Make sure the needed log paths exist.
104 */
105 tmppath = xstrcpy(Config.web_root);
106 tmppath = xstrcat(tmppath, (char *)"/log/fermentation/");
107 if (! mkdirs(tmppath, 0755)) {
108 rc = 5;
109 goto endit1;
110 }
111 free(tmppath);
112 tmppath = xstrcpy(Config.web_root);
113 tmppath = xstrcat(tmppath, (char *)"/log/brews/");
114 if (! mkdirs(tmppath, 0755)) {
115 rc = 5;
116 goto endit1;
117 }
118 free(tmppath);
119 tmppath = NULL;
94 120
95 if (bms_mysql_init()) { 121 if (bms_mysql_init()) {
96 rc = 3; 122 rc = 3;
97 goto endit1; 123 goto endit1;
98 } 124 }

mercurial