2005-04-21 16:53:53 +02:00
|
|
|
#!/bin/sh
|
2011-07-03 15:30:54 +02:00
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ $# -ne 1 ]
|
|
|
|
then echo "Usage: $0 mtreefile"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
cat "$1" | while read line
|
|
|
|
do
|
|
|
|
NF="`echo $line | awk '{ print NF }'`"
|
|
|
|
if [ $NF = 4 ]
|
|
|
|
then mode="`echo $line | awk '{ print $1 }'`"
|
|
|
|
owner="`echo $line | awk '{ print $2 }'`"
|
|
|
|
group="`echo $line | awk '{ print $3 }'`"
|
|
|
|
dir="`echo $line | awk '{ print $4 }'`"
|
|
|
|
mkdir -p $dir
|
2011-07-18 15:53:57 +02:00
|
|
|
targetdev="`stat -f %d $dir/.`"
|
2011-08-18 15:05:27 +02:00
|
|
|
if [ $targetdev -lt 256 ]
|
|
|
|
then echo "skipping non-dev $dir properties"
|
2011-07-03 15:30:54 +02:00
|
|
|
else chown $owner $dir
|
|
|
|
chmod $mode $dir
|
|
|
|
chgrp $group $dir
|
|
|
|
fi
|
|
|
|
elif [ $NF = 3 ]
|
|
|
|
then target="`echo $line | awk '{ print $3 }'`"
|
|
|
|
linkfile="`echo $line | awk '{ print $1 }'`"
|
|
|
|
rm -f $linkfile
|
|
|
|
ln -s $target $linkfile
|
|
|
|
else echo odd line.
|
|
|
|
exit 1
|
|
|
|
fi
|
2005-04-21 16:53:53 +02:00
|
|
|
done
|