]> git.lizzy.rs Git - plan9front.git/blob - rc/bin/inst/mountcwfs
inst: ask to ream filesystem, use 16K blocksize for copydist, fix missed mount in...
[plan9front.git] / rc / bin / inst / mountcwfs
1 #!/bin/rc
2
3 # desc: choose and mount file system partition
4
5 switch($1){
6 case go
7         echo
8         echo The please choose your $fstype partitions
9         echo
10
11         files=(`{ls /dev/sd*/fscache* /dev/fs/fscache* >[2]/dev/null})
12         if(! ~ $#files 0)
13                 ls -l $files
14         echo
15         if(~ $#files 1)
16                 default=(-d $files)
17         if not
18                 default=()
19         prompt $default 'Cwfs cache partition' $files
20         fs=$rd
21         export fs
22
23         files=(`{ls /dev/sd*/fsworm* /dev/fs/fsworm* >[2]/dev/null})
24         if(! ~ $#files 0)
25                 ls -l $files
26         echo
27         if(~ $#files 1)
28                 default=(-d $files)
29         if not
30                 default=()
31         prompt $default 'Cwfs worm partition' $files
32         fsworm=$rd
33         export fsworm
34
35         files=(`{ls /dev/sd*/other* /dev/fs/other* >[2]/dev/null})
36         if(! ~ $#files 0)
37                 ls -l $files
38         echo
39         if(~ $#files 1)
40                 default=(-d $files)
41         if not
42                 default=()
43         prompt $default 'Cwfs other partition' $files
44         fsother=$rd
45         export fsother
46
47         ream=no
48         if(! ~ $fstype `{fstype $fs})
49                 ream=yes
50         prompt -d $ream 'Ream the filesystem?' yes no
51         ream=$rd
52
53         log Starting $fstype file server for $fs
54         unmount /n/newfs >[2]/dev/null
55         echo halt >>/srv/cwfs.cmd >[2]/dev/null
56         rm -f /srv/cwfs /srv/cwfs.cmd
57
58         if(~ $ream yes){
59                 if(! test -f /tmp/fsconfig){
60                         {
61                                 echo service cwfs
62                                 echo config $fs
63
64                                 # new config option
65                                 echo noauth
66
67                                 echo filsys main c'('$fs')('$fsworm')'
68                                 echo filsys dump o
69                                 if(! ~ $fsother ''){
70                                         echo filsys other '('$fsother')'
71                                         echo ream other
72                                 }
73                                 echo ream main
74                                 echo end
75                         } >/tmp/fsconfig
76                 }
77                 echo 'Reaming filesystem'
78                 if(! $fstype -f $fs -c </tmp/fsconfig){
79                         mountfs=ready
80                         export mountfs
81                         exit oops
82                 }
83         }
84         if not {
85                 echo 'Entering manual configuration mode. when done, type end'
86                 if(! $fstype -n cwfs -f $fs -c){
87                         mountfs=ready
88                         export mountfs
89                         exit oops
90                 }
91         }
92
93         log Configuering $fstype file server for $fs
94         {
95                 echo allow
96                 echo users default
97                 echo cfs main
98                 echo create /adm adm adm 775 d
99                 echo create /adm/users adm adm 664
100                 echo create /usr sys sys 775 d
101                 echo newuser $user
102                 echo newuser sys +$user
103                 echo newuser adm +$user
104                 if(! ~ $fsother ''){
105                         echo cfs other
106                         echo create /usr sys sys 775 d
107                         echo create /usr/$user $user $user 775 d
108                         echo create /usr/$user/tmp $user $user 750 d
109                         echo cfs main
110                 }
111         } >>/srv/cwfs.cmd
112         sleep 5
113
114         log Mounting $fstype file server for $fs
115         if(! logprog mount -c /srv/cwfs /n/newfs){
116                 mountfs=ready
117                 export mountfs
118                 exit
119         }
120
121 case checkready checkdone
122         if(! ~ $fstype '' && ~ $#fs 1 && test -f $fs){
123                 if(! test -f /srv/cwfs){
124                         logprog $fstype -f $fs
125                         echo allow >>/srv/cwfs.cmd >>[2]/srv/log
126                 }
127                 if(test -f /srv/cwfs && ! test -f /n/newfs/adm/users){
128                         log Mounting $fstype file server for $fs
129                         if(! logprog mount -c /srv/cwfs /n/newfs){
130                                 mountfs=ready
131                                 export mountfs
132                                 exit
133                         }
134                 }
135                 if(test -f /srv/cwfs && test -f /n/newfs/adm/users){
136                         mountfs=done
137                         export mountfs
138                         exit
139                 }
140         }
141         mountfs=ready
142         export mountfs
143         exit
144 }