summaryrefslogtreecommitdiffstats
path: root/ui/common/ui-system.c
diff options
context:
space:
mode:
authorGeoff Levand <geoff@infradead.org>2012-03-08 20:48:21 -0800
committerGeoff Levand <geoff@infradead.org>2012-03-08 20:51:37 -0800
commit604a1ccf072f9f33326fb6dc919c1b6233d40866 (patch)
tree88297738af995f9ea8df78e134d0a2dac111d157 /ui/common/ui-system.c
parentae0ba68f475ae5b057aad6538765bc8702134b9a (diff)
downloadtalos-petitboot-604a1ccf072f9f33326fb6dc919c1b6233d40866.tar.gz
talos-petitboot-604a1ccf072f9f33326fb6dc919c1b6233d40866.zip
Add --start-daemon option to ui programs
Add the option --start-daemon to automatically start pb-discover if it is not already started. For use when running as a stand-alone app. Signed-off-by: Geoff Levand <geoff@infradead.org>
Diffstat (limited to 'ui/common/ui-system.c')
-rw-r--r--ui/common/ui-system.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/ui/common/ui-system.c b/ui/common/ui-system.c
index 0140f0e..8604848 100644
--- a/ui/common/ui-system.c
+++ b/ui/common/ui-system.c
@@ -33,6 +33,30 @@
#include "ui-system.h"
/**
+ * pb_start_daemon - start the pb-discover daemon.
+ */
+
+int pb_start_daemon(void)
+{
+ int result;
+ const char *argv[2];
+ char *name = talloc_asprintf(NULL, "%s/sbin/pb-discover",
+ pb_system_apps.prefix);
+
+ argv[0] = name;
+ argv[1] = NULL;
+
+ result = pb_run_cmd(argv, 0);
+
+ talloc_free(name);
+
+ if (result)
+ pb_log("%s: failed: (%d)\n", __func__, result);
+
+ return result;
+}
+
+/**
* kexec_load - kexec load helper.
* @l_image: The local image file for kexec to execute.
* @l_initrd: Optional local initrd file for kexec --initrd, can be NULL.
@@ -67,7 +91,7 @@ static int kexec_load(const char *l_image, const char *l_initrd,
*p++ = l_image; /* 5 */
*p++ = NULL; /* 6 */
- result = pb_run_cmd(argv);
+ result = pb_run_cmd(argv, 1);
if (result)
pb_log("%s: failed: (%d)\n", __func__, result);
@@ -98,7 +122,7 @@ static int kexec_reboot(void)
*p++ = "now"; /* 3 */
*p++ = NULL; /* 4 */
- result = pb_run_cmd(argv);
+ result = pb_run_cmd(argv, 1);
/* On error, force a kexec with the -e option */
@@ -108,7 +132,7 @@ static int kexec_reboot(void)
*p++ = "-e"; /* 2 */
*p++ = NULL; /* 3 */
- result = pb_run_cmd(argv);
+ result = pb_run_cmd(argv, 1);
}
if (result)
OpenPOWER on IntegriCloud