Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=frugalware.git;a=commitdiff;h=80c46069c1465994bd7b1b12913297a37b1dc323

commit 80c46069c1465994bd7b1b12913297a37b1dc323
Author: Miklos Vajna <[EMAIL PROTECTED]>
Date:   Mon Mar 10 19:49:11 2008 +0100

service: rework for newer chkconfig
- from crazy

diff --git a/var/service b/var/service
index 77db200..c15a213 100644
--- a/var/service
+++ b/var/service
@@ -7,46 +7,65 @@
TEXTDOMAIN=service
TEXTDOMAINDIR=/var/lib/frugalware/messages

+
+usage()
+{
+       echo $"Usage: $0 service action"
+        echo
+        echo $"Actions:"
+        echo
+        echo $"start        Start the service."
+        echo
+        echo $"stop         Stop the service."
+        echo
+        echo $"status       Status of the service (if it supports querying 
so)."
+        echo
+        echo $"restart      Stop and start again the service."
+        echo
+        echo $"add          Adds a new service for management by chkconfig."
+        echo
+        echo $"del          Removes a service from chkconfig management."
+        echo
+        echo $"list         List whether the service is stopped or started in 
each runlevel."
+        exit 0
+}
+
+if [ "$1" = "" ]; then
+       usage
+fi
+
if [ "$1" = "--version" ]; then
-       echo "service (pacman-tools) 0.2"
+       echo "service (pacman-tools) 0.2.1"
echo
-       echo "Copyright (c) 2003-2007 by Miklos Vajna <[EMAIL PROTECTED]>"
+       echo "Copyright (c) 2003-2008 by Miklos Vajna <[EMAIL PROTECTED]>"
echo "This is free software; see the source for copying conditions.  There is 
NO"
echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 
PURPOSE."
exit 0
elif [ "$1" = "--help" ]; then
-       echo $"Usage: $0 service action"
-       echo
-       echo $"Actions:"
-       echo
-       echo $"start        Start the service."
-       echo
-       echo $"stop         Stop the service."
-       echo
-       echo $"status       Status of the service (if it supports querying so)."
-       echo
-       echo $"restart      Stop and start again the service."
-       echo
-       echo $"add          Adds a new service for management by chkconfig."
-       echo
-       echo $"del          Removes a service from chkconfig management."
-       echo
-       echo $"list         List whether the service is stopped or started in 
each runlevel."
-       exit 0
+       usage
fi
-if [ "$1" = "list" ]; then
-       chkconfig --list --level $2 | grep $2:$3
+
+if [ "$1" = "level" ]; then
+       if [ "$2" != "" ]; then
+               if [ "$3" != "" ]; then
+                       ## well just support english for now 'on' is not
+                       ## the same as Ein etc
+                       LC_ALL=C; chkconfig --list --level $2 | grep $2:$3
+               else
+                       echo $"Usage: $0 level <level> <on/off>"
+                       exit 1
+               fi
+       else
+               echo $"Usage: $0 level <level> <on/off>"
+               exit 1
+       fi
else
service=rc.$1
name=/etc/rc.d/$service
if ! [ -z "$1" ]; then
if ! [ -e $name ]; then
-                       # this will print a nice error message
-                       chkconfig --list $service
-                       exit 1
-               fi
-               if ! chkconfig --list $service >/dev/null 2>&1; then
-                       chkconfig --list $service
+                       ## maybe typo ?
+                       usage
exit 1
fi
fi
@@ -55,7 +74,17 @@ else
elif [ "$2" = "del" ]; then
chkconfig --del $service
elif [ "$2" = "list" ]; then
-               chkconfig --list $service
+               chkconfig --list $service >/dev/null 2>&1
+               RET=$?
+               if [ "$RET" = "0" ]; then
+                       ## we are fine , the file $name
+                       ## exists and is added  list it
+                       chkconfig --list $service
+               else
+                       ## error , files exists but isn't added
+                       echo $"Use $0 $1 add first."
+                       exit 1
+               fi
else
$name $2
fi
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to