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