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