Exemplo n.º 1
0
static bool
on_timeout_cmd(void *data)
{
    const char *cmd;
    const char *param;

    cmd = cmds[cur_cmd++];
    param = cmds[cur_cmd++];

    printf("Firing new command: %s %s\n", cmd, param);

    if (!strcmp(cmd, "monitor"))
        sol_platform_add_service_monitor(on_service_changed, param, NULL);
    else if (!strcmp(cmd, "stop-monitor"))
        sol_platform_del_service_monitor(on_service_changed, param, NULL);
    else if (!strcmp(cmd, "start"))
        sol_platform_start_service(param);
    else if (!strcmp(cmd, "stop"))
        sol_platform_stop_service(param);
    else if (!strcmp(cmd, "restart"))
        sol_platform_restart_service(param);
    else if (!strcmp(cmd, "target"))
        sol_platform_set_target(param);

    if (n_cmds - cur_cmd >= 2)
        return true;

    timeout_handle = NULL;
    return false;
}
Exemplo n.º 2
0
static int
machine_id_start(const struct sol_platform_linux_micro_module *mod,
    const char *service)
{
    int ret = 0;
    static const char *FSTAB = "fstab";
    enum sol_platform_service_state state = SOL_PLATFORM_SERVICE_STATE_ACTIVE;

    name = service;

    if (done)
        return 0;

    /* If fstab is present and functional, wait for it to go up for
     * this to run. If it's not, try to do machine-id's business
     * nonetheless */
    ret = sol_platform_add_service_monitor
            (on_fstab_service_state_changed, FSTAB, mod);
    if (ret < 0)
        return run_do();
    ret = sol_platform_start_service(FSTAB);
    if (ret < 0) {
        sol_platform_del_service_monitor
            (on_fstab_service_state_changed, FSTAB, NULL);
        return run_do();
    }

    state = sol_platform_get_service_state(FSTAB);
    if (state == SOL_PLATFORM_SERVICE_STATE_ACTIVE)
        return run_do();

    return 0; /* wait for dep to activate */
}