Hi Marc

Thanks for the patch. It would be nice if you could update the
changelog items as well in the patch. See further comments below.

On Sat, Apr 29, 2006 at 03:59:40PM +0200, Marc Haber wrote:
> On Wed, Mar 22, 2006 at 10:15:40PM +0100, Ola Lundqvist wrote:
> > Patch is welcome.
> 
> A first try is attached. This basically moves the lock that we already
> use to a more global level, and work rudimenatarily. It is not well
> tested though.
 
Shouldn't the locking be moved to after the sleep?

I also think that we should have it configurable if it should break or
wait, when if finds a previous lock.

I can add that myself though.

> One thing I have not gotten right is message handling: The message
> printed if /usr/bin/dotlockfile is not found seems to go nowhere if
> the cron-apt run won't generate output otherwise. I have not yet
> understood the message/log file handling with the createdivinfo stuff.
> It is kind of underdocumented.

Yes it is a bit hidden... But there are some documentation...

# Create file with RUN information. Line data should be added later.
# Arguments:
# 1: File to create (if = "syslog" we should log to syslog instead)
# 2: File to cat e.g. $TEMP
# 3: Optional file to cat (like errormsg.d/action or so)
# 4: Optional runinformation file (will be removed)
# 5: Optional actioninformation file (will be removed)
# 6: If not empty data will be printed to stdout too.
createdivinfo()

What it does is that it create a file (or log to syslog if file = syslog) that
is a concatenation of all the arguments of which some are removed after 
concatenation.

So what you do is that you prepare a number of files, and then later run
createdivinfo to concatenate the full message that can be emailed away or 
similar.

Regards,

// Ola

> Greetings
> Marc
> 
> -- 
> -----------------------------------------------------------------------------
> Marc Haber         | "I don't trust Computers. They | Mailadresse im Header
> Mannheim, Germany  |  lose things."    Winona Ryder | Fon: *49 621 72739834
> Nordisch by Nature |  How to make an American Quilt | Fax: *49 621 72739835

> --- cron-apt  2006-04-29 15:32:33.424994750 +0200
> +++ /usr/sbin/cron-apt        2006-04-29 15:53:24.551185250 +0200
> @@ -270,6 +270,9 @@
>      if [ -d "$TMPDIR" ] ; then
>       rmdir "$TMPDIR"
>      fi
> +    if [ -x "/usr/bin/dotlockfile" ]; then
> +        dotlockfile -u $LOCKFILE
> +    fi
>  }
>  
>  # Do the actual msg transfer. This reduce some duplications.
> @@ -386,9 +389,26 @@
>      exit 0
>  fi
>  
> -############################### sleep 
> #########################################
> +################## try to take out a lock, terminate if unsuccessful 
> ##########
>  
>  echo "CRON-APT RUN [$CONFIG]: $(date)" > $INITLOG
> +if [ -x /usr/bin/dotlockfile ] ; then
> +    if ! dotlockfile -l -p -r 10 $LOCKFILE; then
> +        # create log entry
> +        echo > $MAIL "cannot acquire cron-apt lock."
> +     onexit
> +     exit 1
> +    fi
> +else
> +    if [ -z "$NOLOCKWARN" ]; then
> +        echo >  $TEMP "WARNING: dotlockfile not installed. If you don't want 
> to see this"
> +        echo >> $TEMP "         Warning any more, set NOLOCKWARN in the 
> configuration file."
> +     createerrorinfo "startup"
> +    fi
> +fi
> +
> +############################### sleep 
> #########################################
> +
>  if [ -n "$RUNSLEEP" ] ; then
>      if [ $RUNSLEEP -gt 0 ] ; then
>       if [ -z "$RANDOM" ] ; then
> @@ -424,34 +444,14 @@
>           grep -v "^[[:space:]]*$" | {
>               while read LINE ; do
>                   echo "CRON-APT LINE: $APTCOMMAND $LINE" > "$TEMP"
> -                 if [ -x /usr/bin/dotlockfile ] ; then
> -                     if ! dotlockfile -l -p -r 10 $LOCKFILE; then
> -                         echo > $TEMP "cannot acquire apt lock."
> -                         RET=1
> -                     else
> -                         UMASK_SAVE=$(umask)
> -                         umask $UMASK_RELAXED
> -                         $APTCOMMAND $OPTIONS $LINE >> $TEMP 2>&1
> -                         RET=$?
> -                         umask $UMASK_SAVE
> -                     fi
> -                     dotlockfile -u $LOCKFILE
> -                 else
> -                     if [ -z "$NOLOCKWARN" ]; then
> -                         echo >  $TEMP "WARNING: dotlockfile not installed. 
> If you don't want to see this"
> -                         echo >> $TEMP "         Warning any more, set 
> NOLOCKWARN in the configuration file."
> -                     fi
> -                     UMASK_SAVE=$(umask)
> -                     umask $UMASK_RELAXED
> -                     $APTCOMMAND $OPTIONS $LINE >> $TEMP 2>&1
> -                     RET=$?
> -                     umask $UMASK_SAVE
> -                 fi
> +                 UMASK_SAVE=$(umask)
> +                 umask $UMASK_RELAXED
> +                 $APTCOMMAND $OPTIONS $LINE >> $TEMP 2>&1
> +                 RET=$?
> +                 umask $UMASK_SAVE
>                   if [ "$FILTERCTRLM" = "true" ]; then
>                       CTRLM="$(echo -e \\r)"
>                       < "$TEMP" sed "s/.*$CTRLM\(.\+\)/\1/" > "$FILTER"
> -                     #grep -v "
> -#" "$TEMP" > "$FILTER"
>                       cp "$FILTER" "$TEMP"
>                   fi
>                   if [ $RET -ne 0 ]; then


-- 
 --------------------- Ola Lundqvist ---------------------------
/  [EMAIL PROTECTED]                     Annebergsslingan 37      \
|  [EMAIL PROTECTED]                 654 65 KARLSTAD          |
|  +46 (0)54-10 14 30                  +46 (0)70-332 1551       |
|  http://www.opal.dhs.org             UIN/icq: 4912500         |
\  gpg/f.p.: 7090 A92B 18FE 7994 0C36  4FE4 18A1 B1CF 0FE5 3DD9 /
 ---------------------------------------------------------------


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to