[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

cron job to monitor global revision number

From: Christopher Ness <chris_at_nesser.org>
Date: 2004-09-28 05:05:12 CEST

Hi all,

I do not maintain the repository I am working on but I want to track how
often commits are made, then I can make some graphs with the data.

You need to authorize to use this server so I am using the command line
authentication, which seems very dangerous on shared machines. I'm
surprised that the --password option exists and isn't buried somewhere
in the config file.

I wrote a cron job that I thought would do the trick, but it is failing
on me and I don't understand why. I hacked it around so that it went
from a two line script into a mess.

I expected some network failures and whatnot, but it is failing every
time and is driving me nuts when cron emails me errors asking for a
username!

Steps:
0. Checked out the repository with:
  # cd /home/nesscg/sandbox/
  # svn co https://URL/Goes/Here
  # ....provided credentials here....

1. Set up cron job with this file `crontab $FILENAME`:
 # use /bin/sh to run commands, no matter what /etc/passwd says
 SHELL=/bin/bash
 HOME=/home/nesscg
 # mail any output to ‘paul’, no matter whose crontab this is
 MAILTO=nesscg

PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/nesscg/bin
 #
 # run every 15 minutes, every day...
         0,15,30,45 * * * * $HOME/bin/svn-watch

2. Put this script in the place mentioned above.

#!/bin/bash
O_FILE=/home/nesscg/websvn
REPO=/home/nesscg/sandbox/se4a03/

# Capture the revision information! w00t, going to plot this with time
env
# Unlock any files that might be fubar'd from the last run
killall svn &>/dev/null
svn cleanup
# Run the update command and grab the revision info
# The security risk of this line is infinitely large on a shared system
# YOU ARE PUTTING YOUR PASSWORD IN THE OPEN! Try `ps aux | grep svn`
svn --non-interactive --username nesscg --password *blanked* up $REPO
SVN_RETURN=`svnversion ${REPO}`

# Write the date \t time \t revisioninfo
echo "`date +%F%t%R%t` ${SVN_RETURN}" >> $O_FILE
exit 0

3. Open up my email and see these messages from cron for EVERY
execution, note the top is the output of the `env` command:

MAILTO=nesscg
SHELL=/bin/sh
OLDPWD=/home/nesscg
PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/nesscg/+bin
PWD=/home/nesscg/sandbox/se4a03
HOME=/home/nesscg
SHLVL=2
LOGNAME=nesscg
_=/bin/env
svn: '' is not a working copy directory
svn: PROPFIND request failed on '/trunk/se4a03'
svn: PROPFIND of '/trunk/se4a03': authorization failed

So what am I doing wrong? I _thought_ I was using the command line
arguments to authenticate! This script works every time I run it as my
own user and not in the cron environment, so I'm thinking it's the shell
that cron is using, but what is it missing to cause auth failures?

Thoughts and Thanks,
Chris

-- 
Software Engineering V,
McMaster University
PGP Public Key: http://www.nesser.org/pgp-key/
20:53:51 up 1:41, 5 users, load average: 1.33, 1.43, 1.36 
http://www.fsf.org/philosophy/no-word-attachments.html

Received on Tue Sep 28 05:05:59 2004

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.