2013-03-03 11:19:50 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2013-06-25 22:56:10 +02:00
|
|
|
if [ $# -eq 0 ] || [ "$1" = "-h" ]; then
|
|
|
|
cat <<EOF
|
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
|
|
|
|
used.
|
|
|
|
EOF
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
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
|
|
|
|
find "$i" -exec chown -R ${UID}:${GID} {} \;
|
|
|
|
find "$i" -type d -exec chmod ${DMASK} {} \;
|
|
|
|
find "$i" -type f -exec chmod ${FMASK} {} \;
|
|
|
|
done
|