summaryrefslogtreecommitdiff
path: root/sys/lib/dist.old/pc/inst/fmtfossil
blob: 98bf33fc1072b3bb983caa5e3c94d99e9020afe4 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/rc

# desc: initialize disks for a fossil server
# prereq: configfs

switch($1){
case checkready checkdone
	if(! ~ $fstype fossil+venti fossil){
		fmtfossil=notdone
		export fmtfossil
		exit
	}
	ff=`{ls /dev/sd*/fossil* /dev/fs/fossil* >[2]/dev/null}
	if(~ $#ff 0){
		fmtfossil=notdone
		export fmtfossil
		exit
	}
	gg=()
	for(f in $ff)
		if(isfossil $f)
			gg=($gg $f)
	if(~ $#gg 0){
		fmtfossil=ready
		export fmtfossil
		exit
	}
	fmtfossil=done
	export fmtfossil
	exit

case go
	ff=`{ls /dev/sd*/fossil* /dev/fs/fossil* >[2]/dev/null}
	if(~ $#ff 0){
		echo 'You need to create a partition or partitions to hold the Fossil write cache.'
		echo 'The partition name must begin with "fossil".'
		echo
		fmtfossil=notdone
		export fmtfossil
		exit
	}
	default=()
	if(~ $#ff 1){
		default=(-d $ff)
	}
	echo You have the following fossil partitions.
	echo
	prompt $default 'Fossil partition to format' $ff
	f=$rd

	do=yes
	if(isfossil $f){
		echo $f appears to already be formatted as Fossil file system.
		echo Do you really want to reformat it?
		echo
		prompt -d no 'Reformat '$f yes no
		do=$rd
	}
	if(~ $do yes){
		fossil/flfmt -y $f
		n=`{cat /dev/swap | grep ' user' | sed 's/^[0-9]+\/([0-9]+) .*/\1/'}
		if(test $n -gt 32768)
			m=3000	# if have at least 128 user MB, use 24MB for fossil
		if not if(test $n -gt 16384)
			m=1500	# 64 user MB => 12MB for fossil
		if not if(test $n -gt 8192)
			m=750	# 32 user MB => 6MB for fossil
		if not
			m=256	# 2MB for fossil (this will be slow)

		# if we're using a venti in the back, take hourly snapshots
		# that retire after three days, in addition to the daily dumps at 5am
		if(~ $fstype fossil+venti){
			v=''
			snap='fsys main snaptime -s 60 -a 0500 -t 2880'
		}
		# otherwise, take the daily dumps but nothing else --
		# we can't retire snapshots unless dumps are being archived
		if not{
			v='-V'
			snap=''
		}
		echo \
'fsys main config '^$f^'
fsys main open '^$v^' -c '^$m^'
'^$snap^'
'		| fossil/conf -w $f
	}
	
	echo Done.
}