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

config as template

- create config on startup
- remove copy `config.txt` on `make install`
parent 82242501
No related branches found
No related tags found
No related merge requests found
......@@ -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()"
)
......@@ -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;
......
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
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