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