#include "emuld.h"
+#define MAX_PKGS_BUF 1024
+
int g_epoll_fd;
struct epoll_event g_events[MAX_EVENTS];
void* dl_handles[MAX_PLUGINS];
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.");
}
}
+
static bool epoll_init(void)
{
g_epoll_fd = epoll_create(MAX_EVENTS); // create event pool