temporary files which will be written to the real location if the
editor exits successfully.</para>
+ <para>If <option>--drop-in=</option> is specified, the given drop-in file name
+ will be used instead of the default <filename>override.conf</filename>.</para>
+
<para>If <option>--full</option> is specified, this will copy the
original units instead of creating drop-in files.</para>
<listitem><para>When used with <command>bind</command>, creates a read-only bind mount.</para></listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--drop-in=</option></term>
+
+ <listitem>
+ <para>When used with <command>edit</command>, use the given drop-in file name instead of
+ <filename>override.conf</filename>.</para>
+ </listitem>
+ </varlistentry>
+
<xi:include href="user-system-options.xml" xpointer="host" />
<xi:include href="user-system-options.xml" xpointer="machine" />
_cleanup_(hashmap_freep) Hashmap *cached_name_map = NULL, *cached_id_map = NULL;
_cleanup_(edit_file_free_all) EditFile *edit_files = NULL;
_cleanup_(lookup_paths_free) LookupPaths lp = {};
+ _cleanup_free_ char *drop_in_alloc = NULL, *suffix = NULL;
+ const char *drop_in;
size_t n_edit_files = 0;
int r;
assert(names);
assert(ret_edit_files);
+ if (isempty(arg_drop_in))
+ drop_in = "override.conf";
+ else if (!endswith(arg_drop_in, ".conf")) {
+ drop_in_alloc = strjoin(arg_drop_in, ".conf");
+ if (!drop_in_alloc)
+ return log_oom();
+
+ drop_in = drop_in_alloc;
+ } else
+ drop_in = arg_drop_in;
+
+ if (!filename_is_valid(drop_in))
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid drop-in file name '%s'.", drop_in);
+
+ suffix = strjoin(".d/", drop_in);
+ if (!suffix)
+ return log_oom();
+
r = lookup_paths_init(&lp, arg_scope, 0, arg_root);
if (r < 0)
return r;
r = unit_file_create_new(
&lp,
*name,
- arg_full ? NULL : ".d/override.conf",
+ arg_full ? NULL : suffix,
NULL,
edit_files + n_edit_files);
} else {
r = unit_file_create_new(
&lp,
unit_name,
- ".d/override.conf",
+ suffix,
unit_paths,
edit_files + n_edit_files);
}
bool arg_read_only = false;
bool arg_mkdir = false;
bool arg_marked = false;
+const char *arg_drop_in = NULL;
STATIC_DESTRUCTOR_REGISTER(arg_types, strv_freep);
STATIC_DESTRUCTOR_REGISTER(arg_states, strv_freep);
STATIC_DESTRUCTOR_REGISTER(arg_host, unsetp);
STATIC_DESTRUCTOR_REGISTER(arg_boot_loader_entry, unsetp);
STATIC_DESTRUCTOR_REGISTER(arg_clean_what, strv_freep);
+STATIC_DESTRUCTOR_REGISTER(arg_drop_in, unsetp);
static int systemctl_help(void) {
_cleanup_free_ char *link = NULL;
" --read-only Create read-only bind mount\n"
" --mkdir Create directory before mounting, if missing\n"
" --marked Restart/reload previously marked units\n"
+ " --drop-in=NAME Edit unit files using the specified drop-in file name\n"
"\nSee the %2$s for details.\n",
program_invocation_short_name,
link,
ARG_MKDIR,
ARG_MARKED,
ARG_NO_WARN,
+ ARG_DROP_IN,
};
static const struct option options[] = {
{ "read-only", no_argument, NULL, ARG_READ_ONLY },
{ "mkdir", no_argument, NULL, ARG_MKDIR },
{ "marked", no_argument, NULL, ARG_MARKED },
+ { "drop-in", required_argument, NULL, ARG_DROP_IN },
{}
};
arg_no_warn = true;
break;
+ case ARG_DROP_IN:
+ arg_drop_in = optarg;
+ break;
+
case '.':
/* Output an error mimicking getopt, and print a hint afterwards */
log_error("%s: invalid option -- '.'", program_invocation_name);
extern bool arg_read_only;
extern bool arg_mkdir;
extern bool arg_marked;
+extern const char *arg_drop_in;
static inline const char* arg_job_mode(void) {
return _arg_job_mode ?: "replace";