summaryrefslogtreecommitdiff
path: root/rc/bin/inst/mountcwfs
blob: 2c1416f3a361212c050f6b9ab0b5d0306f0f5898 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/rc

# desc: choose and mount file system partition
# prereq: systype

switch($1){
case go
	echo
	echo The please choose your $fstype partitions
	echo

	files=(`{ls /dev/sd*/fscache* /dev/fs/fscache* >[2]/dev/null})
	if(! ~ $#files 0)
		ls -l $files
	echo
	if(~ $#files 1)
		default=(-d $files)
	if not
		default=()
	prompt $default 'Cwfs cache partition' $files
	fs=$rd
	export fs

	files=(`{ls /dev/sd*/fsworm* /dev/fs/fsworm* >[2]/dev/null})
	if(! ~ $#files 0)
		ls -l $files
	echo
	if(~ $#files 1)
		default=(-d $files)
	if not
		default=()
	prompt $default 'Cwfs worm partition' $files
	fsworm=$rd
	export fsworm

	files=(`{ls /dev/sd*/other* /dev/fs/other* >[2]/dev/null})
	if(! ~ $#files 0)
		ls -l $files
	echo
	if(~ $#files 1)
		default=(-d $files)
	if not
		default=()
	prompt $default 'Cwfs other partition' $files
	fsother=$rd
	export fsother

	ream=no
	if(! ~ $fstype `{fstype $fs})
		ream=yes
	prompt -d $ream 'Ream the filesystem?' yes no
	ream=$rd

	log Starting $fstype file server for $fs
	unmount /n/newfs >[2]/dev/null
	echo halt >>/srv/cwfs.cmd >[2]/dev/null
	rm -f /srv/cwfs /srv/cwfs.cmd

	if(~ $ream yes){
		if(! test -f /tmp/fsconfig){
			{
				echo service cwfs
				echo config $fs

				if(! ~ $syst cpu){
					# new config option
					echo noauth
				}

				echo filsys main c'('$fs')('$fsworm')'
				echo filsys dump o
				if(! ~ $fsother ''){
					echo filsys other '('$fsother')'
					echo ream other
				}
				echo ream main
				echo end
			} >/tmp/fsconfig
		}
		echo 'Reaming filesystem'
		if(! $fstype -f $fs -c </tmp/fsconfig){
			mountfs=ready
			export mountfs
			exit oops
		}
	}
	if not {
		echo 'Entering manual configuration mode. when done, type end'
		if(! $fstype -n cwfs -f $fs -c){
			mountfs=ready
			export mountfs
			exit oops
		}
	}

	log Configuering $fstype file server for $fs
	{
		echo allow
		echo users default
		echo cfs main
		echo create /adm adm adm 775 d
		echo create /adm/users adm adm 664
		echo create /dist sys sys 775 d
		echo create /usr sys sys 775 d
		echo newuser adm +bootes
		echo newuser sys +bootes
		echo newuser upas +bootes
		echo newuser $user
		echo newuser adm +$user
		echo newuser sys +$user
		echo newuser upas +$user
		if(! ~ $fsother ''){
			echo cfs other
			echo create /dist sys sys 775 d
			echo create /usr sys sys 775 d
			echo create /usr/bootes bootes bootes 775 d
			echo create /usr/bootes/tmp bootes bootes 750 d
			echo create /usr/$user $user $user 775 d
			echo create /usr/$user/tmp $user $user 750 d
			echo cfs main
		}
	} >>/srv/cwfs.cmd
	sleep 5

	log Mounting $fstype file server for $fs
	if(! logprog mount -c /srv/cwfs /n/newfs){
		mountfs=ready
		export mountfs
		exit
	}
	if(! ~ $fsother ''){
		log Mounting $fstype file server for $fsother
		if(logprog mount -c /srv/cwfs /n/other other)
			bind -qc /n/other/dist /n/newfs/dist
	}

case checkready checkdone
	if(! ~ $fstype '' && ~ $#fs 1 && test -f $fs){
		if(test -f /srv/cwfs && test -d /n/newfs/dist){
			mountfs=done
			export mountfs
			exit
		}
	}
	mountfs=ready
	export mountfs
	exit
}