[Initng-svn] r3988 - in initng/trunk: plugins/bash_launcher plugins/daemon plugins/daemon_clean plugins/service plugins/simple_launcher plugins/stcmd tools

svn at initng.thinktux.net svn at initng.thinktux.net
Tue May 2 01:51:56 CEST 2006


Author: jimmy
Date: Tue May  2 01:51:54 2006
New Revision: 3988

Modified:
   initng/trunk/plugins/bash_launcher/initng_bash_launcher.c
   initng/trunk/plugins/daemon/initng_daemon.c
   initng/trunk/plugins/daemon_clean/initng_daemon_clean.c
   initng/trunk/plugins/service/initng_service.c
   initng/trunk/plugins/simple_launcher/initng_simple_launcher.c
   initng/trunk/plugins/stcmd/initng_stcmd.c
   initng/trunk/src/initng_execute.c
   initng/trunk/src/initng_execute.h
   initng/trunk/src/initng_plugin.h
   initng/trunk/tools/itool.c

Log:
Now it really works in pratice.


Modified: initng/trunk/plugins/bash_launcher/initng_bash_launcher.c
==============================================================================
--- initng/trunk/plugins/bash_launcher/initng_bash_launcher.c	(original)
+++ initng/trunk/plugins/bash_launcher/initng_bash_launcher.c	Tue May  2 01:51:54 2006
@@ -69,20 +69,22 @@
 					 const char *script, const char *args);
 
 
-static int initng_bash(active_db_h * service, process_h * process)
+static int initng_bash(active_db_h * service, process_h * process, const char *exec_name)
 {
 	const char *e = NULL;
 	const char *args = NULL;
 
 	assert(service);
 	assert(service->name);
+	assert(exec_name);
+	assert(process);
 
 	/* WE ARE EXECUTING A START MULTILINE_STRING */
-	if (!(e = get_string_var(&SCRIPT, process->pt->name, service)))
+	if (!(e = get_string_var(&SCRIPT, exec_name, service)))
 		return (FALSE);
 
 	/* get the arguments if any */
-	args = get_string_var(&SCRIPT_OPT, process->pt->name, service);
+	args = get_string_var(&SCRIPT_OPT, exec_name, service);
 
 	/*D_("initng_bash(%s, %s, %s);\n", service->name, e, args); */
 	return (bash_exec(process, service, e, args));

Modified: initng/trunk/plugins/daemon/initng_daemon.c
==============================================================================
--- initng/trunk/plugins/daemon/initng_daemon.c	(original)
+++ initng/trunk/plugins/daemon/initng_daemon.c	Tue May  2 01:51:54 2006
@@ -644,7 +644,7 @@
 
 
 	/* F I N A L L Y   S T A R T */
-	switch (initng_execute_launch(daemon, &T_DAEMON))
+	switch (initng_execute_launch(daemon, &T_DAEMON, NULL))
 	{
 		case FALSE:
 			F_("Did not find a service->\"daemon\" entry to run!\n",
@@ -717,7 +717,7 @@
 
 
 	/* launch stop service */
-	switch (initng_execute_launch(service, &T_KILL))
+	switch (initng_execute_launch(service, &T_KILL, NULL))
 	{
 		case FAIL:
 			F_("  --  (%s): fail launch stop!\n", service->name);

Modified: initng/trunk/plugins/daemon_clean/initng_daemon_clean.c
==============================================================================
--- initng/trunk/plugins/daemon_clean/initng_daemon_clean.c	(original)
+++ initng/trunk/plugins/daemon_clean/initng_daemon_clean.c	Tue May  2 01:51:54 2006
@@ -49,7 +49,7 @@
 	/* start the T_DAEMON_CLEAN */
 	W_("%s %s has been killed!, executing DAEMON_CLEAN!\n", p->pt->name,
 	   s->name);
-	initng_execute_launch(s, &T_DAEMON_CLEAN);
+	initng_execute_launch(s, &T_DAEMON_CLEAN, NULL);
 
 	/*
 	 * if we return TRUE, other kill handlers wont get this signal, 

Modified: initng/trunk/plugins/service/initng_service.c
==============================================================================
--- initng/trunk/plugins/service/initng_service.c	(original)
+++ initng/trunk/plugins/service/initng_service.c	Tue May  2 01:51:54 2006
@@ -456,7 +456,7 @@
 		return;
 
 	/* F I N A L L Y   S T A R T */
-	switch (initng_execute_launch(service, &T_START))
+	switch (initng_execute_launch(service, &T_START, NULL))
 	{
 		case FALSE:
 			F_("Did not find a start entry to run!\n", service->name);
@@ -479,7 +479,7 @@
 		return;
 
 	/* launch stop service */
-	switch (initng_execute_launch(service, &T_STOP))
+	switch (initng_execute_launch(service, &T_STOP, NULL))
 	{
 		case FAIL:
 			F_("  --  (%s): fail launch stop!\n", service->name);

Modified: initng/trunk/plugins/simple_launcher/initng_simple_launcher.c
==============================================================================
--- initng/trunk/plugins/simple_launcher/initng_simple_launcher.c	(original)
+++ initng/trunk/plugins/simple_launcher/initng_simple_launcher.c	Tue May  2 01:51:54 2006
@@ -370,19 +370,20 @@
 	return (result);
 }
 
-static int initng_s_launch(active_db_h * service, process_h * process)
+static int initng_s_launch(active_db_h * service, process_h * process, const char *exec_name)
 {
 
 	assert(service);
 	assert(service->name);
 	assert(process);
+	assert(exec_name);
 
 	D_("service: %s, process: %s\n", service->name, process->pt->name);
 
-	if (is_var(&EXECS, process->pt->name, service))
+	if (is_var(&EXECS, exec_name, service))
 		return (simple_exec(service, process));
 
-	if (is_var(&EXEC, process->pt->name, service))
+	if (is_var(&EXEC, exec_name, service))
 		return (simple_run(service, process));
 
 	return (FALSE);

Modified: initng/trunk/plugins/stcmd/initng_stcmd.c
==============================================================================
--- initng/trunk/plugins/stcmd/initng_stcmd.c	(original)
+++ initng/trunk/plugins/stcmd/initng_stcmd.c	Tue May  2 01:51:54 2006
@@ -550,12 +550,12 @@
 }
 
 
+ptype_h EXTERN_RUN = { "extern_arg", NULL };
 static int cmd_run(char *arg)
 {
 	char * runtype = NULL;
 	char * serv_name = NULL;
 	active_db_h * service = NULL;
-	ptype_h * ptype = NULL;
 	
 	/* search for a ':' char in arg */
 	runtype = strchr(arg, ':');
@@ -577,16 +577,7 @@
 	
 	/* copy serv_name so we can put a '\0' to mark end */
 	serv_name=i_strndup(arg, runtype-arg- 1);
-	
-		/* get the process type by name */
-		ptype = initng_process_db_ptype_find(runtype);
-		if(!ptype)
-		{
-			F_("Process type \"%s\" was not found in service \"%s\"\n", runtype, serv_name);
-			free(serv_name);
-			return(FALSE);
-		}
-		
+			
 		service=initng_active_db_find_by_name(serv_name);
 		if(!service)
 		{
@@ -600,7 +591,7 @@
 	
 		printf("Found service %s\n", service->name);
 		
-		if(initng_execute_launch(service, ptype)!=TRUE)
+		if(initng_execute_launch(service, &EXTERN_RUN, runtype)!=TRUE)
 			return(FALSE);
 	
 	/* return happily */

Modified: initng/trunk/src/initng_execute.c
==============================================================================
--- initng/trunk/src/initng_execute.c	(original)
+++ initng/trunk/src/initng_execute.c	Tue May  2 01:51:54 2006
@@ -43,7 +43,7 @@
 #include "initng_static_data_id.h"
 #include "initng_plugin.h"
 
-int initng_execute_launch(active_db_h * service, ptype_h * type)
+int initng_execute_launch(active_db_h * service, ptype_h * type, const char *exec_name)
 {
 	s_call *current, *q = NULL;
 	process_h *process = NULL;
@@ -75,11 +75,15 @@
 	/* add the process to our service */
 	list_add(&process->list, &service->processes.list);
 
+	/* make sure we have a exec_name */
+	if(!exec_name)
+		exec_name = type->name;
+
 	/* walk the db with hooks */
 	while_list_safe(current, &g.LAUNCH, q)
 	{
 		/* call the start */
-		ret = (*current->c.launch) (service, process);
+		ret = (*current->c.launch) (service, process, exec_name);
 
 		/* if launch succeeded */
 		if (ret >= TRUE)

Modified: initng/trunk/src/initng_execute.h
==============================================================================
--- initng/trunk/src/initng_execute.h	(original)
+++ initng/trunk/src/initng_execute.h	Tue May  2 01:51:54 2006
@@ -23,6 +23,6 @@
 #include "initng_active_db.h"
 #include "initng_process_db.h"
 
-int initng_execute_launch(active_db_h * service, ptype_h * type);
+int initng_execute_launch(active_db_h * service, ptype_h * type, const char * exec_name);
 
 #endif

Modified: initng/trunk/src/initng_plugin.h
==============================================================================
--- initng/trunk/src/initng_plugin.h	(original)
+++ initng/trunk/src/initng_plugin.h	Tue May  2 01:51:54 2006
@@ -50,7 +50,7 @@
 	void (*swatcher) (h_sys_state state);
 	int (*pipewatcher) (active_db_h * service, process_h * process,
 						char *buffer_pos);
-	int (*launch) (active_db_h * service, process_h * process);
+	int (*launch) (active_db_h * service, process_h * process, const char *exec_name);
 	int (*af_launcher) (active_db_h * service, process_h * process);
 	int (*handle_killed) (active_db_h * service, process_h * process);
 	void (*main) (void);

Modified: initng/trunk/tools/itool.c
==============================================================================
--- initng/trunk/tools/itool.c	(original)
+++ initng/trunk/tools/itool.c	Tue May  2 01:51:54 2006
@@ -144,13 +144,7 @@
 	{
 
 		/* create an active struct */
-		ptype_h *ptype = initng_process_db_ptype_find(argv[3]);
-
-		if (!ptype)
-		{
-			puts("ptype not found\n");
-			goto end;
-		}
+		ptype_h ptype = { "test-run", NULL };
 
 		/* Create an active service struct */
 		active_db_h *active = initng_active_db_new(fix_path(argv[1]));
@@ -158,11 +152,11 @@
 		/* This will parse file */
 		initng_common_get_service(active);
 
-		printf("Executing service %s type %s\n", active->name, ptype->name);
+		printf("Executing service %s type %s\n", active->name, argv[3]);
 
 
 		/* Now launch! (will fork) */
-		initng_execute_launch(active, ptype);
+		initng_execute_launch(active, &ptype, argv[3]);
 
 		wait(NULL);
 		goto end;


More information about the Initng-svn mailing list