2013-03-03 11:19:50 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2016-10-12 09:16:48 +02:00
|
|
|
usage () {
|
|
|
|
cat <<EOF>&2
|
2013-10-23 12:49:44 +02:00
|
|
|
Usage: ${0##*/} FOLDERS
|
2013-06-25 22:56:10 +02:00
|
|
|
|
|
|
|
Set file/directory owner and permissions according to current umask for current
|
2014-08-19 11:06:03 +02:00
|
|
|
user.
|
2016-10-12 09:16:48 +02:00
|
|
|
|
2013-06-25 22:56:10 +02:00
|
|
|
EOF
|
2016-10-12 09:16:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[ $# -eq 0 ] && usage && exit 1
|
|
|
|
[ "$1" = "-h" ] && usage && exit
|
|
|
|
[ "$1" = "--" ] && shift
|
2013-06-25 22:56:10 +02:00
|
|
|
|
2013-03-03 11:19:50 +01:00
|
|
|
FMASK=$(umask -S | sed 's/x//g')
|
|
|
|
DMASK=$(umask -S)
|
2013-10-23 12:49:44 +02:00
|
|
|
[ -z "$UID" ] && UID=$(id -u)
|
|
|
|
[ -z "$GID" ] && GID=$(id -g)
|
2013-03-03 11:19:50 +01:00
|
|
|
|
2013-10-23 12:49:44 +02:00
|
|
|
for i ; do
|
2016-06-23 23:18:36 +02:00
|
|
|
find "$i" -exec chown -R "$UID:$GID" {} \;
|
|
|
|
find "$i" -type d -exec chmod "$DMASK" {} \;
|
|
|
|
find "$i" -type f -exec chmod "$FMASK" {} \;
|
2013-10-23 12:49:44 +02:00
|
|
|
done
|