| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# set up owner, group and permissions for system or user directories (2nd parameter) |
| 4 |
OWNER=root |
| 5 |
GROUP=admin |
| 6 |
DIRMOD=16893 # drwxrwxr-x |
| 7 |
EXEMOD=33277 # -rwxrwxr-x |
| 8 |
LINKMOD=41469 # lrwxrwxr-x |
| 9 |
FILEMOD=33204 # -rw-rw-r-- |
| 10 |
|
| 11 |
# recursive survey of directory: |
| 12 |
# ignore cvs, svn and Finder crap |
| 13 |
# choose file mode depending on what kind of file we got |
| 14 |
|
| 15 |
survey () |
| 16 |
{ |
| 17 |
for file in `ls -1A $1` |
| 18 |
do |
| 19 |
case $file in |
| 20 |
CVS | .svn | .cvsignore | .cvspass | .DS_Store ) |
| 21 |
;; |
| 22 |
* ) |
| 23 |
if [ -d "$1/$file" ] |
| 24 |
then |
| 25 |
echo "<f n='$file' o='$OWNER' g='$GROUP' p='$DIRMOD'>" |
| 26 |
survey "$1/$file" |
| 27 |
echo "<mod>mode</mod>" |
| 28 |
echo "</f>" |
| 29 |
elif [ -x "$1/$file" ] |
| 30 |
then |
| 31 |
echo "<f n='$file' o='$OWNER' g='$GROUP' p='$EXEMOD'>" |
| 32 |
echo "<mod>mode</mod>" |
| 33 |
echo "</f>" |
| 34 |
elif [ -L "$1/$file" ] |
| 35 |
then |
| 36 |
echo "<f n='$file' o='$OWNER' g='$GROUP' p='$LINKMOD'>" |
| 37 |
echo "<mod>mode</mod>" |
| 38 |
echo "</f>" |
| 39 |
else |
| 40 |
echo "<f n='$file' o='$OWNER' g='$GROUP' p='$FILEMOD'>" |
| 41 |
echo "<mod>mode</mod>" |
| 42 |
echo "</f>" |
| 43 |
fi |
| 44 |
;; |
| 45 |
esac |
| 46 |
done |
| 47 |
} |
| 48 |
|
| 49 |
# output root XML and top directory, then recursively survey the directories |
| 50 |
|
| 51 |
echo "<?xml version='1.0'?>" |
| 52 |
echo "<pkg-contents spec='1.12'>" |
| 53 |
echo "<f n='${1##*/}' o='$OWNER' g='$GROUP' p='$DIRMOD' pt='$1' m='true' t='file'>" |
| 54 |
survey "$1" |
| 55 |
echo "<mod>mode</mod>" |
| 56 |
echo "</f>" |
| 57 |
echo "</pkg-contents>" |