forked from Stichting-MINIX-Research-Foundation/minix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmtree.sh
More file actions
executable file
·33 lines (31 loc) · 734 Bytes
/
Copy pathmtree.sh
File metadata and controls
executable file
·33 lines (31 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
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
targetdev="`stat -f %d $dir/.`"
if [ $targetdev -lt 256 ]
then echo "skipping non-dev $dir properties"
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
done