summaryrefslogtreecommitdiff
path: root/rc/bin/replica/defs
blob: 45b36419f6c1bf284da5d65f522dbd98f9d5ec60 (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
tmp=()

fn fatal {
	if(! ~ $#tmp 0)
		rm -f $tmp
	echo $* >[1=2]
	exit $"*
}

fn must {
	$* || fatal $"*^': '^$status
}

fn need {
	for(i)
		if(~ $$i UNCONFIGURED)
			fatal $name^' does not set $'^$i
}

opt=()
while(! ~ $#* 0 && ~ $1 -*){
	if(~ $1 -s -c){	# take one argument 
		opt=($opt $1)
		shift
	}
	opt=($opt $1)
	shift
}
if(~ $1 --)
	shift
if(~ $#* 0)
	usage
name=$1
shift
paths=($*)

if(! ~ $name /* ./* ../*)
	name=$home/lib/replica/$name

if(! test -x $name)
	fatal no such replica $name

cfgopt=()
applyopt=()
fn servermount { status='' }
fn clientmount { status='' }
fn serverupdate { status='' }
for (i in clientroot clientproto clientdb clientexclude serverroot serverlog serverproto)
	$i=UNCONFIGURED
. $name

if(! ~ $#serverexclude 0)
	serverexclude=-x^$serverexclude
if(! ~ $#clientexclude 0)
	clientexclude=-x^$clientexclude