562 |
565 |
563 |
566 |
564 int main(int argc, char *argv[]) |
567 int main(int argc, char *argv[]) |
565 { |
568 { |
566 int rc = 0, c, i; |
569 int rc = 0, c, i; |
|
570 char *homepath = NULL; |
567 |
571 |
568 while (1) { |
572 while (1) { |
569 int option_index = 0; |
573 int option_index = 0; |
570 static struct option long_options[] = { |
574 static struct option long_options[] = { |
571 {"debug", 0, 0, 'c'}, |
575 {"debug", 0, 0, 'c'}, |
588 openlog("brewco", LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_USER); |
592 openlog("brewco", LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_USER); |
589 syslog(LOG_NOTICE, "mbsePi-apps brewco v%s starting", VERSION); |
593 syslog(LOG_NOTICE, "mbsePi-apps brewco v%s starting", VERSION); |
590 if (debug) |
594 if (debug) |
591 fprintf(stdout, "mbsePi-apps brewco v%s starting\n", VERSION); |
595 fprintf(stdout, "mbsePi-apps brewco v%s starting\n", VERSION); |
592 |
596 |
|
597 /* |
|
598 * Set home directory path |
|
599 */ |
|
600 if (getenv((char *)"USER") == NULL) { |
|
601 homepath = xstrcpy((char *)"/root"); |
|
602 } else { |
|
603 homepath = xstrcpy(getenv((char *)"HOME")); |
|
604 } |
|
605 varpath = xstrcpy(homepath); |
|
606 varpath = xstrcat(varpath, (char *)"/.brewco/var/"); |
|
607 etcpath = xstrcpy(homepath); |
|
608 etcpath = xstrcat(etcpath, (char *)"/.brewco/etc/"); |
|
609 mkdirs(varpath, 0755); |
|
610 mkdirs(etcpath, 0755); |
|
611 |
|
612 fprintf(stdout, "home: %s etc=%s var=%s\n", homepath, etcpath, varpath); |
593 if (rdconfig()) { |
613 if (rdconfig()) { |
594 fprintf(stderr, "Error reading configuration\n"); |
614 fprintf(stderr, "Error reading configuration\n"); |
595 syslog(LOG_NOTICE, "Error reading configuration: halted"); |
615 syslog(LOG_NOTICE, "Error reading configuration: halted"); |
596 return 1; |
616 return 1; |
597 } |
617 } |