ajout de ufixmod pour corriger les autorisations
This commit is contained in:
parent
d28559ba2b
commit
4e26544371
|
@ -0,0 +1,53 @@
|
|||
#!/bin/bash
|
||||
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
||||
source "$(dirname "$0")/lib/ulib/ulib" || exit 1
|
||||
urequire DEFAULTS
|
||||
|
||||
function display_help() {
|
||||
uecho "$scriptname: forcer le mode d'une liste de fichiers
|
||||
|
||||
USAGE
|
||||
$scriptname [options] [dirs|files....]
|
||||
|
||||
Le mode forcé pour les répertoires est rwxr-xr-x
|
||||
Le mode forcé pour les fichiers est rw-r--r--
|
||||
|
||||
OPTIONS
|
||||
-x, --executable
|
||||
Forcer le mode rwX-r-Xr-X pour les fichiers"
|
||||
}
|
||||
|
||||
executable=
|
||||
parse_opts "${PRETTYOPTS[@]}" \
|
||||
--help '$exit_with display_help' \
|
||||
-x,--executable executable=1 \
|
||||
@ args -- "$@" && set -- "${args[@]}" || die "$args"
|
||||
|
||||
[ $# -gt 0 ] || set -- .
|
||||
|
||||
dmode=755
|
||||
if [ -n "$executable" ]; then
|
||||
fmode=u=rwX,g=rX,o=rX
|
||||
else
|
||||
fmode=644
|
||||
fi
|
||||
|
||||
r=0
|
||||
for i in "$@"; do
|
||||
if [ -d "$i" ]; then
|
||||
etitle "$i"
|
||||
estep "correction répertoires"
|
||||
find "$i" -type d -print -exec chmod "$dmode" {} \; || r=$?
|
||||
estep "correction fichiers"
|
||||
find "$i" -type f -print -exec chmod "$fmode" {} \; || r=$?
|
||||
eend
|
||||
elif [ -f "$i" ]; then
|
||||
estep "$i"
|
||||
chmod "$fmode" "$i" || r=$?
|
||||
else
|
||||
eerror "$i: fichier introuvable"
|
||||
r=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit $r
|
Loading…
Reference in New Issue