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