From 2634a85ca986eca262f565e2dbd90962f99c7273 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Sat, 18 Jun 2016 20:22:18 +0100 Subject: [PATCH] Add a new service setting, "options", which can be used for various options and which deprecates several other settings. Includes a new option, starts-log, specifying that the service starts the syslog service. --- src/load_service.cc | 29 +++++++++++++++++++++++++++++ src/service.h | 3 ++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/load_service.cc b/src/load_service.cc index 79972ff..a4a4f88 100644 --- a/src/load_service.cc +++ b/src/load_service.cc @@ -437,6 +437,7 @@ ServiceRecord * ServiceSet::loadServiceRecord(const char * name) } } else if (setting == "onstart") { + // deprecated std::list> indices; string onstart_cmds = read_setting_value(i, end, &indices); for (auto indexpair : indices) { @@ -444,11 +445,37 @@ ServiceRecord * ServiceSet::loadServiceRecord(const char * name) if (onstart_cmd == "rw_ready") { onstart_flags.rw_ready = true; } + else if (onstart_cmd == "log_ready") { + onstart_flags.log_ready = true; + } else { throw new ServiceDescriptionExc(name, "Unknown onstart command: " + onstart_cmd); } } } + else if (setting == "options") { + std::list> indices; + string onstart_cmds = read_setting_value(i, end, &indices); + for (auto indexpair : indices) { + string option_txt = onstart_cmds.substr(indexpair.first, indexpair.second - indexpair.first); + if (option_txt == "starts-rwfs") { + onstart_flags.rw_ready = true; + } + else if (option_txt == "starts-log") { + onstart_flags.log_ready = true; + } + else if (option_txt == "nosigterm") { + onstart_flags.no_sigterm = true; + } + else if (option_txt == "runs-on-console") { + onstart_flags.runs_on_console = true; + } + else { + throw new ServiceDescriptionExc(name, "Unknown option: " + option_txt); + } + } + + } else if (setting == "termsignal") { string signame = read_setting_value(i, end, nullptr); int signo = signalNameToNumber(signame); @@ -460,10 +487,12 @@ ServiceRecord * ServiceSet::loadServiceRecord(const char * name) } } else if (setting == "nosigterm") { + // deprecated string sigtermsetting = read_setting_value(i, end); onstart_flags.no_sigterm = (sigtermsetting == "yes" || sigtermsetting == "true"); } else if (setting == "runs-on-console") { + // deprecated string runconsolesetting = read_setting_value(i, end); onstart_flags.runs_on_console = (runconsolesetting == "yes" || runconsolesetting == "true"); } diff --git a/src/service.h b/src/service.h index a45471d..b1b1963 100644 --- a/src/service.h +++ b/src/service.h @@ -72,12 +72,13 @@ struct OnstartFlags { bool rw_ready : 1; + bool log_ready : 1; // Not actually "onstart" commands: bool no_sigterm : 1; // do not send SIGTERM bool runs_on_console : 1; // run "in the foreground" - OnstartFlags() noexcept : rw_ready(false), + OnstartFlags() noexcept : rw_ready(false), log_ready(false), no_sigterm(false), runs_on_console(false) { } -- 2.25.1