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 | |
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`
-rw-r--r-- | CMakeLists.txt | 9 | ||||
-rw-r--r-- | cli/cli-miner.cpp | 44 | ||||
-rw-r--r-- | config.tpl (renamed from config.txt) | 10 |
3 files changed, 46 insertions, 17 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ade87b2..f818209 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -398,12 +398,3 @@ if( NOT "${CMAKE_INSTALL_PREFIX}" STREQUAL "${PROJECT_BINARY_DIR}" ) else() set(WIN_OUTPUT_RELEASE "/Release") endif() - -# avoid overwrite of user defined settings -# install `config.txt`if file not exists in `${CMAKE_INSTALL_PREFIX}/bin` -install(CODE " \ - if(NOT EXISTS ${CMAKE_INSTALL_PREFIX}/bin${WIN_OUTPUT_RELEASE}/config.txt)\n \ - file(INSTALL ${CMAKE_CURRENT_SOURCE_DIR}/config.txt \ - DESTINATION ${CMAKE_INSTALL_PREFIX}/bin${WIN_OUTPUT_RELEASE})\n \ - endif()" -) 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; @@ -1,3 +1,4 @@ +R"===( /* * pool_address - Pool address should be in the form "pool.supportxmr.com:3333". Only stratum pools are supported. * wallet_address - Your wallet, or pool login. @@ -5,9 +6,9 @@ * * We feature pools up to 1MH/s. For a more complete list see M5M400's pool list at www.moneropools.com */ -"pool_address" : "pool.usxmrpool.com:3333", -"wallet_address" : "", -"pool_password" : "", +"pool_address" : "POOLURL", +"wallet_address" : "POOLUSER", +"pool_password" : "POOLPASSWD", /* * Network timeouts. @@ -155,3 +156,6 @@ * This setting will only be needed in 2020's. No need to worry about it now. */ "prefer_ipv4" : true, + +)===" +
\ No newline at end of file |