]> andersk Git - moira.git/blob - gen/install_dirs
Fixed setquota; removed rm welcome; fixed modes on dot files
[moira.git] / gen / install_dirs
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
5 # SMS error codes the library uses:
6 set SMS_PROTO = 47836477
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
13 set TMPSTOR = /tmp/tmpstor      # Temporary area for user . files
14 set USERTAR = /tmp/proto.tar    # Tarfile for user . files
15
16 # Give ourselves a fresh work area
17 rm -rf $USERTAR
18 rm -rf $TMPSTOR
19 mkdir $TMPSTOR
20 if ($status) exit $SMS_PROTO
21
22 # Make a tarfile containing the user prototype files for future use.
23 (cd /usr/prototype_user;tar cf - .) | (cd $TMPSTOR; tar xpf -)
24 (cd $TMPSTOR; tar cf $USERTAR .)
25 if ($status) exit $SMS_PROTO
26 rm -rf $TMPSTOR
27
28 # So that the new directories get the right protections.
29 umask 66
30
31 while (1)
32    # Do this until there are no more lines of input
33    set input = `echo $<`
34    if ($#input != 4) break
35
36    set dir = $input[1]
37    set uid = $input[2]
38    set gid = $input[3]
39    set type = $input[4]
40
41    # Don't do anything if the directory already exists
42    if (-d $dir) continue
43
44    while (1)
45       set tmpdir = $dir:h/_$dir:t
46       # Don't clobber this directory if it exists.
47       if (-d $tmpdir) then
48          continue
49       else
50          mkdir $tmpdir
51          # At some point it may be wise to check the status here and 
52          # return a soft failure, but the current protocol doesn't
53          # support this
54          break
55       endif
56    end
57    if (! -d $tmpdir) continue
58    chown $uid.$gid $tmpdir
59
60    # At some point, we may wish to add a more elegant way of handling 
61    # locker types.  The current arrangement allows for easy adding of 
62    # default actions here.
63    switch ($type)
64       case HOMEDIR:
65          
66          # ***** Remove this when /etc/encorce_quota becomes obsolete!
67          # Give this filesystem a 600K quota
68          setquota $dev $uid 600
69          # *****
70
71          # Give user prototype files
72          # sms_untar is a setuid argv[1] tar xfp -
73          (cd $tmpdir; sms_untar $uid < $USERTAR)
74          if ($status) set WARN
75          breaksw      
76       default:
77          breaksw
78    endsw
79
80    mv $tmpdir $dir
81    ### Soft failure when ready
82 end
83
84 # Cleanup
85 rm -f $USERTAR
86 exit 0
87
88 #
89 #       $Source$
90 #       $Header$
91 #
This page took 0.048938 seconds and 5 git commands to generate.