Add a new service setting, "options", which can be used for various options
authorDavin McCall <davmac@davmac.org>
Sat, 18 Jun 2016 19:22:18 +0000 (20:22 +0100)
committerDavin McCall <davmac@davmac.org>
Sat, 18 Jun 2016 19:22:18 +0000 (20:22 +0100)
and which deprecates several other settings. Includes a new option, starts-log,
specifying that the service starts the syslog service.

src/load_service.cc
src/service.h

index 79972ffe0e9a66475905315ae57a276e9b544a6e..a4a4f881185d72369e637ff08fd621aa4ef9522d 100644 (file)
@@ -437,6 +437,7 @@ ServiceRecord * ServiceSet::loadServiceRecord(const char * name)
                     }
                 }
                 else if (setting == "onstart") {
+                    // deprecated
                     std::list<std::pair<unsigned,unsigned>> 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<std::pair<unsigned,unsigned>> 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");
                 }
index a45471dac01f76d3f400890430a49dd3cfd1b559..b1b1963bb70119e39c38a9bdb2093c6bcfb95440 100644 (file)
 
 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)
     {
     }