1#!/bin/sh
2# $Id: mirror.sh,v 1.1 1999/07/15 18:13:25 jens Exp $
3
4# This script shows an example of how you can mirror lots of
5# servers without lots of administrativ problems.
6
7# where to find the binary
8SPEGLA="./spegla"
9
10# where we run the program from
11MIRROR_DIR=. #"/chageme"
12
13# name of the config file
14CONF="mirrorconf"
15
16# comment out if unwanted
17CALCTIME=1
18
19# mirror
20#	runs spegla for ther named section in the config file mirrorconf
21#
22mirror() {
23	section=${1}
24	if [ -z "$section" ]; then
25		echo 1>&2 "mirror: no section"
26		exit 2
27	fi
28
29	echo Updating $section
30	$SPEGLA 											\
31		--section=common --configfile=mirrorconf 		\
32		--section=$section --configfile=mirrorconf 		\
33		--lockfile=lock/$section						\
34		--logfile=log/$section
35}
36
37printtime() {
38	seconds=$1
39	if [ -z "$seconds" ]; then
40		seconds=0
41	fi
42
43	hours=`expr $seconds / 3600`
44	seconds=`expr $seconds - $hours '*' 3600`
45	minutes=`expr $seconds / 60`
46	seconds=`expr $seconds - $minutes '*' 60`
47	printf '%02d:%02d:%02d' $hours $minutes $seconds
48}
49
50if cd $MIRROR_DIR ; then
51else
52	exit 2
53fi
54
55if [ ! -z "$CALCTIME" ]; then
56	starttime=`date '+%s'`
57	startdate=`date`
58fi
59
60
61# Sections that are to be mirrored
62##################################
63
64mirror gnu
65mirror bind
66mirror tools
67mirror host
68
69##################################
70if [ ! -z "$CALCTIME" ]; then
71	endtime=`date '+%s'`
72	echo update of mirrors started at $startdate
73	echo update of mirrors ended at `date`
74	echo -n "total amount of time "
75	printtime `expr $endtime - $starttime`
76	echo
77fi
78