Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_unix/rc/bin/loadfossil – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#!/bin/rc
2
# loadfossil - populate a fossil partition or file
3
#
4
# due to name clashes in /srv, will only work on a machine
5
# without a fossil named `fossil' already running.
6
 
7
rfork en
8
 
9
fn killfossil {
10
	sleep 1
11
	unmount /n/f &
12
	sleep 1
13
	rm -f /srv/^(fossil fossil.open fscons fscons.open)
14
	kill fossil | rc
15
	sleep 1
16
}
17
 
18
fn sendexpect {		# send expect timeout
19
	echo $1
20
	if(! dial/expect -qt $3 $2)
21
		echo -n 'no '^$"1^'...' > /dev/cons
22
}
23
 
24
fn usage {
25
	echo usage: $argv0 partition root proto fossil.conf >[1=2]
26
	exit usage
27
}
28
 
29
fn sigexit {
30
	rm -f /tmp/fossil-no-list.conf
31
	exit
32
}
33
fn sigint sighup sigterm {
34
	rm -f /tmp/fossil-no-list.conf
35
	killfossil
36
	exit note
37
}
38
 
39
# process arguments
40
if (! ~ $#* 4)
41
	usage
42
argv0=$0
43
fosspart=$1
44
srcroot=$2
45
proto=$3
46
fossconf=$4
47
 
48
if (test -e /srv/fossil -o -e /srv/fossil.open) {
49
	echo $0: /srv/fossil* exists, not safe to start a new fossil >[1=2]
50
	exit fossil-already-running
51
}
52
 
53
# initialise fossil
54
fossil/flfmt -y $fosspart
55
 
56
# install listen-less config for fossil creation
57
{
58
	grep -v '^listen ' $fossconf
59
	echo create /active/adm adm sys d775
60
	echo create /active/adm/users adm sys 664
61
} >/tmp/fossil-no-list.conf
62
fossil/conf -w $fosspart /tmp/fossil-no-list.conf
63
 
64
# start fossil
65
fossil/fossil -f $fosspart
66
mount -cC /srv/fossil.open /n/f
67
 
68
# set up /adm/users
69
cp /adm/users /n/f/adm
70
{
71
	echo
72
	dial/drain &
73
	sleep 2
74
	sendexpect 'users -r /active/adm/users' ': ' 5
75
} </srv/fscons.open >>/srv/fscons.open
76
 
77
# remount with new users
78
unmount /n/f
79
mount -cC /srv/fossil.open /n/f
80
 
81
# populate fossil
82
@ {
83
	# logs are boring, make them all appear empty
84
	chmod +arw /tmp/empty-log >/tmp/empty-log
85
	cd $srcroot/sys/log && {
86
		for (f in [0-9a-z]* */*)
87
			if (! ~ $f httpd mkfile smtpdb timesync.d vac year)
88
				bind /tmp/empty-log $f
89
	}
90
	cd /tmp
91
	disk/mkfs -u $srcroot/adm/users -U -d /n/f -s $srcroot $proto
92
}
93
 
94
# stop fossil gracefully
95
{
96
	echo
97
	dial/drain &
98
	sleep 2
99
	sendexpect 'fsys all sync' ': ' 120
100
	sendexpect 'fsys all halt' ': ' 5
101
} </srv/fscons.open >>/srv/fscons.open
102
killfossil
103
 
104
# install permanent fossil configuration
105
fossil/conf -w $fosspart $fossconf