[Initng-svn] r2717 - initng/plugins/ngc2

svn at initng.thinktux.net svn at initng.thinktux.net
Wed Jan 4 18:20:32 CET 2006


Author: jimmy
Date: Wed Jan  4 18:20:31 2006
New Revision: 2717

Modified:
   initng/plugins/ngc2/initng_ngc2.c
   initng/plugins/ngc2/ngc2.c
Log:
More work, to make ngc work nice.



Modified: initng/plugins/ngc2/initng_ngc2.c
==============================================================================
--- initng/plugins/ngc2/initng_ngc2.c	(original)
+++ initng/plugins/ngc2/initng_ngc2.c	Wed Jan  4 18:20:31 2006
@@ -197,7 +197,7 @@
 
     if (!tmp_cmd || tmp_cmd->com_type == 0)
     {
-        F_("command type '%c', long \"%s\", option : \"%s\"\n", header.c,
+        D_("command type '%c', long \"%s\", option : \"%s\"\n", header.c,
            header.l, header.o);
         result.c = header.c;
         result.t = 0;
@@ -212,7 +212,7 @@
     /* check if command requires option, and option is not set */
     if (tmp_cmd->opt_type == REQUIRES_OPT && header_opt_len < 1)
     {
-        F_("Command %c - %s, requires an option!\n", header.c, header.l);
+        D_("Command %c - %s, requires an option!\n", header.c, header.l);
         result.c = header.c;
         result.t = 0;
         result.s = S_REQUIRES_OPT;
@@ -224,7 +224,7 @@
     /* check if command is not using and option, and option is set */
     if (tmp_cmd->opt_type == NO_OPT && header_opt_len > 0)
     {
-        F_("Command %c - %s, don't want an option!\n", header.c, header.l);
+        D_("Command %c - %s, don't want an option!\n", header.c, header.l);
         result.c = header.c;
         result.t = 0;
         result.s = S_NOT_REQUIRES_OPT;
@@ -339,7 +339,7 @@
                 F_("failed to send all data\n");
             /* TODO: really continue?? */
 
-            F_("Invalid command type '%c', line '%s', option : \"%s\"\n",
+            D_("Invalid command type '%c', line '%s', option : \"%s\"\n",
                header.c, header.l, header.o);
             return;
     }

Modified: initng/plugins/ngc2/ngc2.c
==============================================================================
--- initng/plugins/ngc2/ngc2.c	(original)
+++ initng/plugins/ngc2/ngc2.c	Wed Jan  4 18:20:31 2006
@@ -225,7 +225,7 @@
 
     if (header_printed == FALSE)
     {
-        print_out("Got an response from initng, version: %s\n", result->version);
+        /*print_out("Got an response from initng, version: %s\n", result->version);*/
 
         if (strcmp(result->version, VERSION) != 0)
         {
@@ -265,10 +265,12 @@
             return (NULL);
 
         case S_COMMAND_NOT_FOUND:
-            print_out("\nCommand -%c is not found.\n\n", result->c);
+	{
+            print_out("\nCommand not found.\n\n");
             free(result);
+	    print_usage();
             return (NULL);
-
+	}
         case S_TRUE:
             return (result);
     }
@@ -285,7 +287,7 @@
             TEMP_FAILURE_RETRY(read(sock, &tmp_read, MAX_RESCIVE_SIZE))) > 0)
     {
         tmp_read[len] = '\0';
-        print_out("%s", tmp_read);
+        print_out("%s\n", tmp_read);
     }
 
     /* TODO: error handling??? */
@@ -381,7 +383,7 @@
 	{
 	    print_out("This meens that the service cound not start,\n");
 	    print_out("Please check initng console, syslogs or ngc -L\n");
-	    print_out("For more info.\n");
+	    print_out("For more info.\n\n");
 	    
 	    return(FALSE);    
 	}
@@ -418,12 +420,12 @@
     int counter = 0;
     int once_found = 0;
 
-    print_out("Stopping service: \n");
+    print_out("\nStopping service: \n");
 
     if (TEMP_FAILURE_RETRY(read(sock, &row, sizeof(active_row))) !=
         sizeof(row))
     {
-        print_out("failed to read response\n");
+        print_out("\tfailed to read response\n");
         close_socket();
         return FALSE;
     }
@@ -460,7 +462,7 @@
         if (TEMP_FAILURE_RETRY(read(sock, &row, sizeof(active_row))) !=
             sizeof(row))
         {
-            print_out("failed to read response\n");
+            print_out("\n\tfailed to read response\n");
             close_socket();
             return FALSE;
         }
@@ -468,9 +470,14 @@
         /* not found can be goood */
         if (once_found == 1 && strcmp(row.s, "NOT_FOUND") == 0)
             break;
-        else
-            once_found = 1;
-
+        
+        /* If its NOT_FOUND in future, then its a goot thing */
+	once_found = 1;
+
+	/* break if failed */
+	if(row.i == IS_FAILED)
+	    break;
+	
         close_socket();
 
         counter++;
@@ -480,47 +487,31 @@
     /* not found can be goood */
     if (once_found == 1 && strcmp(row.s, "NOT_FOUND") == 0)
     {
-        print_out("\tService stopped sucessfully!\n");
+        print_out("\tService %s stopped sucessfully!\n", row.n);
         return (TRUE);
     }
-
-    if (row.i == IS_FAILED)
+    
+    /* or bad */
+    if (strcmp(row.s, "NOT_FOUND") == 0)
     {
-        print_out
-            ("Service %s has status FAILED\n\n Clearing status in 1 second.",
-             row.n);
-        sleep(1);
-
-	TMP_QUIET; /* Dont show anymore atempts */
-	
-        /* zap the service */
-        if (!send_and_handle('z', NULL, row.n))
-            return (FALSE);
-	    
-	TMP_UNQUIET;
-
-        print_out
-            ("Done, WARNING, clearing service meens that its removed from initng,\n");
-        print_out
-            ("This dont actually meens that the service is really stopped.\n");
-        return (TRUE);
+	print_out("\n\n\tService %s was never started.\n", row.n);
+	return (TRUE);
     }
 
-    /* Down is to */
+
+    /* Down is really good to */
     if (row.i == IS_DOWN)
     {
-        print_out("\tNo service %s exists anymore!\n", row.n);
+        print_out("\tService %s is down!\n", row.n);
         return (TRUE);
     }
 
-    if (counter == 10)
-    {
-        print_out("Timeout on stop service, might be stopped soon anyway.\n");
-        return (FALSE);
-    }
 
-    print_out("\tFailed to stop service, %s (%s)\n", row.n, row.s);
-    return (FALSE);
+    print_out("Service %s has status failed to stop.\n", row.n);
+    print_out("Instead you shud kill this service manually,\n");
+    print_out("And after that do ngc -z %s, to release\n", row.s);
+    print_out("its status from initng.\n\n");
+    return(FALSE);
 }
 
 
@@ -584,7 +575,7 @@
             exit(1);
 
     }
-    print_out("Error, should not got here!\n");
+    print_out("Error, should not got here!\n report to bugzilla.\n");
     exit(22);
 }
 
@@ -594,12 +585,12 @@
 
     if (!(result = send_command(c, l, o)))
     {
-        print_out("Command -%c --%s, %s - Unable to send command!\n", c, l, o);
+        /*print_out("Command -%c --%s, %s - Unable to send command!\n", c, l, o);*/
         return (FALSE);
     }
     if (!handle_result(result))
     {
-        print_out("Command -%c --%s, %s - Bad result!\n", c, l, o);
+        /*print_out("Command -%c --%s, %s - Bad result!\n", c, l, o);*/
         return (FALSE);
     }
 
@@ -688,6 +679,7 @@
 
 
     }
+    printf("\n\n");
     exit(0);
 }
 


More information about the Initng-svn mailing list