daemon: make possible to set datadir before init

Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
R4SAS 2022-04-09 19:57:16 +03:00
parent 678a1ae0fb
commit 2f10decf56
2 changed files with 35 additions and 17 deletions

View File

@ -64,6 +64,12 @@ namespace util
return service;
}
void Daemon_Singleton::setDataDir(std::string path)
{
if (path != "")
DaemonDataDir = path;
}
bool Daemon_Singleton::init(int argc, char* argv[]) {
return init(argc, argv, nullptr);
}
@ -74,7 +80,13 @@ namespace util
i2p::config::ParseCmdline(argc, argv);
std::string config; i2p::config::GetOption("conf", config);
std::string datadir; i2p::config::GetOption("datadir", datadir);
std::string datadir;
if(DaemonDataDir != "") {
datadir = DaemonDataDir;
} else {
i2p::config::GetOption("datadir", datadir);
}
i2p::fs::DetectDataDir(datadir, IsService());
i2p::fs::Init();

View File

@ -28,6 +28,8 @@ namespace util
virtual bool stop ();
virtual void run () {};
virtual void setDataDir (std::string path);
bool isDaemon;
bool running;
@ -41,6 +43,10 @@ namespace util
// d-pointer for httpServer, httpProxy, etc.
class Daemon_Singleton_Private;
Daemon_Singleton_Private &d;
private:
std::string DaemonDataDir;
};
#if defined(QT_GUI_LIB) // check if QT