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