X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ui%2Ftwin%2Fpbt-client.c;h=1170b34555664c449fdbb12f0c3cdaf19541cc9b;hb=59e81c46a962da51e51474e9b36258ff0e04ae42;hp=a2c3e931204bc639af070ea2d26b618b547bbd48;hpb=bd0c684c9941c24ee4191f4550ec966d5b1fa8ab;p=petitboot diff --git a/ui/twin/pbt-client.c b/ui/twin/pbt-client.c index a2c3e93..1170b34 100644 --- a/ui/twin/pbt-client.c +++ b/ui/twin/pbt-client.c @@ -262,9 +262,10 @@ static void pbt_client_destructor(struct pbt_client *client) memset(client, 0, sizeof(*client)); } -struct pbt_client *pbt_client_init(enum pbt_twin_backend backend, unsigned int width, - unsigned int height, - int (*kexec_cb)(struct pbt_client *, struct pb_opt_data *)) +struct pbt_client *pbt_client_init(enum pbt_twin_backend backend, + unsigned int width, unsigned int height, + int (*kexec_cb)(struct pbt_client *, struct pb_opt_data *), + int start_deamon, int dry_run) { struct pbt_client *pbt_client; unsigned int i; @@ -281,6 +282,7 @@ struct pbt_client *pbt_client_init(enum pbt_twin_backend backend, unsigned int w pbt_client->sig = "pbt_client"; pbt_client->kexec_cb = kexec_cb; + pbt_client->dry_run = dry_run; pbt_client->frame.scr = pbt_scr_init(pbt_client, backend, width, height, NULL, NULL); @@ -289,17 +291,34 @@ struct pbt_client *pbt_client_init(enum pbt_twin_backend backend, unsigned int w /* Loop here for scripts that just started the server. */ if (1) { +start_deamon: for (i = 10; i; i--) { pbt_client->discover_client = discover_client_init(&pbt_client_ops, pbt_client); - if (pbt_client->discover_client) break; - pb_log("%s: waiting for server %d\n", __func__, i); sleep(1); } + if (!pbt_client->discover_client && start_deamon) { + int result; + + start_deamon = 0; + + result = pb_start_daemon(); + + if (!result) + goto start_deamon; + + pb_log("%s: discover_client_init failed.\n", __func__); + fprintf(stderr, "%s: error: discover_client_init failed.\n", + __func__); + fprintf(stderr, "could not start pb-discover, the petitboot " + "daemon.\n"); + goto fail_client_init; + } + if (!pbt_client->discover_client) { pb_log("%s: discover_client_init failed.\n", __func__); fprintf(stderr, "%s: error: discover_client_init failed.\n",