summaryrefslogtreecommitdiff
path: root/web-server/wwwcvs-orig-files/modules/wwwgnu-nongnu/files/update-cvs.sh
blob: 62ac513fac16f4adc4da3b1a69f765bbea1ad070 (plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash

# Handle cvs updates. This script looks at
#  /usr/local/to-update/
# where the 
#  /var/www/new-savannah-project/new.py 
# script creates empty files if there is work to do.
#
# Ward Vandewege, 2012-09-26

DIR="/usr/local/to-update/"
RUNUSER="wwwcvs"

CHECKOUT="/var/www/savannah-checkouts"
LOGFILE="/var/log/wwwcvs/update-cvs.log"

if [[ "$(whoami)" != "$RUNUSER" ]]; then
        echo "Script must be run as user: $RUNUSER"
        exit -1
fi

if [[ -e $DIR/www ]]; then
  cd /var/www
	echo `date` >> $LOGFILE
	echo "www: Beginning checkout" >> $LOGFILE
	/usr/bin/cvs update -Pd . >> $LOGFILE 2>&1
  rm -f $DIR/www
	echo "www: CVS checkout completed" >> $LOGFILE
fi

for f in `ls $DIR`; do
	NEXT=`expr index "$f" '___'`
	if [[ "$NEXT" == "0" ]]; then
	 continue
	fi

	arr=`echo $f | tr -s "___" ' '`
	T=''
	for x in $arr; do
		if [[ "$T" == '' ]]; then
			T=$x
		else
			P=$x
		fi
	done

	cd $CHECKOUT/$T
	echo `date` >> $LOGFILE
	echo "$P: Beginning checkout (type $T)" >> $LOGFILE
	if [[ ! -d $P ]]; then
		# Cf. RT #816041. This is lunacy. Ward, 2013-03-28.
		mkdir $P
	fi
	/usr/bin/cvs -d :pserver:anoncvs@cvs.savannah.gnu.org:/webcvs/$P checkout -P $P >> $LOGFILE 2>&1
	echo "$P: CVS checkout completed (type $T)" >> $LOGFILE
	rm -f $DIR/$f

done