Commit b4dea9a0 authored by Axel Auweter's avatar Axel Auweter
Browse files

Add preliminary web gui (under development).

parent f9932899
...@@ -27,9 +27,42 @@ void usage(int argc, char* argv[]) ...@@ -27,9 +27,42 @@ void usage(int argc, char* argv[])
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
/* Check if run from command line */
int argcReal;
char **argvReal;
if (isatty(fileno(stdin))) {
argcReal = argc;
argvReal = (char**)argv;
}
else {
/* Check if we are a CGI program */
if (!getenv("QUERY_STRING")) {
std::cout << "No terminal and no QUERY_STRING environment variable." << std::endl;
std::cout << "Exiting." << std::endl;
exit(EXIT_FAILURE);
}
/* Print content type */
std::cout << "Content-type: text/plain" << std::endl << std::endl;
/* Create argcReal and argvReal */
argcReal = 1;
argvReal = (char**)malloc(sizeof(char*));
argvReal[0] = strdup("dcdbconfig"); /* dummy to make consistent with command line invocation */
char *token = strtok(getenv("QUERY_STRING"), "&");
while (token) {
argcReal++;
argvReal = (char**)realloc((void*)argvReal, argcReal*sizeof(char*));
/* FIXME: should check if argvReal is NULL */
argvReal[argcReal-1] = token;
token = strtok(NULL, "&");
}
}
/* Check command line parameters */ /* Check command line parameters */
if (argc < 2) { if (argcReal < 2) {
usage(argc, argv); usage(argcReal, argvReal);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -39,49 +72,49 @@ int main(int argc, char* argv[]) ...@@ -39,49 +72,49 @@ int main(int argc, char* argv[])
host = "localhost"; host = "localhost";
} }
while ((ret=getopt(argc, argv, "+h:"))!=-1) { while ((ret=getopt(argcReal, argvReal, "+h:"))!=-1) {
switch(ret) { switch(ret) {
case 'h': case 'h':
host = optarg; host = optarg;
break; break;
default: default:
usage(argc, argv); usage(argcReal, argvReal);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
if (optind >= argc) { if (optind >= argcReal) {
std::cout << "Missing command!" << std::endl; std::cout << "Missing command!" << std::endl;
usage(argc, argv); usage(argcReal, argvReal);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/* Process user command */ /* Process user command */
if (strcasecmp(argv[optind], "help") == 0) { if (strcasecmp(argvReal[optind], "help") == 0) {
/* Help is special: either we do general usage or we trigger the class factory and run the printHelp() function */ /* Help is special: either we do general usage or we trigger the class factory and run the printHelp() function */
if (optind + 1 >= argc) { if (optind + 1 >= argcReal) {
usage (argc, argv); usage (argcReal, argvReal);
} }
else { else {
auto action = UserActionFactory::getAction(argv[optind+1]); auto action = UserActionFactory::getAction(argvReal[optind+1]);
if (action) { if (action) {
action->printHelp(argc, argv); action->printHelp(argcReal, argvReal);
} }
else { else {
std::cout << "Cannot provide help for unknown command: " << argv[optind+1] << std::endl; std::cout << "Cannot provide help for unknown command: " << argvReal[optind+1] << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
} }
else { else {
/* If the command is not help, we try to instantiate the respective class through the factory and process the command */ /* If the command is not help, we try to instantiate the respective class through the factory and process the command */
auto action = UserActionFactory::getAction(argv[optind]); auto action = UserActionFactory::getAction(argvReal[optind]);
if (action) { if (action) {
return action->executeCommand(argc, argv, optind, host); return action->executeCommand(argcReal, argvReal, optind, host);
} }
else { else {
std::cout << "Unknwon command: " << argv[1] << std::endl; std::cout << "Unknwon command: " << argvReal[1] << std::endl;
usage(argc, argv); usage(argcReal, argvReal);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
......
...@@ -61,7 +61,7 @@ int main(int argc, char * const argv[]) ...@@ -61,7 +61,7 @@ int main(int argc, char * const argv[])
} }
/* Print content type */ /* Print content type */
std::cout << "Content-type: text/html" << std::endl << std::endl; std::cout << "Content-type: text/plain" << std::endl << std::endl;
/* Create argcReal and argvReal */ /* Create argcReal and argvReal */
argcReal = 1; argcReal = 1;
......
...@@ -2,7 +2,7 @@ MAKEFILENAME := $(lastword $(MAKEFILE_LIST)) ...@@ -2,7 +2,7 @@ MAKEFILENAME := $(lastword $(MAKEFILE_LIST))
include config.mk include config.mk
LIBRARIES = DCDBLib LIBRARIES = DCDBLib
PROJECTS = FilePusher SysFsPusher CollectAgent ParastationProvider IPMIPusher MontBlancPusher SNMPPusher DCDBTools scripts PROJECTS = FilePusher SysFsPusher CollectAgent ParastationProvider IPMIPusher MontBlancPusher SNMPPusher DCDBTools scripts webgui
CASSANDRA_VERSION = 2.2.5 CASSANDRA_VERSION = 2.2.5
MOSQUITTO_VERSION = 1.3.5 MOSQUITTO_VERSION = 1.3.5
...@@ -311,6 +311,8 @@ $(DCDBDEPSPATH)/.prerequesites: $(DCDBDEPSPATH)/.extract-distfiles ...@@ -311,6 +311,8 @@ $(DCDBDEPSPATH)/.prerequesites: $(DCDBDEPSPATH)/.extract-distfiles
sed -i -e 's/#LoadModule\ cgid_module.*/LoadModule\ cgid_module\ modules\/mod_cgid.so/' $(DCDBDEPLOYPATH)/conf/httpd.conf; \ sed -i -e 's/#LoadModule\ cgid_module.*/LoadModule\ cgid_module\ modules\/mod_cgid.so/' $(DCDBDEPLOYPATH)/conf/httpd.conf; \
echo " Setting symlink for dcdbquery..."; \ echo " Setting symlink for dcdbquery..."; \
ln -s $(DCDBDEPLOYPATH)/bin/dcdbquery $(DCDBDEPLOYPATH)/cgi-bin/; \ ln -s $(DCDBDEPLOYPATH)/bin/dcdbquery $(DCDBDEPLOYPATH)/cgi-bin/; \
echo " Setting symlink for dcdbconfig..."; \
ln -s $(DCDBDEPLOYPATH)/bin/dcdbconfig $(DCDBDEPLOYPATH)/cgi-bin/; \
echo " Adding cgi-bin SymLinksIfOwnerMatch option..."; \ echo " Adding cgi-bin SymLinksIfOwnerMatch option..."; \
sed -i -e '/<Directory.*cgi-bin.>/,/<\/Directory>/ s/Options.*/Options\ SymLinksIfOwnerMatch/' $(DCDBDEPLOYPATH)/conf/httpd.conf; \ sed -i -e '/<Directory.*cgi-bin.>/,/<\/Directory>/ s/Options.*/Options\ SymLinksIfOwnerMatch/' $(DCDBDEPLOYPATH)/conf/httpd.conf; \
touch $(DCDBDEPSPATH)/$(H)/.installed; \ touch $(DCDBDEPSPATH)/$(H)/.installed; \
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment