From b51bd770260c00099320993a574df81b4bf9e8ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcela=20Ma=C5=A1l=C3=A1=C5=88ov=C3=A1?= Date: Fri, 24 Oct 2008 13:14:05 +0000 Subject: [PATCH] - update init script according to SysVInitScript --- at.spec | 5 +- atd.init | 158 ++++++++++++++++++++++++++++++------------------------- 2 files changed, 91 insertions(+), 72 deletions(-) diff --git a/at.spec b/at.spec index e5b414a..587b5a6 100644 --- a/at.spec +++ b/at.spec @@ -6,7 +6,7 @@ Summary: Job spooling tools Name: at Version: 3.1.10 -Release: 25%{?dist} +Release: 26%{?dist} License: GPLv2+ Group: System Environment/Daemons URL: http://ftp.debian.org/debian/pool/main/a/at @@ -187,6 +187,9 @@ fi %attr(4755,root,root) %{_bindir}/at %changelog +* Fri Oct 24 2008 Marcela Mašláňová - 3.1.10-26 +- update init script according to SysVInitScript + * Tue Sep 16 2008 Marcela Maslanova - 3.1.10-25 - thanks dwalsh for selinux patch, which fix #460873 diff --git a/atd.init b/atd.init index 39ffcdf..2f3fd20 100755 --- a/atd.init +++ b/atd.init @@ -1,95 +1,111 @@ -#!/bin/bash +#!/bin/sh # -# /etc/rc.d/init.d/atd +# atd Starts/stop the "at" daemon # -# Starts the "at" daemon -# -# chkconfig: 345 95 5 +# chkconfig: 345 95 5 # description: Runs commands scheduled by the "at" command at the time \ # specified when "at" was run, and runs batch commands when the load \ # average is low enough. -# processname: atd + +### BEGIN INIT INFO +# Provides: atd at batch +# Required-Start: $local_fs +# Required-Stop: $local_fs +# Default-Start: 345 +# Default-Stop: 95 +# Short-Description: Starts/stop the "at" daemon +# Description: Runs commands scheduled by the "at" command at the time +# specified when "at" was run, and runs batch commands when the load +# average is low enough. +### END INIT INFO # Source function library. -. /etc/init.d/functions +. /etc/rc.d/init.d/functions -# pull in sysconfig settings -[ -f /etc/sysconfig/atd ] && . /etc/sysconfig/atd - -RETVAL=0 +exec=/usr/sbin/atd prog="atd" -ATD=/usr/sbin/atd -LOCK_FILE=/var/lock/subsys/atd +config=/etc/sysconfig/atd + +[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog + +lockfile=/var/lock/subsys/$prog -[ -f /etc/sysconfig/atd ] || exit 6 - start() { - # Check if atd is already running - echo -n $"Starting $prog: " - daemon $ATD $OPTS && success || failure - RETVAL=$? - [ "$RETVAL" = 0 ] && touch $LOCK_FILE - echo + [ -x $exec ] || exit 5 + [ -f $config ] || exit 6 + echo -n $"Starting $prog: " + daemon $exec $OPTS && success || failure + retval=$? + echo + [ $retval -eq 0 ] && touch $lockfile + return $retval } stop() { - echo -n $"Stopping $prog: " - if [ -n "`pidfileofproc $ATD`" ] ; then - killproc $ATD + echo -n $"Stopping $prog: " + if [ -n "`pidfileofproc $exec`" ] ; then + killproc $exec RETVAL=3 else failure $"Stopping $prog" fi - RETVAL=$? - [ "$RETVAL" = 0 ] && rm -f $LOCK_FILE + retval=$? echo + [ $retval -eq 0 ] && rm -f $lockfile + return $retval +} + +restart() { + stop + start +} + +reload() { + restart +} + +force_reload() { + restart +} + +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 } -restart() { - stop - start -} - -reload() { - echo -n $"Reloading $prog: " - if [ -n "`pidfileofproc $ATD`" ]; then - killproc $ATD -HUP - else - failure $"Reloading $prog" - fi - RETVAL=$? - echo -} - case "$1" in -start) - start - ;; -stop) - stop - ;; -restart) - stop - start - ;; -reload) - reload - ;; -condrestart) - if [ -f $LOCK_FILE ]; then - if [ "$RETVAL" = 0 ]; then - stop - sleep 3 - start - fi - fi - ;; -status) - status $ATD - ;; -*) - echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}" - RETVAL=3 + start) + rh_status_q && exit 0 + $1 + ;; + stop) + rh_status_q || exit 0 + $1 + ;; + restart) + $1 + ;; + reload) + rh_status_q || exit 7 + $1 + ;; + force-reload) + force_reload + ;; + status) + rh_status + ;; + condrestart|try-restart) + rh_status_q || exit 0 + restart + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" + exit 2 esac -exit $RETVAL +exit $?