#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <limits.h>
#include <sys/wait.h>
#include <time.h>
#include <math.h>
#include <sys/types.h>
#include <sys/syscall.h>
#include <sys/stat.h>
#include <syslog.h>
#include <dirent.h>
#include <stdbool.h>
#include <linux/version.h>
#include <sys/wait.h>

#include <syslog.h>
#include "bus-wait-for-jobs.h"
#include "main-func.h"
#include "sd-bus.h"
#include "fd-util.h"
#include "fileio.h"

static int run(int argc, char* argv[])
{
    _cleanup_(sd_bus_message_unrefp) sd_bus_message *msg = NULL, *reply = NULL;
    _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
    _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
    const char *object = NULL;
    int r, ret = 0;
    _cleanup_free_ char *p = NULL;

    r = read_one_line_file("/proc/cmdline", &p);
    if (r < 0) {
        log_info("Failed to read /proc/cmdline errno:%d", r);
        return -ENOENT;
    } else {
        if (strstr(p, "casper")) {
            log_info("os install break");
            return EXIT_SUCCESS;
        }
    }

    ret = sd_bus_open_system(&bus);
    if (ret < 0) {
        log_error("Failed to connect to system bus: %s\n", strerror(-ret));
        return EXIT_FAILURE;
    }

    r = sd_bus_call_method(
            bus,
            "org.freedesktop.systemd1",
            "/org/freedesktop/systemd1",
            "org.freedesktop.systemd1.Manager",
            "StartUnit",
            &error,
            &msg,
            "ss",
            "systemd-logind.service",
            "fail");
    if (r >= 0) {
        r = sd_bus_message_read(msg, "o", &object);
        if (r >= 0) {
             log_info("preload systemd-logind.service object:%s", object);
        }
    }

    return EXIT_SUCCESS;
}

DEFINE_MAIN_FUNCTION(run);