public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] cron02: Use lib to restart crond service
@ 2013-07-09  9:25 Peng Haitao
  2013-07-09 11:37 ` chrubis
  2013-07-10  1:40 ` Wanlong Gao
  0 siblings, 2 replies; 3+ messages in thread
From: Peng Haitao @ 2013-07-09  9:25 UTC (permalink / raw)
  To: ltp-list

Use restart_daemon() to restart crond service.

Signed-off-by: Peng Haitao <penght@cn.fujitsu.com>
---
 testcases/commands/cron/cron02 | 27 +++++----------------------
 testcases/lib/cmdlib.sh        |  8 ++++++++
 2 files changed, 13 insertions(+), 22 deletions(-)

diff --git a/testcases/commands/cron/cron02 b/testcases/commands/cron/cron02
index f8615dc..16b425d 100755
--- a/testcases/commands/cron/cron02
+++ b/testcases/commands/cron/cron02
@@ -52,29 +52,10 @@ do_setup(){
         }
         fi
 
-	# running under systemd?
-	if command -v systemctl >/dev/null 2>&1; then
-		HAVE_SYSTEMCTL=true
+	if [ -n "$CROND_DAEMON" ]; then
+		restart_daemon $CROND_DAEMON
 	else
-		HAVE_SYSTEMCTL=false
-	fi
-
-	# restart cron daemon
-	# Red Hat uses crond, SuSE/Other uses cron.
-	if [ -x /etc/init.d/crond ]; then
-		/etc/init.d/crond restart
-	elif [ -x /etc/init.d/cron ]; then
-		/etc/init.d/cron restart
-	elif $HAVE_SYSTEMCTL; then
-		for crond in "crond" "cron"; do
-			if systemctl is-enabled $crond.service >/dev/null 2>&1; then
-				systemctl restart $crond.service
-				break
-			fi
-		done
-	else
-		echo "Could not determine cron init.d script."
-		exit 1
+		tst_brkm TBROK "Couldn't find crond or cron"
 	fi
 }
 
@@ -90,6 +71,8 @@ do_cleanup(){
 #-----------------------------------------------------------------------
 # FUNCTION:  MAIN
 #-----------------------------------------------------------------------
+. cmdlib.sh
+
 do_setup
 cron_pos_tests.sh $TEST_USER
 EXIT_CODE=$?
diff --git a/testcases/lib/cmdlib.sh b/testcases/lib/cmdlib.sh
index b1ea15e..d6f43d2 100644
--- a/testcases/lib/cmdlib.sh
+++ b/testcases/lib/cmdlib.sh
@@ -168,6 +168,14 @@ elif command -v rsyslogd >/dev/null 2>&1; then
 	SYSLOG_DAEMON="rsyslog"
 fi
 
+# Check to see if cron or crond exists
+CROND_DAEMON=""
+if command -v crond >/dev/null 2>&1; then
+	CROND_DAEMON="crond"
+elif command -v cron >/dev/null 2>&1; then
+	CROND_DAEMON="cron"
+fi
+
 start_daemon()
 {
 	if [ $HAVE_SYSTEMCTL -eq 1 ]; then
-- 
1.8.3.1


------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-07-10  1:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-09  9:25 [LTP] [PATCH] cron02: Use lib to restart crond service Peng Haitao
2013-07-09 11:37 ` chrubis
2013-07-10  1:40 ` Wanlong Gao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox