From: Karthik Date: Tue, 28 Sep 2021 05:58:06 +0000 (+0530) Subject: Add option to run post boot commands on emulator X-Git-Tag: submit/tizen/20210928.063523^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e53e336bc23f5b72d5ef1ee7c847d8d9b9879452;p=platform%2Fadaptation%2Femulator%2Femulator-daemon.git Add option to run post boot commands on emulator Change-Id: I7aefde421fabe13aef5e8795621cf5892f62e64f Signed-off-by: Karthik --- diff --git a/packaging/emuld.spec b/packaging/emuld.spec index 584fdcb..fa6f767 100644 --- a/packaging/emuld.spec +++ b/packaging/emuld.spec @@ -4,7 +4,7 @@ %define emuld_major_version 0 %define emuld_minor_version 11 -%define emuld_release_number 2 +%define emuld_release_number 3 Name: emuld Version: %{emuld_major_version}.%{emuld_minor_version}.%{emuld_release_number} diff --git a/src/emuld.cpp b/src/emuld.cpp index 638bbdc..1e1df8b 100644 --- a/src/emuld.cpp +++ b/src/emuld.cpp @@ -38,6 +38,8 @@ #include "emuld.h" +#define MAX_PKGS_BUF 1024 + int g_epoll_fd; struct epoll_event g_events[MAX_EVENTS]; void* dl_handles[MAX_PLUGINS]; @@ -141,11 +143,55 @@ static void send_to_kernel(void) LOGINFO("[DBUS] sent booting done to kernel"); } + +static void run_postboot_script(char* fileName) { + int ret = -1; + char file_name[MAX_PKGS_BUF]; + char launch_buf[MAX_PKGS_BUF + 2]; + snprintf(file_name, sizeof(file_name), "/home/owner/share/tmp/.emul-scripts/%s", fileName); + LOGINFO("[run_postboot_script] called %s\n",file_name); + ret = access(file_name, F_OK); + if (ret != 0) + { + LOGWARN("[RunScript] file does not exist: %s", file_name); + return; + } + + ret = chmod(file_name, 0755); + if (ret != 0) + { + LOGWARN("[RunScript] file permission setting is failed : [%d] %s", ret, file_name); + return; + } + + snprintf(launch_buf, sizeof(launch_buf), ". %s", file_name); + + systemcall(launch_buf); +} + + +static void run_postboot_scripts() +{ + DIR *d; + struct dirent *dir; + d = opendir("/home/owner/share/tmp/.emul-scripts/"); + if (d) + { + while ((dir = readdir(d)) != NULL) + { + run_postboot_script(dir->d_name); + } + closedir(d); + } +} + static void boot_done(void *data, DBusMessage *msg) { if (dbus_message_is_signal(msg, DBUS_IFACE_BOOT_DONE, BOOT_DONE_SIGNAL) != 0) { + LOGINFO("[DBUS] Running post boot scripts."); + run_postboot_scripts(); LOGINFO("[DBUS] sending booting done to ecs."); send_to_ecs(IJTYPE_BOOT, 0, 0, NULL); LOGINFO("[DBUS] sending booting done to kernel for log."); @@ -153,6 +199,7 @@ static void boot_done(void *data, DBusMessage *msg) } } + static bool epoll_init(void) { g_epoll_fd = epoll_create(MAX_EVENTS); // create event pool