added option for disabling automatic update check, add scan mode to start log
This commit is contained in:
+21
-2
@@ -111,6 +111,7 @@ static struct options opt = {
|
||||
false, // localOnly
|
||||
0, // httpPort
|
||||
"/var/" PACKAGE "/html", // htmlPath
|
||||
true, // updateCheck
|
||||
|
||||
PACKAGE_LOGFILE, // logFile
|
||||
-1, // logAreas
|
||||
@@ -156,7 +157,8 @@ static const char argpdoc[] =
|
||||
#define O_LOCAL (O_PIDFIL+1)
|
||||
#define O_HTTPPT (O_LOCAL+1)
|
||||
#define O_HTMLPA (O_HTTPPT+1)
|
||||
#define O_LOG (O_HTMLPA+1)
|
||||
#define O_UPDCHK (O_HTMLPA+1)
|
||||
#define O_LOG (O_UPDCHK+1)
|
||||
#define O_LOGARE (O_LOG+1)
|
||||
#define O_LOGLEV (O_LOGARE+1)
|
||||
#define O_RAW (O_LOGLEV+1)
|
||||
@@ -208,6 +210,7 @@ static const struct argp_option argpoptions[] = {
|
||||
{"localhost", O_LOCAL, NULL, 0, "Listen for command line connections on 127.0.0.1 interface only", 0 },
|
||||
{"httpport", O_HTTPPT, "PORT", 0, "Listen for HTTP connections on PORT, 0 to disable [0]", 0 },
|
||||
{"htmlpath", O_HTMLPA, "PATH", 0, "Path for HTML files served by HTTP port [/var/ebusd/html]", 0 },
|
||||
{"updatecheck", O_UPDCHK, "MODE", 0, "Set automatic update check to MODE (on|off) [on]", 0 },
|
||||
|
||||
{NULL, 0, NULL, 0, "Log options:", 5 },
|
||||
{"logfile", 'l', "FILE", 0, "Write log to FILE (only for daemon) [" PACKAGE_LOGFILE "]", 0 },
|
||||
@@ -456,6 +459,20 @@ error_t parse_opt(int key, char *arg, struct argp_state *state) {
|
||||
}
|
||||
opt->htmlPath = arg;
|
||||
break;
|
||||
case O_UPDCHK: // --updatecheck=on
|
||||
if (arg == NULL || arg[0] == 0) {
|
||||
argp_error(state, "invalid updatecheck");
|
||||
return EINVAL;
|
||||
}
|
||||
if (strcmp("on", arg) == 0) {
|
||||
opt->updateCheck = true;
|
||||
} else if (strcmp("off", arg) == 0) {
|
||||
opt->updateCheck = false;
|
||||
} else {
|
||||
argp_error(state, "invalid updatecheck");
|
||||
return EINVAL;
|
||||
}
|
||||
break;
|
||||
|
||||
// Log options:
|
||||
case 'l': // --logfile=/var/log/ebusd.log
|
||||
@@ -1173,7 +1190,9 @@ int main(int argc, char* argv[]) {
|
||||
signal(SIGINT, signalHandler);
|
||||
signal(SIGTERM, signalHandler);
|
||||
|
||||
logNotice(lf_main, PACKAGE_STRING "." REVISION " started");
|
||||
logNotice(lf_main, PACKAGE_STRING "." REVISION " started%s",
|
||||
opt.scanConfig ? opt.initialScan==ESC ? " with scan" : opt.initialScan==BROADCAST ? " with broadcast scan"
|
||||
: opt.initialScan==SYN ? " with full scan" : " with single scan" : "");
|
||||
|
||||
// load configuration files
|
||||
loadConfigFiles(s_messageMap);
|
||||
|
||||
@@ -69,6 +69,7 @@ struct options {
|
||||
bool localOnly; //!< listen on 127.0.0.1 interface only
|
||||
uint16_t httpPort; //!< optional port to listen for HTTP connections, 0 to disable [0]
|
||||
const char* htmlPath; //!< path for HTML files served by the HTTP port [/var/ebusd/html]
|
||||
bool updateCheck; //!< perform automatic update check
|
||||
|
||||
const char* logFile; //!< log file name [/var/log/ebusd.log]
|
||||
int logAreas; //!< log areas [all]
|
||||
|
||||
@@ -100,7 +100,7 @@ result_t UserList::addFromFile(const string& filename, unsigned int lineNo, map<
|
||||
MainLoop::MainLoop(const struct options& opt, Device *device, MessageMap* messages)
|
||||
: Thread(), m_device(device), m_reconnectCount(0), m_userList(opt.accessLevel), m_messages(messages),
|
||||
m_address(opt.address), m_scanConfig(opt.scanConfig), m_initialScan(opt.readOnly ? ESC : opt.initialScan),
|
||||
m_polling(opt.pollInterval > 0), m_enableHex(opt.enableHex), m_shutdown(false) {
|
||||
m_polling(opt.pollInterval > 0), m_enableHex(opt.enableHex), m_shutdown(false), m_runUpdateCheck(opt.updateCheck) {
|
||||
// open Device
|
||||
result_t result = m_device->open();
|
||||
if (result != RESULT_OK) {
|
||||
@@ -298,7 +298,7 @@ void MainLoop::run() {
|
||||
logError(lf_main, "conditions require a poll interval > 0");
|
||||
}
|
||||
}
|
||||
if (!m_shutdown && now > nextCheckRun) {
|
||||
if (m_runUpdateCheck && !m_shutdown && now > nextCheckRun) {
|
||||
TCPClient client;
|
||||
TCPSocket* socket = client.connect("ebusd.eu", 80);
|
||||
if (socket) {
|
||||
|
||||
@@ -376,6 +376,9 @@ class MainLoop : public Thread, DeviceListener {
|
||||
/** set to true to shutdown. */
|
||||
bool m_shutdown;
|
||||
|
||||
/** perform automatic update check. */
|
||||
bool m_runUpdateCheck;
|
||||
|
||||
/** the created @a BusHandler instance. */
|
||||
BusHandler* m_busHandler;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user