]> andersk Git - moira.git/blame - gen/acl.sh
Deal with new organization of incremental. Provide support for building
[moira.git] / gen / acl.sh
CommitLineData
883e2e2b 1#!/bin/sh
2# $Id$
f4f32185 3if [ -d /var/athena ] && [ -w /var/athena ]; then
4 exec >/var/athena/moira_update.log 2>&1
5else
6 exec >/tmp/moira_update.log 2>&1
7fi
883e2e2b 8
9# The following exit codes are defined and MUST BE CONSISTENT with the
10# error codes the library uses:
11MR_MISSINGFILE=47836473
12MR_MKCRED=47836474
13MR_TARERR=47836476
14
15status=0
16
17PATH=/bin:/usr/bin
18TARFILE=/var/tmp/acl.out
19
20# Alert if the tar file does not exist
21test -r $TARFILE || exit $MR_MISSINGFILE
22
23# Make a temporary directory to unpack the tar file into
24mkdir /var/tmp/acltmp || exit $MR_MKCRED
25cd /var/tmp/acltmp || exit $MR_MKCRED
9d7295fe 26tar xpf $TARFILE || exit $MR_TARERR
883e2e2b 27
28# Copy over each file which is new or has changed
29for file in `find . -type f -print | sed -e 's/^\.//'`; do
30 if [ $file = /etc/passwd -o $file = /etc/passwd.local ]; then
31 # Make sure that there is a head file, or that the generated
32 # file contains an entry for root.
33 if [ ! -f $file.head ]; then
34 if egrep -s ^root: .$file; then
35 :
36 else
f01b0db3 37 status=$MR_MISSINGFILE
883e2e2b 38 break
39 fi
40 fi
41 elif [ $file = /etc/group -o $file = /etc/group.local ]; then
42 # Make sure that there is a head file, or that the generated
43 # file contains a group with gid 0.
44 if [ ! -f $file.head ]; then
f01b0db3 45 if awk -F: '$3 == "0" { exit 1; }' $file; then
46 status=$MR_MISSINGFILE
883e2e2b 47 break
48 fi
49 fi
50 fi
51
9d7295fe 52 if [ -f $file.head ]; then
53 head=$file.head
54 else
55 head=
56 fi
57 if [ -f $file.tail ]; then
58 tail=$file.tail
59 else
60 tail=
61 fi
62
63 # Note that "$file" is a full pathname, and so ".$file" means
64 # the copy of file in the directory hierarchy rooted at ".",
65 # not "$file with a . prepended to its basename".
883e2e2b 66
9d7295fe 67 # Create a tmp file with the correct owner and mode
883e2e2b 68 if [ -f $file ]; then
9d7295fe 69 cp -p $file $file.$$
70 else
71 cp -p .$file $file.$$
72 fi
73
74 # Now dump the correct data into the tmp file without changing its
75 # owner and mode
76 cat $head .$file $tail > $file.$$
77
78 if cmp -s $file.$$ $file; then
79 rm -f $file.$$
883e2e2b 80 else
9d7295fe 81 mv $file.$$ $file
883e2e2b 82 fi
83done
84
85# cleanup
86cd /
87rm -rf /var/tmp/acltmp
88test -f $TARFILE && rm -f $TARFILE
89test -f $0 && rm -f $0
90
91exit $status
This page took 0.220945 seconds and 5 git commands to generate.