File: update

package info (click to toggle)
shoop 0.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 328 kB
  • ctags: 41
  • sloc: sh: 1,138; makefile: 209; perl: 44
file content (44 lines) | stat: -rwxr-xr-x 1,343 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh -e
GHOME=/home/groups/shoop
ID_FILE=$GHOME/.ssh/identity
HTDOCS=$GHOME/htdocs
if [ "$RUNNING_UNDER_CVS" ]; then
	exec ssh -i $ID_FILE "$@"
fi
CVS_RSH=$HTDOCS/update
export CVS_RSH
case "$1" in
	www)
		RUNNING_UNDER_CVS=1
		export RUNNING_UNDER_CVS
		date -u
		(cd $HTDOCS;exec cvs update)
	;;
	cvspulse)
		echo "Pulsing webserver to update from cvs on $(date -u)"
		(if lockfile -1 -r 2 $HTDOCS/update.lock 2>/dev/null; then
			# we have obtained the lock on the cvspulse script.
			if lockfile -0 -r 0 $HTDOCS/cvspulse.lock 2>/dev/null; then
				# ok, new pulse active.
				# remove master lock, so other pulses can come in.
				exec >> $GHOME/cvspulse.log 2>&1
				rm -f $HTDOCS/update.lock
				$0 www;
				# We do a loop, so that if while we are reupdating, another
				# pulse comes in, we can be sure that it will still have its
				# changes noticed by this script.
				while [ -e $HTDOCS/cvsflag.lock ]; do
					rm -f $HTDOCS/cvsflag.lock
					$0 www
				done
				rm -f $HTDOCS/cvspulse.lock
			elif lockfile -0 -r 0 $HTDOCS/cvsflag.lock 2>/dev/null; then
				# 2nd(and subsequent) pulses set the above lock
				# flag, which the 1st pulse we see and will do
				# another update from cvs.  We don't have to do anything here.
				: this is a null command, which returns true
			fi
			rm -f $HTDOCS/update.lock
		fi)&
	;;
esac