Hi,

This is my first contribution (and first day in use :-)) to otrs.
Thanks for it!

I wasn't able to get otrs running with apache-2.0.53 and mod_perl-1.99.17, i 
have now apache-1.3.33 and mod_perl-1.27-r4 on 
Gentoo Linux with preloaded perl libs.

I have written a little patch witch allows me to run ~otrs/bin/Cron.sh as 
root.

cmd: ~otrs/bin/Cron.sh (start|stop|restart) <otrs_user> <otrs_home>

With friendly regards,

Jochum Rene

P.s.: sry, for my poor english
--- Cron.sh.old	2005-05-01 19:26:59.440823888 +0200
+++ Cron.sh	2005-05-01 19:17:38.050168240 +0200
@@ -20,28 +20,56 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 # --
 
-CURRENTUSER=`whoami`
+CURRENTUSERID="$(id -u)"
 OTRS_HOME=$HOME
 #CRON_USER=" -u $RUNASUSER ";
 CRON_USER=""
+CRONTAB=$(which crontab)
 
-if test $CURRENTUSER = root; then
-  echo "Run this script just as OTRS user! Or use 'Cron.sh {start|stop|restart} OTRS_USER'!"
+if [ "${CURRENTUSERID}" = "0" ] && [ -z $2 -a -z $3 ]; then
+  echo "Run this script just as OTRS user! Or use 'Cron.sh {start|stop|restart} <OTRS_USER> <OTRS_HOME>'!"
   exit 5
+else
+  CRON_USER="-u $2"
+  OTRS_HOME=$3
 fi
 
 # find otrs root
 #OTRS_ROOT=/opt/OpenTRS
-if test -e $OTRS_HOME/var/cron; then
-    OTRS_ROOT=$OTRS_HOME
+if [ -d ${OTRS_HOME}/var/cron ] ; then
+    OTRS_ROOT=${OTRS_HOME}
 else
-    echo "No cronjobs in $OTRS_HOME/var/cron found!";
-    echo " * Check the \$HOME (/etc/passwd) of the OTRS user. It must be the root dir of your OTRS system (e. g. /opt/otrs). ";
+    echo "No cronjobs in ${OTRS_HOME}/var/cron found!"
+    echo " * Check the \$HOME (/etc/passwd) of the OTRS user. It must be the root dir of your OTRS system (e. g. /opt/otrs)."
+    echo ""
     exit 5;
 fi
 
-CRON_DIR=$OTRS_ROOT/var/cron
-CRON_TMP_FILE=$OTRS_ROOT/var/tmp/otrs-cron-tmp.$$
+CRON_DIR=${OTRS_ROOT}/var/cron
+CRON_TMP_FILE=${OTRS_ROOT}/var/tmp/otrs-cron-tmp.$$
+
+start() {
+  if cd ${CRON_DIR} && ls * | egrep -E -v '(.dist|.rpm|CVS|Entries|Repository|Root)' | \
+    xargs cat > ${CRON_TMP_FILE} && ${CRONTAB} ${CRON_USER} ${CRON_TMP_FILE}; then
+      rm -f ${CRON_TMP_FILE}
+      echo "(using ${OTRS_ROOT}) done"
+      exit 0
+  else
+      rm -f ${CRON_TMP_FILE}
+      echo "failed"; > /dev/stderr
+      exit 1
+  fi
+}
+
+stop() {
+  if ${CRONTAB} ${CRON_USER} -r ; then
+    echo "done"
+    exit 0
+  else
+    echo "failed"
+    exit 1
+  fi
+}
 
 echo "Cron.sh - start/stop OTRS cronjobs - <\$Revision: 1.10 $> "
 echo "Copyright (c) 2002 Martin Edenhofer <[EMAIL PROTECTED]>"
@@ -54,33 +82,21 @@
     # start
     # ------------------------------------------------------
     start)
-      if mkdir -p $CRON_DIR; cd $CRON_DIR && ls * |grep -v '.dist'|grep -v '.rpm'| grep -v CVS | grep -v Entries | grep -v Repository | grep -v Root | xargs cat > $CRON_TMP_FILE && crontab $CRON_USER $CRON_TMP_FILE; then
-        rm -rf $CRON_TMP_FILE
-        echo "(using $OTRS_ROOT) done";
-        exit 0;
-      else
-        echo "failed";
-        exit 1;
-      fi
+      start
     ;;
     # ------------------------------------------------------
     # stop
     # ------------------------------------------------------
     stop)
-      if crontab $CRON_USER -r ; then
-        echo "done";
-        exit 0;
-      else
-        echo "failed";
-        exit 1;
-      fi
+      stop
     ;;
     # ------------------------------------------------------
     # restart
     # ------------------------------------------------------
     restart)
-      $0 stop
-      $0 start
+      stop
+      sleep 1
+      start
     ;;
     # ------------------------------------------------------
     # Usage

Attachment: pgp1B9WYl3H7O.pgp
Description: PGP signature

_______________________________________________
OTRS mailing list: dev - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/dev
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/dev

Reply via email to