Skip to content
Snippets Groups Projects
Commit d8d24bb4 authored by psychocrypt's avatar psychocrypt
Browse files

fix simple start

Simple starts requires always user interactions if config.txt and
pools.txt is not available.
This PR asked the user only on the first advanced option if he/she
preferse the simple start or an advanced mode.
If all parameter are already defined via command line options than the
question will never be shown.
parent 3d1d37a0
No related branches found
No related tags found
No related merge requests found
...@@ -195,7 +195,14 @@ inline void prompt_once(bool& prompted) ...@@ -195,7 +195,14 @@ inline void prompt_once(bool& prompted)
} }
} }
void do_guided_pool_config(const bool use_simple_start) inline bool use_simple_start()
{
// ask this question only once
static bool simple_start = read_yes_no("\nUse simple setup method? (Y/n)", "Y");
return simple_start;
}
void do_guided_pool_config()
{ {
using namespace xmrstak; using namespace xmrstak;
...@@ -261,19 +268,22 @@ void do_guided_pool_config(const bool use_simple_start) ...@@ -261,19 +268,22 @@ void do_guided_pool_config(const bool use_simple_start)
} }
auto& rigid = params::inst().poolRigid; auto& rigid = params::inst().poolRigid;
if(!use_simple_start && rigid.empty() && !params::inst().userSetRigid) if(rigid.empty() && !params::inst().userSetRigid)
{ {
prompt_once(prompted); if(!use_simple_start())
if(!stdin_flushed)
{ {
// clear everything from stdin to allow an empty rigid prompt_once(prompted);
std::cin.clear();
std::cin.ignore(INT_MAX, '\n');
}
std::cout << "- Rig identifier for pool-side statistics (needs pool support). Can be empty:" << std::endl; if(!stdin_flushed)
getline(std::cin, rigid); {
// clear everything from stdin to allow an empty rigid
std::cin.clear();
std::cin.ignore(INT_MAX, '\n');
}
std::cout << "- Rig identifier for pool-side statistics (needs pool support). Can be empty:" << std::endl;
getline(std::cin, rigid);
}
} }
bool tls = params::inst().poolUseTls; bool tls = params::inst().poolUseTls;
...@@ -289,15 +299,19 @@ void do_guided_pool_config(const bool use_simple_start) ...@@ -289,15 +299,19 @@ void do_guided_pool_config(const bool use_simple_start)
#endif #endif
bool nicehash = params::inst().nicehashMode; bool nicehash = params::inst().nicehashMode;
if(!use_simple_start && !userSetPool) if(!userSetPool)
{ {
prompt_once(prompted); if(!use_simple_start())
nicehash = read_yes_no("- Do you want to use nicehash on this pool? (y/N)", "N"); {
prompt_once(prompted);
nicehash = read_yes_no("- Do you want to use nicehash on this pool? (y/N)", "N");
}
} }
bool multipool = false; bool multipool = false;
if(!use_simple_start && !userSetPool) if(!userSetPool)
multipool = read_yes_no("- Do you want to use multiple pools? (y/N)", "N"); if(!use_simple_start())
multipool = read_yes_no("- Do you want to use multiple pools? (y/N)", "N");
int64_t pool_weight = 1; int64_t pool_weight = 1;
if(multipool) if(multipool)
...@@ -335,7 +349,7 @@ void do_guided_pool_config(const bool use_simple_start) ...@@ -335,7 +349,7 @@ void do_guided_pool_config(const bool use_simple_start)
std::cout << "Pool configuration stored in file '" << params::inst().configFilePools << "'" << std::endl; std::cout << "Pool configuration stored in file '" << params::inst().configFilePools << "'" << std::endl;
} }
void do_guided_config(const bool use_simple_start) void do_guided_config()
{ {
using namespace xmrstak; using namespace xmrstak;
...@@ -353,7 +367,7 @@ void do_guided_config(const bool use_simple_start) ...@@ -353,7 +367,7 @@ void do_guided_config(const bool use_simple_start)
{ {
http_port = params::httpd_port_disabled; http_port = params::httpd_port_disabled;
#ifndef CONF_NO_HTTPD #ifndef CONF_NO_HTTPD
if(!use_simple_start) if(!use_simple_start())
{ {
prompt_once(prompted); prompt_once(prompted);
...@@ -737,17 +751,13 @@ int main(int argc, char* argv[]) ...@@ -737,17 +751,13 @@ int main(int argc, char* argv[])
bool hasConfigFile = configEditor::file_exist(params::inst().configFile); bool hasConfigFile = configEditor::file_exist(params::inst().configFile);
bool hasPoolConfig = configEditor::file_exist(params::inst().configFilePools); bool hasPoolConfig = configEditor::file_exist(params::inst().configFilePools);
if(!hasConfigFile || !hasPoolConfig) // check if we need a guided start
{ if(!hasConfigFile)
bool use_simple_start = read_yes_no("\nUse simple setup method? (Y/n)", "Y"); do_guided_config();
// check if we need a guided start if(!hasPoolConfig)
if(!hasConfigFile) do_guided_pool_config();
do_guided_config(use_simple_start);
if(!hasPoolConfig)
do_guided_pool_config(use_simple_start);
}
if(!jconf::inst()->parse_config(params::inst().configFile.c_str(), params::inst().configFilePools.c_str())) if(!jconf::inst()->parse_config(params::inst().configFile.c_str(), params::inst().configFilePools.c_str()))
{ {
win_exit(); win_exit();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment