diff options
author | psychocrypt <psychocrypt@users.noreply.github.com> | 2017-09-28 23:12:53 +0200 |
---|---|---|
committer | psychocrypt <psychocrypt@users.noreply.github.com> | 2017-09-30 23:46:08 +0200 |
commit | 39d144639f837ee4a49c25158c2385f007d01417 (patch) | |
tree | 7781efbe569249059f3e6383a41260f45af1abaf /cli/cli-miner.cpp | |
parent | 82242501b02d19cf6549d35c5b8a8dd2a62a84d0 (diff) | |
download | xmr-stak-39d144639f837ee4a49c25158c2385f007d01417.zip xmr-stak-39d144639f837ee4a49c25158c2385f007d01417.tar.gz |
config as template
- create config on startup
- remove copy `config.txt` on `make install`
Diffstat (limited to 'cli/cli-miner.cpp')
-rw-r--r-- | cli/cli-miner.cpp | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/cli/cli-miner.cpp b/cli/cli-miner.cpp index df9432e..f2c5c1d 100644 --- a/cli/cli-miner.cpp +++ b/cli/cli-miner.cpp @@ -29,6 +29,7 @@ #include "../console.h" #include "../donate-level.h" #include "../Params.hpp" +#include "../ConfigEditor.hpp" #include "../version.h" @@ -39,6 +40,7 @@ #include <stdlib.h> #include <stdio.h> #include <string> +#include <iostream> #include <time.h> @@ -91,17 +93,14 @@ int main(int argc, char *argv[]) else if(opName.compare("--noCPU") == 0) { Params::inst().useCPU = false; - return 0; } else if(opName.compare("--noAMD") == 0) { Params::inst().useAMD = false; - return 0; } else if(opName.compare("--noAMD") == 0) { Params::inst().useNVIDIA = false; - return 0; } else if(opName.compare("--cpu") == 0) { @@ -172,7 +171,42 @@ int main(int argc, char *argv[]) else Params::inst().configFile = argv[i]; } - + + // check if we need a guided start + if(!ConfigEditor::file_exist(Params::inst().configFile)) + { + // load the template of the backend config into a char variable + const char *tpl = + #include "../config.tpl" + ; + ConfigEditor configTpl{}; + configTpl.set(std::string(tpl)); + auto& pool = Params::inst().poolURL; + if(pool.empty()) + { + std::cout<<"Please enter:\n- pool address: e.g. pool.usxmrpool.com:3333"<<std::endl; + std::cin >> pool; + } + auto& userName = Params::inst().poolUsername; + if(userName.empty()) + { + std::cout<<"- user name (wallet address or pool login):"<<std::endl; + std::cin >> userName; + } + auto& passwd = Params::inst().poolPasswd; + if(passwd.empty()) + { + // clear everything from stdin to allow an empty password + std::cin.clear(); std::cin.ignore(INT_MAX,'\n'); + std::cout<<"- password (mostly empty or x):"<<std::endl; + getline(std::cin, passwd); + } + configTpl.replace("POOLURL", pool); + configTpl.replace("POOLUSER", userName); + configTpl.replace("POOLPASSWD", passwd); + configTpl.write(Params::inst().configFile); + std::cout<<"Configuration stored in file '"<<Params::inst().configFile<<"'"<<std::endl; + } if(!jconf::inst()->parse_config(Params::inst().configFile.c_str())) { @@ -180,7 +214,7 @@ int main(int argc, char *argv[]) return 0; } - if (!xmrstak::BackendConnector::self_test()) + if (!BackendConnector::self_test()) { win_exit(); return 0; |