-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixperm.sh
executable file
·47 lines (42 loc) · 1.2 KB
/
fixperm.sh
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh
# Change the permissions and extendet file attributes for the given files and
# directories or the current directory. Always work recursivly.
prog=`basename "$0"`
usage () {
echo "Usage: $prog [path ...]"
echo " $prog -h"
}
rm_acl () {
# remove acl entries TODO how to delete all of them?
chmod -RN "$@"
}
chmod_R () {
# set unix file permissions
find "$@" \
\( -type f -exec chmod 600 {} + \) -or \
\( -type d -exec chmod 700 {} + \)
# alternatively
#chmod -R u+rwX,go-rwx "$@"
}
xattr_r () {
# delete apples extendet file attributes
local attributes=
attributes="$attributes com.apple.quarantine"
attributes="$attributes com.apple.FinderInfo"
attributes="$attributes com.apple.metadata:_kTimeMachineNewestSnapshot"
attributes="$attributes com.apple.metadata:_kTimeMachineOldestSnapshot"
for attribute in $attributes; do
xattr -rd $attribute "$@"
done
# alternatively
#xattr -rc "$@"
}
if [ "$1" = -h ]; then
usage
exit
fi
# if no arguments are given work on the current directory
if [ $# -eq 0 ]; then set .; fi
if [ `uname` = Darwin ]; then rm_acl "$@"; fi
chmod_R "$@"
if [ `uname` = Darwin ]; then xattr_r "$@"; fi