rpms/anacron/devel anacron.init,1.19,1.20 anacron.spec,1.53,1.54

Marcela Mašláňová mmaslano at fedoraproject.org
Fri Oct 24 13:03:20 UTC 2008


Author: mmaslano

Update of /cvs/pkgs/rpms/anacron/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv15591

Modified Files:
	anacron.init anacron.spec 
Log Message:
* Fri Oct 24 2008 Marcela Mašláňová <mmaslano at redhat.com> 2.3-65
- rewrite init script - using fedora guidelines SysVInitScript



Index: anacron.init
===================================================================
RCS file: /cvs/pkgs/rpms/anacron/devel/anacron.init,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- anacron.init	23 Sep 2008 08:23:14 -0000	1.19
+++ anacron.init	24 Oct 2008 13:02:50 -0000	1.20
@@ -1,83 +1,99 @@
 #!/bin/sh
-# Startup script for anacron
 #
-# chkconfig: 2345 95 05
-# description: Run cron jobs that were left out due to downtime
-# pidfile: /var/run/anacron.pid
+# anacron Run cron jobs that were left out due to downtime.
 #
+# chkconfig:   2345 99 05
+# description: anacron exits after it has determined it has no more work to do. \
+#        Hence, its initscript cannot do normal lock file management. \
+#        The anacron binary now creates its own /var/run/anacron.pid pid file \
+#        and /var/lock/subsys lock files, and removes them automatically at exit, \
+#        so at least there will be no more "anacron is dead but subsys locked" \
+#        messages. 
+
+### BEGIN INIT INFO
+# Provides: $anacron
+# Required-Start: $local_fs $syslog
+# Required-Stop: $local_fs $syslog
+# Default-Start:  2345
+# Default-Stop: 99
+# Short-Description: run left over cron jobs 
+# Description: anacron exits after it has determined it has no more work to do.
+#        Hence, its initscript cannot do normal lock file management.
+#        The anacron binary now creates its own /var/run/anacron.pid pid file
+#        and /var/lock/subsys lock files, and removes them automatically at exit,
+#        so at least there will be no more "anacron is dead but subsys locked"
+#        messages.    
+### END INIT INFO
+
 # Source function library.
 . /etc/rc.d/init.d/functions
 
-[ -f /usr/sbin/anacron ] || exit 0
+exec=/usr/sbin/anacron
+prog=anacron
+#config=doesn't have config file, some values are stored in /etc/anacrontab
 
-prog="anacron"
-PIDFILE=/var/run/${prog}.pid
-LOCKFILE=/var/lock/subsys/$prog
-#
-#  NOTE: anacron exits after it has determined it has no more work to do.
-#        Hence, its initscript cannot do normal lock file management.
-#        The anacron binary now creates its own /var/run/anacron.pid pid file
-#        and /var/lock/subsys lock files, and removes them automatically at exit,
-#        so at least there will be no more "anacron is dead but subsys locked" 
-#        messages.
-#
+lockfile=/var/lock/subsys/$prog
 
 start() {
-    echo -n $"Starting $prog: " 
+    [ -x $exec ] || exit 5
+    echo -n $"Starting $prog: "
     daemon +19 anacron -s
-    RETVAL=$?
-    if [ $RETVAL -ne 0 ]; then
-	failure;
-    fi;
+    retval=$?
     echo
-    return $RETVAL
+    [ $retval -eq 0 ]
+	## && touch $lockfile it creates lock in code
+    return $retval
 }
 
 stop() {
     echo -n $"Stopping $prog: "
-    if [ -f $PIDFILE ]; then
-	killproc anacron
-	RETVAL=$?
-	if [ $RETVAL -ne 0 ]; then 
-	    failure;
-	fi;
-    else
-	RETVAL=1
-	failure;
-    fi
+    killproc $prog
+    retval=$?
     echo
-    return $RETVAL
+    [ $retval -eq 0 ]
+    #usually anacron clean his lock after he stops himself.
+    #Just in case something goes wrong kill him.
+    [ -f $lockfile ] && rm -f $lockfile
+    return $retval
 }
 
-case "$1" in
-	start)
-	    start
-	    ;;
-	
-	stop)
-	    stop
-	    ;;
-	
-	status)
-	    status anacron
-	    ;;
-
-	restart)
-	    stop
-	    start
-	    ;;
-
-	condrestart)
-	    if [ -f $LOCKFILE ]; then
-		stop
-		start
-	    fi
-	    ;;
-	
-	*)
-	    echo $"Usage: $0 {start|stop|restart|condrestart|status}"
-	    exit 1
+restart() {
+    stop
+    start
+}
+
+rh_status() {
+    # run checks to determine if the service is running or use generic status
+    status $prog
+}
 
+rh_status_q() {
+    rh_status >/dev/null 2>&1
+}
+
+
+case "$1" in
+    start)
+        rh_status_q && exit 0
+        $1
+        ;;
+    stop)
+        rh_status_q || exit 0
+        $1
+        ;;
+    restart)
+        $1
+        ;;
+    status)
+        rh_status
+        ;;
+    condrestart)
+        rh_status_q || exit 0
+        restart
+        ;;
+    *)
+        echo $"Usage: $0 {start|stop|status|restart|condrestart}"
+        exit 2
 esac
+exit $?
 
-exit $RETVAL


Index: anacron.spec
===================================================================
RCS file: /cvs/pkgs/rpms/anacron/devel/anacron.spec,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- anacron.spec	23 Sep 2008 08:27:10 -0000	1.53
+++ anacron.spec	24 Oct 2008 13:02:50 -0000	1.54
@@ -1,7 +1,7 @@
 Summary: A cron-like program that can run jobs lost during downtime
 Name: anacron
 Version: 2.3
-Release: 64%{?dist}
+Release: 65%{?dist}
 License: GPLv2+
 Group: System Environment/Base
 URL: http://packages.debian.org/stable/source/anacron
@@ -111,6 +111,9 @@
 %dir /etc/cron.monthly/0anacron
 
 %changelog
+* Fri Oct 24 2008 Marcela Mašláňová <mmaslano at redhat.com> 2.3-65
+- rewrite init script - using fedora guidelines SysVInitScript
+
 * Wed Jul 30 2008 Marcela Maslanova <mmaslano at redhat.com> 2.3-64
 - fix fuzz
 - fix previous patch, thanks to mbroz




More information about the scm-commits mailing list