ifupdown: implement --force

This commit is contained in:
Ariadne Conill 2020-09-08 19:17:00 -06:00
parent efe9b60e37
commit b514d31c26
3 changed files with 7 additions and 2 deletions

View file

@ -96,6 +96,9 @@ acquire_state_lock(const char *state_path, const char *lifname)
bool
skip_interface(struct lif_interface *iface, const char *ifname)
{
if (exec_opts.force)
return false;
if (up && iface->refcount > 0)
{
fprintf(stderr, "%s: skipping %s (already configured), use --force to force configuration\n",

View file

@ -68,13 +68,14 @@ set_no_lock(const char *opt_arg)
}
static void
no_op(const char *opt_arg)
set_force(const char *opt_arg)
{
(void) opt_arg;
exec_opts.force = true;
}
static struct if_option exec_options[] = {
{'f', "force", NULL, "force (de)configuration", false, no_op},
{'f', "force", NULL, "force (de)configuration", false, set_force},
{'i', "interfaces", "interfaces FILE", "use FILE for interface definitions", true, set_interfaces_file},
{'l', "no-lock", NULL, "do not use a lockfile to serialize state changes", false, set_no_lock},
{'n', "no-act", NULL, "do not actually run any commands", false, set_no_act},

View file

@ -23,6 +23,7 @@ struct lif_execute_opts {
bool verbose;
bool mock;
bool no_lock;
bool force;
const char *executor_path;
const char *interfaces_file;
const char *state_file;