ambevar-dotfiles/.scripts/sanitize

23 lines
454 B
Plaintext
Raw Normal View History

#!/bin/sh
2013-06-25 22:56:10 +02:00
if [ $# -eq 0 ] || [ "$1" = "-h" ]; then
cat <<EOF
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.
2013-06-25 22:56:10 +02:00
EOF
exit
2013-06-25 22:56:10 +02:00
fi
FMASK=$(umask -S | sed 's/x//g')
DMASK=$(umask -S)
[ -z "$UID" ] && UID=$(id -u)
[ -z "$GID" ] && GID=$(id -g)
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