summaryrefslogtreecommitdiff
path: root/sys/lib/dist/pc/inst/prepdisk
blob: 6ef4a92f8ab285be437c628ebdac2b45c9758cff (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
#!/bin/rc

# desc: subdivide plan 9 disk partition
# prereq: partdisk

fn autotype {
	if(~ $fstype fossil)
		echo -a 9fat -a nvram -a fossil -a swap
	if(~ $fstype fossil+venti)
		echo -a 9fat -a nvram -a arenas -a isect -a fossil -a swap # -a other
}

switch($1) {
case checkready
	if(! test -f /dev/sd*/plan9*){
		prepdisk=notdone
		export prepdisk
	}

case go
	echo 'The following Plan 9 disk partitions were found.'
	echo
	disks=(/dev/sd*/plan9*)
	for (i in $disks){
		echo $i
		echo q | disk/prep -r $i >[2]/dev/null
		echo
	}
	if(~ $#disks 1)
		default=(-d $disks)
	if not
		default=()
	prompt $default 'Plan 9 partition to subdivide' $disks
	disk=$rd

	echo 'This is disk/prep; use it to subdivide the Plan 9 partition.'
	echo 'If it is not yet subdivided, a sensible layout will be suggested;'
	echo 'you can probably just type ''w'' and then ''q''.'
	echo
	disk/prep `{autotype} $disk
	disk/prep -p $disk >`{basename -d $disk}^/ctl >[2]/dev/null

case checkdone
	if(! test -f /dev/sd*/9fat)
		prepdisk=ready

	if(! ~ $prepdisk ready){
		prepdisk=done
		switch($fstype){
		case fossil
			if(! test -f /dev/sd*/fossil* && ! test -f /dev/fs/fossil*)
				prepdisk=ready
		case fossil+venti
			if(! test -f /dev/sd*/fossil* && ! test -f /dev/fs/fossil*)
				prepdisk=ready
			if(! test -f /dev/sd*/arenas && ! test -f /dev/fs/arenas*)
				prepdisk=ready
			if(! test -f /dev/sd*/isect && ! test -f /dev/fs/isect*)
				prepdisk=ready
		}
	}
	export prepdisk
}