[__git]: Fix explorers on *BSD

stat's implementation differs between BSD and GNU/Linux Operating Systems.
Tested on FreeBSD, manual-compatibility was asserted for OpenBSD and NetBSD.
This commit is contained in:
evilham 2020-06-17 22:17:27 +02:00
parent a6543a72ad
commit d59e2c6440
2 changed files with 22 additions and 2 deletions

10
cdist/conf/type/__git/explorer/group Normal file → Executable file
View file

@ -2,4 +2,14 @@
destination="/$__object_id/.git" destination="/$__object_id/.git"
os="$(cat "$__global/explorer/os")"
case $os in
*bsd)
# Checked on OpenBSD, FreeBSD and NetBSD
stat -f "%Sg" "${destination}" 2>/dev/null || exit 0
;;
*)
stat --print "%G" "${destination}" 2>/dev/null || exit 0 stat --print "%G" "${destination}" 2>/dev/null || exit 0
;;
esac

10
cdist/conf/type/__git/explorer/owner Normal file → Executable file
View file

@ -2,4 +2,14 @@
destination="/$__object_id/.git" destination="/$__object_id/.git"
os="$(cat "$__global/explorer/os")"
case $os in
*bsd)
# Checked on OpenBSD, FreeBSD and NetBSD
stat -f "%Su" "${destination}" 2>/dev/null || exit 0
;;
*)
stat --print "%U" "${destination}" 2>/dev/null || exit 0 stat --print "%U" "${destination}" 2>/dev/null || exit 0
;;
esac