summaryrefslogtreecommitdiff
path: root/net/cvsup-mirror/files/update.sh
blob: 76cd3db2e43906ad9ec41a67c742db4483540f3c (plain) (blame)
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
59
60
61
62
63
64
65
66
67
68
#! /bin/sh

if ! export PREFIX=$(expr $0 : "\(/.*\)/etc/cvsup/update\.sh\$"); then
    echo "$0: Cannot determine the PREFIX" >&2
    exit 1
fi

export PATH=/bin:/usr/bin:${PREFIX}/bin

lock=/var/spool/lock/cvsup.lock
log=/var/log/cvsup.log

# Rotate the log files

umask 22
test -f ${log}.7 && mv -f ${log}.7 ${log}.8
test -f ${log}.6 && mv -f ${log}.6 ${log}.7
test -f ${log}.5 && mv -f ${log}.5 ${log}.6
test -f ${log}.4 && mv -f ${log}.4 ${log}.5
test -f ${log}.3 && mv -f ${log}.3 ${log}.4
test -f ${log}.2 && mv -f ${log}.2 ${log}.3
test -f ${log}.1 && mv -f ${log}.1 ${log}.2
test -f ${log}.0 && mv -f ${log}.0 ${log}.1
test -f ${log}   && mv -f ${log}   ${log}.0
exec >${log} 2>&1

# Do the update

date "+CVSup update begins at %Y/%m/%d %H:%M:%S"

# The rest of this is executed while holding the lock file, to ensure that
# multiple instances won't collide with one another.

lockf -t 0 ${lock} /bin/sh << 'E*O*F'

base=${PREFIX}/etc/cvsup
cd ${base} || exit
. ./config.sh || exit

colldir=sup.client
startup=${PREFIX}/etc/rc.d

umask 2

if [ ${host_crypto} = ${host} ]; then
    echo "Updating from ${host}"
    cvsup -1gL 1 -c ${colldir} -h ${host} supfile
else
    if [ -d prefixes/FreeBSD-crypto.cvs ]; then
	echo "Updating from ${host_crypto}"
	cvsup -1gL 1 -c ${colldir} -h ${host_crypto} supfile.crypto
    fi
    echo "Updating from ${host}"
    cvsup -1gL 1 -c ${colldir} -h ${host} supfile.non-crypto
fi

if [ -f .start_server ]; then
    if [ -x ${startup}/cvsupd.sh ]; then
	echo -n "Starting the server:"
	/bin/sh ${startup}/cvsupd.sh
	echo "."
    fi
    rm -f .start_server
fi

E*O*F

date "+CVSup update ends at %Y/%m/%d %H:%M:%S"