mirror of
https://github.com/clearlinux/micro-config-drive.git
synced 2026-10-04 15:58:38 +00:00
fix spawn commands
This commit is contained in:
@@ -74,6 +74,13 @@ fi
|
||||
AC_SUBST(RESIZE2FS)
|
||||
AC_DEFINE_UNQUOTED([RESIZEFS_PATH], ["$RESIZE2FS"], [Path to resize2fs binary])
|
||||
|
||||
AC_PATH_PROG([SHELL], [sh], [no], [$PATH:/sbin:/usr/sbin])
|
||||
if test x"$SHELL" == x"no" ; then
|
||||
AC_MSG_ERROR([Please install sh.])
|
||||
fi
|
||||
AC_SUBST(SHELL)
|
||||
AC_DEFINE_UNQUOTED([SHELL_PATH], ["$SHELL"], [Path to sh binary])
|
||||
|
||||
AC_PATH_PROG([HOSTNAMECTL], [hostnamectl], [no], [$PATH:/sbin:/usr/sbin])
|
||||
if test x"$HOSTNAMECTL" == x"no" ; then
|
||||
AC_MSG_ERROR([Please install hostnamectl.])
|
||||
|
||||
@@ -75,26 +75,31 @@ bool exec_task(const gchar* command_line) {
|
||||
GError* error = NULL;
|
||||
gint exit_status = 0;
|
||||
gboolean result;
|
||||
GString* command;
|
||||
command = g_string_new("");
|
||||
g_string_printf(command, SHELL_PATH " -c '%s'", (char*)command_line );
|
||||
|
||||
LOG(MOD "Executing: %s\n", command_line);
|
||||
result = g_spawn_command_line_sync(command_line,
|
||||
LOG(MOD "Executing: %s\n", command->str);
|
||||
result = g_spawn_command_line_sync(command->str,
|
||||
&standard_output,
|
||||
&standard_error,
|
||||
&exit_status,
|
||||
&error);
|
||||
|
||||
g_string_free(command, true);
|
||||
|
||||
if (!result || exit_status != 0) {
|
||||
LOG(MOD "Command failed\n");
|
||||
if (error) {
|
||||
LOG(MOD "Error: %s\n", (char*)error->message);
|
||||
}
|
||||
if (standard_error) {
|
||||
LOG(MOD "STD Error: %s", (char*)standard_error);
|
||||
LOG(MOD "STD Error: %s\n", (char*)standard_error);
|
||||
}
|
||||
}
|
||||
|
||||
if (standard_output) {
|
||||
LOG(MOD "STD output: %s", (char*)standard_output);
|
||||
LOG(MOD "STD output: %s\n", (char*)standard_output);
|
||||
g_free(standard_output);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user