]>
Commit | Line | Data |
---|---|---|
b8e4bdf8 | 1 | #!/bin/csh -f |
2 | # This script installs new directories on NFS servers. | |
3 | ||
4 | # The following exit codes are defined and MUST BE CONSISTENT with the | |
2ce085d2 | 5 | # MR error codes the library uses: |
6 | set MR_PROTO = 47836477 | |
b8e4bdf8 | 7 | |
8 | set path=(/etc /bin /usr/bin /usr/etc) | |
9 | ||
10 | # Find out what device we're working on | |
11 | set dev = $1 | |
12 | ||
df6d8bff | 13 | set USERTAR = /tmp/nfs.dir/proto.tar # Tarfile for user . files |
b8e4bdf8 | 14 | |
15 | # So that the new directories get the right protections. | |
16 | umask 66 | |
17 | ||
18 | while (1) | |
19 | # Do this until there are no more lines of input | |
20 | set input = `echo $<` | |
21 | if ($#input != 4) break | |
22 | ||
23 | set dir = $input[1] | |
24 | set uid = $input[2] | |
25 | set gid = $input[3] | |
26 | set type = $input[4] | |
27 | ||
28 | # Don't do anything if the directory already exists | |
29 | if (-d $dir) continue | |
30 | ||
31 | while (1) | |
32 | set tmpdir = $dir:h/_$dir:t | |
33 | # Don't clobber this directory if it exists. | |
34 | if (-d $tmpdir) then | |
d362c76b | 35 | break; |
b8e4bdf8 | 36 | else |
37 | mkdir $tmpdir | |
38 | # At some point it may be wise to check the status here and | |
39 | # return a soft failure, but the current protocol doesn't | |
40 | # support this | |
41 | break | |
42 | endif | |
43 | end | |
44 | if (! -d $tmpdir) continue | |
45 | chown $uid.$gid $tmpdir | |
46 | ||
47 | # At some point, we may wish to add a more elegant way of handling | |
48 | # locker types. The current arrangement allows for easy adding of | |
49 | # default actions here. | |
50 | switch ($type) | |
51 | case HOMEDIR: | |
52 | ||
53 | # ***** Remove this when /etc/encorce_quota becomes obsolete! | |
b138e831 | 54 | # Give this filesystem a 1200K quota |
55 | setquota $dev $uid 1200 | |
b8e4bdf8 | 56 | # ***** |
57 | ||
58 | # Give user prototype files | |
69d33c3c | 59 | (cd $tmpdir; tar xf $USERTAR) |
b8e4bdf8 | 60 | if ($status) set WARN |
69d33c3c | 61 | chown $uid.$gid $tmpdir $tmpdir/.??* $tmpdir/* |
b8e4bdf8 | 62 | breaksw |
74186cf3 | 63 | case COURSE: |
64 | /bin/chmod 775 $tmpdir | |
65 | breaksw | |
b8e4bdf8 | 66 | default: |
67 | breaksw | |
68 | endsw | |
69 | ||
70 | mv $tmpdir $dir | |
71 | ### Soft failure when ready | |
72 | end | |
73 | ||
b8e4bdf8 | 74 | exit 0 |
75 | ||
76 | # | |
77 | # $Source$ | |
78 | # $Header$ | |
79 | # |