From c803730f79af7c451c948899583a1df176e7bf42 Mon Sep 17 00:00:00 2001
From: Vinicius Ruoso <vkr07@c3sl.ufpr.br>
Date: Thu, 27 May 2010 15:29:06 -0300
Subject: [PATCH] Added check on inep file when generating the run minute to
 cron

If the inep file is missing, we calculate the cron run minute based on a
random number. This will allow the agent.sh to run correctly even when
there's no inep stored on the system.

Signed-off-by: Vinicius Ruoso <vkr07@c3sl.ufpr.br>
Acked-by: Diego Pasqualin <dgp06@c3sl.ufpr.br>
Acked-by: Erik Alexandre Pucci <eap08@c3sl.ufpr.br>
Acked-by: Ricardo T Oliveira <rto07@c3sl.ufpr.br>
Signed-off-by: Josiney de Souza <josineys@c3sl.ufpr.br>
---
 agent.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/agent.sh b/agent.sh
index de5a63c..6731699 100755
--- a/agent.sh
+++ b/agent.sh
@@ -76,7 +76,11 @@ function checkUpdate()
 
 function schedule()
 {
-    MIN=$(( $(sed "s/[^0-9]//g" ${CLIENTCONFDIR}/inep) % 60 ))
+    if test -f "${CLIENTCONFDIR}/inep"; then
+        MIN=$(( $(sed "s/[^0-9]//g" ${CLIENTCONFDIR}/inep) % 60 ))
+    else
+        MIN=$(( $RANDOM % 60 ))
+    fi
 
     userCron="$(printf\
         "${MIN} ${SCHEDULE}\n${NETSCHEDULE}\n@reboot ${PREFIX}/agent.sh\n")"
-- 
GitLab