#include "manager.h"
#include "log.h"
#include "mount-setup.h"
+#include "hostname-setup.h"
+#include "load-fragment.h"
static enum {
ACTION_RUN,
};
if (startswith(word, "systemd.default="))
- return set_default_unit(word + 15);
+ return set_default_unit(word + 16);
else if (startswith(word, "systemd.log_target=")) {
/* Mount /proc, /sys and friends, so that /proc/cmdline and
* /proc/$PID/fd is available. */
- mount_setup();
+ if (mount_setup() < 0)
+ goto finish;
/* Reset all signal handlers. */
assert_se(reset_all_signal_handlers() == 0);
assert_se(action == ACTION_RUN || action == ACTION_TEST);
+ /* Set up PATH unless it is already set */
+ setenv("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", false);
+
/* Move out of the way, so that we won't block unmounts */
assert_se(chdir("/") == 0);
log_debug("systemd running in %s mode.", manager_running_as_to_string(running_as));
+ if (running_as == MANAGER_INIT)
+ if (hostname_setup() < 0)
+ goto finish;
+
if ((r = manager_new(running_as, &m)) < 0) {
log_error("Failed to allocate manager object: %s", strerror(-r));
goto finish;
if ((r = manager_load_unit(m, default_unit, &target)) < 0) {
log_error("Failed to load default target: %s", strerror(-r));
- goto finish;
+
+ log_info("Trying to load rescue target...");
+ if ((r = manager_load_unit(m, SPECIAL_RESCUE_TARGET, &target)) < 0) {
+ log_error("Failed to load rescue target: %s", strerror(-r));
+ goto finish;
+ }
}
if (action == ACTION_TEST) {