mirror of
https://github.com/SuperBFG7/ympd
synced 2024-11-17 11:04:48 +00:00
Fix: check existance of needed directories under /var/lib/mympd
This commit is contained in:
parent
9d1236e92a
commit
2a675bc4e8
41
src/mympd.c
41
src/mympd.c
@ -183,6 +183,8 @@ static int inihandler(void* user, const char* section, const char* name, const c
|
|||||||
void read_statefiles() {
|
void read_statefiles() {
|
||||||
char *crap;
|
char *crap;
|
||||||
char value[400];
|
char value[400];
|
||||||
|
|
||||||
|
printf("Reading states\n");
|
||||||
if (mympd_state_get("notificationWeb", value)) {
|
if (mympd_state_get("notificationWeb", value)) {
|
||||||
if (strcmp(value, "true") == 0)
|
if (strcmp(value, "true") == 0)
|
||||||
mympd_state.notificationWeb = true;
|
mympd_state.notificationWeb = true;
|
||||||
@ -227,12 +229,26 @@ void read_statefiles() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool testdir(char *name, char *dirname) {
|
||||||
|
DIR* dir = opendir(dirname);
|
||||||
|
if (dir) {
|
||||||
|
closedir(dir);
|
||||||
|
printf("%s: \"%s\"\n", name, dirname);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("%s: \"%s\" don't exists\n", name, dirname);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
struct mg_mgr mgr;
|
struct mg_mgr mgr;
|
||||||
struct mg_connection *nc;
|
struct mg_connection *nc;
|
||||||
struct mg_connection *nc_http;
|
struct mg_connection *nc_http;
|
||||||
struct mg_bind_opts bind_opts;
|
struct mg_bind_opts bind_opts;
|
||||||
const char *err;
|
const char *err;
|
||||||
|
char testdirname[400];
|
||||||
|
|
||||||
//defaults
|
//defaults
|
||||||
config.mpdhost = "127.0.0.1";
|
config.mpdhost = "127.0.0.1";
|
||||||
@ -277,16 +293,6 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
printf("Starting myMPD %s\n", MYMPD_VERSION);
|
printf("Starting myMPD %s\n", MYMPD_VERSION);
|
||||||
|
|
||||||
DIR* dir = opendir(SRC_PATH);
|
|
||||||
if (dir) {
|
|
||||||
printf("Document root: %s\n", SRC_PATH);
|
|
||||||
closedir(dir);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
printf("Document root \"%s\" don't exists\n", SRC_PATH);
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
signal(SIGTERM, signal_handler);
|
signal(SIGTERM, signal_handler);
|
||||||
signal(SIGINT, signal_handler);
|
signal(SIGINT, signal_handler);
|
||||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||||
@ -349,6 +355,21 @@ int main(int argc, char **argv) {
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!testdir("Document root", SRC_PATH))
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
snprintf(testdirname, 400, "%s/tmp", config.varlibdir);
|
||||||
|
if (!testdir("Temp dir", testdirname))
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
snprintf(testdirname, 400, "%s/smartpls", config.varlibdir);
|
||||||
|
if (!testdir("Smartpls dir", testdirname))
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
|
snprintf(testdirname, 400, "%s/state", config.varlibdir);
|
||||||
|
if (!testdir("State dir", testdirname))
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
read_statefiles();
|
read_statefiles();
|
||||||
|
|
||||||
if (config.ssl == true)
|
if (config.ssl == true)
|
||||||
|
Loading…
Reference in New Issue
Block a user