#include #include #include #include #include "actions.h" #include void usage(char* argv0) { printf("Usage: %s \n", argv0); exit(1); } int main(int argc, char** argv){ try { if (argc < 1) return 111; if (argc != 1 + 2) usage(argv[0]); std::string config_file = argv[1]; if (!een9::isRegularFile(config_file) || !een9::endsWith(config_file, ".json")) { printf("\"%s\" is not a json file\n", argv[1]); usage(argv[0]); } std::string cmd = argv[2]; std::string config_text; een9::readFile(config_file, config_text); const json::JSON config = json::parse_str_flawless(config_text); if (cmd == "initialize") { const char* ROOT_PW = getenv("ROOT_PW"); een9_ASSERT(ROOT_PW, "No root password specified." "Assign desired root password value to environment variable ROOT_PW"); std::string root_pw = ROOT_PW; initialize_website(config, root_pw); } else if (cmd == "run") { run_website(config); } else een9_THROW("unknown action (known are 'run', 'initialize')"); } catch (std::exception& e) { printf("System failure\n%s\n", e.what()); } return 0; }