Skip to content

Commit

Permalink
Support for "+=" in service settings ("command" only)
Browse files Browse the repository at this point in the history
This adds support for "+=" operator as a way to append to setting values
in service description files (instead of "=" which is currently used for
assignment). For the moment, it is implemented only for the "command"
setting.

This should be useful for user customisation of system services - the
user can override the system service description, but @include the
original, and then add extra arguments to the command line via "command
+= ...".

Support for additional commands, tests, and documentation will follow.
  • Loading branch information
davmac314 committed Sep 8, 2024
1 parent 63d7701 commit 344012b
Show file tree
Hide file tree
Showing 8 changed files with 602 additions and 330 deletions.
10 changes: 5 additions & 5 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ifeq ($(BUILD_SHUTDOWN),yes)
endif

dinit_objects = dinit.o load-service.o service.o proc-service.o baseproc-service.o control.o dinit-log.o \
dinit-main.o run-child-proc.o options-processing.o dinit-env.o
dinit-main.o run-child-proc.o options-processing.o dinit-env.o settings.o

objects = $(dinit_objects) dinitctl.o dinitcheck.o shutdown.o dinit-monitor.o

Expand All @@ -23,11 +23,11 @@ all: dinit dinitctl dinitcheck dinit-monitor $(SHUTDOWN)
dinit: $(dinit_objects)
$(CXX) -o dinit $(dinit_objects) $(ALL_LDFLAGS)

dinitctl: dinitctl.o options-processing.o
$(CXX) -o dinitctl dinitctl.o options-processing.o $(ALL_LDFLAGS)
dinitctl: dinitctl.o options-processing.o settings.o
$(CXX) -o dinitctl dinitctl.o options-processing.o settings.o $(ALL_LDFLAGS)

dinitcheck: dinitcheck.o options-processing.o
$(CXX) -o dinitcheck dinitcheck.o options-processing.o $(ALL_LDFLAGS)
dinitcheck: dinitcheck.o options-processing.o settings.o
$(CXX) -o dinitcheck dinitcheck.o options-processing.o settings.o $(ALL_LDFLAGS)

dinit-monitor: dinit-monitor.o
$(CXX) -o dinit-monitor dinit-monitor.o $(ALL_LDFLAGS)
Expand Down
4 changes: 2 additions & 2 deletions src/dinitcheck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ service_record *load_service(service_set_t &services, const std::string &name,

try {
process_service_file(name, input_stack,
[&](string &line, file_pos_ref input_pos, string &setting,
[&](string &line, file_pos_ref input_pos, string &setting, setting_op_t op,
string_iterator &i, string_iterator &end) -> void {

auto process_dep_dir_n = [&](std::list<prelim_dep> &deplist, const std::string &waitsford,
Expand All @@ -671,7 +671,7 @@ service_record *load_service(service_set_t &services, const std::string &name,
};

try {
process_service_line(settings, name.c_str(), line, input_pos, setting, i, end,
process_service_line(settings, name.c_str(), line, input_pos, setting, op, i, end,
load_service_n, process_dep_dir_n);
}
catch (service_description_exc &exc) {
Expand Down
3 changes: 2 additions & 1 deletion src/dinitctl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1775,7 +1775,8 @@ static int enable_disable_service(int socknum, cpbuffer_t &rbuffer, service_dir_
input_stack.push(service_file_path, std::move(service_file));

try {
process_service_file(from, input_stack, [&](string &line, file_pos_ref fpr, string &setting,
process_service_file(from, input_stack, [&](string &line, file_pos_ref fpr,
string &setting, dinit_load::setting_op_t op,
dinit_load::string_iterator i, dinit_load::string_iterator end) -> void {
if (setting == "waits-for" || setting == "depends-on" || setting == "depends-ms") {
string dname = dinit_load::read_setting_value(fpr, i, end);
Expand Down
Loading

0 comments on commit 344012b

Please sign in to comment.