From: Nicolas Boisselier Date: Tue, 19 Dec 2017 05:01:09 +0000 (+0000) Subject: etc/profile.d/ldap.sh X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=4a724aee0cb4c8624cba6a92b31aef3b8d5cf0e0;p=nb.git etc/profile.d/ldap.sh --- diff --git a/etc/profile.d/ldap.sh b/etc/profile.d/ldap.sh index 9404cb84..194ba8aa 100644 --- a/etc/profile.d/ldap.sh +++ b/etc/profile.d/ldap.sh @@ -86,9 +86,10 @@ ldapsearch_csv() { } ldap_gup_dir() { - local dir="$1" && shift - cd "$dir" || return - local perm=$(ls -dlaF --color=auto . 2>/dev/null | awk '{print $3"."$4}') + local usage="Usage: ldap_gup_dir [DIR|-tar]" + local dir="${1:?$usage}" && shift + #cd "$dir" || return + local perm=$(ls -dlaF --color=auto "$dir" 2>/dev/null | awk '{print $3"."$4}') local tmp=`mktemp -d` eval ' ldap_gup $@ | while IFS=: read -r -a rec; do @@ -102,8 +103,12 @@ ldap_gup_dir() { ( [ -n "$perm" ] && chown "$perm" "$tmp"/* chmod 640 "$tmp"/* - mv "$tmp"/* ./ - ) 2>&1 | true + if [ "$dir" = "-tar" ]; then + cd "$tmp" && tar cvf - * | cat + else + mv "$tmp"/* "$dir/" + fi + ) 2>/dev/null rm -rf "$tmp" }