Author: pebender
Date: Sat Jan  3 18:57:09 2009
New Revision: 4165

Modified:
     
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/usr/bin/mm_service

Log:
- Improved error messages generated by mm_service.



Modified:  
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/usr/bin/mm_service
==============================================================================
---  
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/usr/bin/mm_service  
 
(original)
+++  
trunk/gar-minimyth/script/meta/minimyth/files/source/rootfs/usr/bin/mm_service  
 
Sat Jan  3 18:57:09 2009
@@ -5,21 +5,21 @@
  use feature "switch";

  my $service = shift;
-my $command = shift;
+my $action  = shift;

  if ((! defined ($service)) || ($service eq ''))
  {
      die qq(error: you must specify a service);
  }

-if ((! defined ($command)) || ($command eq ''))
+if ((! defined ($action)) || ($action eq ''))
  {
-    die qq(error: you must specify an command );
+    die qq(error: you must specify an action);
  }

  if (! -e "/etc/rc.d/init/$service.pm")
  {
-    die qq(error: unknown service: $service);
+    die qq(error: unknown service '$service');
  }

  require MiniMyth;
@@ -30,13 +30,39 @@

  my $package = "init::$service";

-eval "require $package";
+# Require package.
+if (! $minimyth->package_require($package))
+{
+    die;
+}
+
+# Make sure that action exists.
+if (! $minimyth->package_member_require($package, $action))
+{
+    die;
+}

-given ($command)
+# Perform action.
+given ($action)
  {
-    when (/^start$/) { $package->start($minimyth); }
-    when (/^stop$/ ) { $package->stop($minimyth);  }
-    default          { die qq(error: unknown command: $command); }
+    when (/^start$/)
+    {
+        if (! $package->start($minimyth))
+        {
+            die;
+        }
+    }
+    when (/^stop$/)
+    {
+        if (! $package->stop($minimyth))
+        {
+            die;
+        }
+    }
+    default
+    {
+        die qq(error: unkown action '$action' for service '$service');
+    }
  }

  1;

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"minimyth-commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/minimyth-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to