bool loaded_policy = false;
bool arm_reboot_watchdog = false;
bool queue_default_job = false;
- bool empty_etc = false;
+ bool first_boot = false;
char *switch_root_dir = NULL, *switch_root_init = NULL;
struct rlimit saved_rlimit_nofile = RLIMIT_MAKE_CONST(0), saved_rlimit_memlock = RLIMIT_MAKE_CONST((rlim_t) -1);
const char *error_message = NULL;
if (in_initrd())
log_info("Running in initial RAM disk.");
-
- /* Let's check whether /etc is already populated. We
- * don't actually really check for that, but use
- * /etc/machine-id as flag file. This allows container
- * managers and installers to provision a couple of
- * files already. If the container manager wants to
- * provision the machine ID itself it should pass
- * $container_uuid to PID 1. */
-
- empty_etc = access("/etc/machine-id", F_OK) < 0;
- if (empty_etc)
- log_info("Running with unpopulated /etc.");
+ else {
+ /* Let's check whether we are in first boot, i.e. whether /etc is still unpopulated. We use
+ * /etc/machine-id as flag file, for this: if it exists we assume /etc is populated, if it
+ * doesn't it's unpopulated. This allows container managers and installers to provision a
+ * couple of files already. If the container manager wants to provision the machine ID itself
+ * it should pass $container_uuid to PID 1. */
+
+ first_boot = access("/etc/machine-id", F_OK) < 0;
+ if (first_boot)
+ log_info("Running with unpopulated /etc.");
+ }
} else {
_cleanup_free_ char *t;
set_manager_defaults(m);
manager_set_show_status(m, arg_show_status);
- manager_set_first_boot(m, empty_etc);
+ manager_set_first_boot(m, first_boot);
/* Remember whether we should queue the default job */
queue_default_job = !arg_serialization || arg_switched_root;
if (r < 0)
return r;
+ /* If this is the first boot, and we are in the host system, then preset everything */
if (m->first_boot > 0 &&
- m->unit_file_scope == UNIT_FILE_SYSTEM &&
+ MANAGER_IS_SYSTEM(m) &&
!m->test_run_flags) {
r = unit_file_preset_all(UNIT_FILE_SYSTEM, 0, NULL, UNIT_FILE_PRESET_ENABLE_ONLY, NULL, 0);