From 005c94556e80e1eecc4db15c46d9bee4c2fa71a2 Mon Sep 17 00:00:00 2001 From: Jake Guffey Date: Tue, 19 Feb 2013 15:23:52 -0500 Subject: [PATCH] Fix to support FreeBSD's stat(1) Added check for OS type Added FreeBSD syntax in case of $os=freebsd --- cdist/conf/type/__directory/explorer/group | 14 +++++++++++++- cdist/conf/type/__directory/explorer/mode | 14 +++++++++++++- cdist/conf/type/__directory/explorer/owner | 14 +++++++++++++- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__directory/explorer/group b/cdist/conf/type/__directory/explorer/group index b14794e3..4da5b45d 100644 --- a/cdist/conf/type/__directory/explorer/group +++ b/cdist/conf/type/__directory/explorer/group @@ -22,7 +22,19 @@ # destination="/$__object_id" +# Since $__global isn't available, use uname directly, uname and tr are both part of POSIX +os="$(uname -s | tr '[:upper:]' '[:lower:]')" + +case "$os" in + "freebsd") + cmd="stat -f %Sg" + ;; + *) + cmd="stat -c %G" + ;; +esac if [ -e "$destination" ]; then - stat -c "%G" "$destination" + $cmd "$destination" fi + diff --git a/cdist/conf/type/__directory/explorer/mode b/cdist/conf/type/__directory/explorer/mode index 3ffa497e..1d40c795 100644 --- a/cdist/conf/type/__directory/explorer/mode +++ b/cdist/conf/type/__directory/explorer/mode @@ -22,7 +22,19 @@ # destination="/$__object_id" +# Since $__global isn't available, use uname directly, uname and tr are both part of POSIX +os="$(uname -s | tr '[:upper:]' '[:lower:]')" + +case "$os" in + "freebsd") + cmd="stat -f %Op" + ;; + *) + cmd="stat -c %a" + ;; +esac if [ -e "$destination" ]; then - stat -c "%a" "$destination" + $cmd "$destination" fi + diff --git a/cdist/conf/type/__directory/explorer/owner b/cdist/conf/type/__directory/explorer/owner index a691ac1b..452dc672 100644 --- a/cdist/conf/type/__directory/explorer/owner +++ b/cdist/conf/type/__directory/explorer/owner @@ -22,7 +22,19 @@ # destination="/$__object_id" +# Since $__global isn't available, use uname directly, uname and tr are both part of POSIX +os="$(uname -s | tr '[:upper:]' '[:lower:]')" + +case "$os" in + "freebsd") + cmd="stat -f %Su" + ;; + *) + cmd="stat -c %U" + ;; +esac if [ -e "$destination" ]; then - stat -c "%U" "$destination" + $cmd "$destination" fi +