static char **arg_path_property = NULL;
static char **arg_socket_property = NULL;
static char **arg_timer_property = NULL;
-static bool arg_with_timer = false;
static bool arg_quiet = false;
static bool arg_verbose = false;
static OutputMode arg_output = _OUTPUT_MODE_INVALID;
if (r < 0)
return r;
- arg_with_timer = true;
break;
OPTION_LONG("on-boot", "SECONDS", "Run SECONDS after machine was booted up"):
if (r < 0)
return r;
- arg_with_timer = true;
break;
OPTION_LONG("on-startup", "SECONDS", "Run SECONDS after systemd activation"):
if (r < 0)
return r;
- arg_with_timer = true;
break;
OPTION_LONG("on-unit-active", "SECONDS", "Run SECONDS after the last activation"):
if (r < 0)
return r;
- arg_with_timer = true;
break;
OPTION_LONG("on-unit-inactive", "SECONDS",
if (r < 0)
return r;
- arg_with_timer = true;
break;
OPTION_LONG("on-calendar", "SPEC", "Realtime timer"): {
if (r < 0)
return r;
- arg_with_timer = true;
break;
}
if (r < 0)
return r;
- arg_with_timer = true;
break;
OPTION_LONG("on-clock-change", NULL, "Run when the realtime clock jumps"):
if (r < 0)
return r;
- arg_with_timer = true;
break;
OPTION_LONG("timer-property", "NAME=VALUE", "Set timer unit property"):
if (strv_extend(&arg_timer_property, opts.arg) < 0)
return log_oom();
- arg_with_timer = arg_with_timer ||
- STARTSWITH_SET(opts.arg,
- "OnActiveSec=",
- "OnBootSec=",
- "OnStartupSec=",
- "OnUnitActiveSec=",
- "OnUnitInactiveSec=",
- "OnCalendar=",
- "OnClockChange=",
- "OnTimezoneChange=");
break;
}
if (arg_runtime_scope == RUNTIME_SCOPE_USER)
arg_ask_password = false;
- with_trigger = !!arg_path_property || !!arg_socket_property || arg_with_timer;
+ size_t n_timer_triggers = 0, n_other_timer_properties = 0;
+ STRV_FOREACH(i, arg_timer_property)
+ if (STARTSWITH_SET(*i,
+ "OnActiveSec=",
+ "OnBootSec=",
+ "OnStartupSec=",
+ "OnUnitActiveSec=",
+ "OnUnitInactiveSec=",
+ "OnCalendar=",
+ "OnClockChange=",
+ "OnTimezoneChange="))
+ n_timer_triggers++;
+ else
+ n_other_timer_properties++;
+ if (n_other_timer_properties > 0 && n_timer_triggers == 0)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--timer-property= set without any timer trigger expression (i.e. On*= setting), refusing.");
+
+ with_trigger = arg_path_property || arg_socket_property || arg_timer_property;
/* currently, only single trigger (path, socket, timer) unit can be created simultaneously */
- if (!!arg_path_property + !!arg_socket_property + (int) arg_with_timer > 1)
+ if (!!arg_path_property + !!arg_socket_property + !!arg_timer_property > 1)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Only single trigger (path, socket, timer) unit can be created.");
"--json= is not compatible with path, socket or timer operations.");
}
- if (arg_timer_property && !arg_with_timer)
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
- "--timer-property= has no effect without any other timer options.");
-
if (arg_wait) {
if (arg_no_block)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
return start_transient_trigger(bus, ".path");
if (arg_socket_property)
return start_transient_trigger(bus, ".socket");
- if (arg_with_timer)
+ if (arg_timer_property)
return start_transient_trigger(bus, ".timer");
return start_transient_service(bus);
}