From b55520e9871e3bf2796b775573c5b7c105e0eab8 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 21 Nov 2017 23:32:04 +0100 Subject: [PATCH] Applying uqam-fob's suggestions. --- cdist/conf/explorer/cpu_sockets | 6 +++--- cdist/conf/type/__ccollect_source/manifest | 2 +- cdist/conf/type/__docker_compose/gencode-remote | 4 ++-- cdist/conf/type/__install_reboot/manifest | 2 +- .../conf/type/__package_pkgng_freebsd/explorer/pkg_version | 4 ++-- cdist/conf/type/__rvm/explorer/state | 2 +- cdist/conf/type/__staged_file/gencode-local | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cdist/conf/explorer/cpu_sockets b/cdist/conf/explorer/cpu_sockets index afb7b6b0..1e75182b 100755 --- a/cdist/conf/explorer/cpu_sockets +++ b/cdist/conf/explorer/cpu_sockets @@ -25,14 +25,14 @@ os=$("$__explorer/os") case "$os" in "macosx") - system_profiler SPHardwareDataType | grep "Number of Processors" | awk -F': ' '{print $2}' + system_profiler SPHardwareDataType | grep "Number of Processors" | awk -F ': ' '/Number of Processors/ {print $2}' ;; *) if [ -r /proc/cpuinfo ]; then - sockets="$(grep "physical id" /proc/cpuinfo | sort | uniq | wc -l)" + sockets=$(grep "physical id" /proc/cpuinfo | sort -u | wc -l) if [ "${sockets}" -eq 0 ]; then - sockets="$(grep -c "processor" /proc/cpuinfo)" + sockets=$(grep -cE "^processor\s+:" /proc/cpuinfo) fi echo "${sockets}" fi diff --git a/cdist/conf/type/__ccollect_source/manifest b/cdist/conf/type/__ccollect_source/manifest index 26c6cc99..b3694722 100755 --- a/cdist/conf/type/__ccollect_source/manifest +++ b/cdist/conf/type/__ccollect_source/manifest @@ -22,7 +22,7 @@ name="$__object_id" state="$(cat "$__object/parameter/state")" source="$(cat "$__object/parameter/source")" destination="$(cat "$__object/parameter/destination")" -ccollectconf="$(sed 's,/$,,' "$__object/parameter/ccollectconf")" +ccollectconf="$(sed -E 's,/+$,,' "$__object/parameter/ccollectconf")" sourcedir="$ccollectconf/sources" basedir="$sourcedir/$name" diff --git a/cdist/conf/type/__docker_compose/gencode-remote b/cdist/conf/type/__docker_compose/gencode-remote index 396c93ac..4872d83d 100755 --- a/cdist/conf/type/__docker_compose/gencode-remote +++ b/cdist/conf/type/__docker_compose/gencode-remote @@ -24,8 +24,8 @@ state="$(cat "$__object/parameter/state")" if [ "${state}" = "present" ]; then # Download docker-compose file - echo 'curl -L "https://github.com/docker/compose/releases/download/'"${version}"'/docker-compose-$(uname -s)-$(uname -m)" -o /tmp/docker-compose' - echo 'mv /tmp/docker-compose /usr/local/bin/docker-compose' + echo "curl -L 'https://github.com/docker/compose/releases/download/${version}/docker-compose-$(uname -s)-$(uname -m)' -o /tmp/docker-compose" + echo 'mv /tmp/docker-compose /usr/local/bin/docker-compose' # Change permissions echo 'chmod +x /usr/local/bin/docker-compose' fi diff --git a/cdist/conf/type/__install_reboot/manifest b/cdist/conf/type/__install_reboot/manifest index 86ae797c..6255d525 100755 --- a/cdist/conf/type/__install_reboot/manifest +++ b/cdist/conf/type/__install_reboot/manifest @@ -21,4 +21,4 @@ # set defaults # options="$(cat "$__object/parameter/options" 2>/dev/null \ # || echo "" | tee "$__object/parameter/options")" -cat "$__object/parameter/options" 2>/dev/null 1>/dev/null || echo "" > "$__object/parameter/options" +[ -f "$__object/parameter/options" ] || touch "$__object/parameter/options" diff --git a/cdist/conf/type/__package_pkgng_freebsd/explorer/pkg_version b/cdist/conf/type/__package_pkgng_freebsd/explorer/pkg_version index 92ce0623..9ab32f2e 100755 --- a/cdist/conf/type/__package_pkgng_freebsd/explorer/pkg_version +++ b/cdist/conf/type/__package_pkgng_freebsd/explorer/pkg_version @@ -29,9 +29,9 @@ fi # Don't produce "no pkgs installed" output -- breaks things PKG_OUTPUT=$(pkg info 2>&1) -printf "%s" "$(echo "$PKG_OUTPUT" \ +printf "%s" "$PKG_OUTPUT" \ | awk '{print $1}' \ | sed 's/^\(.*\)-\([^-]*\)$/name:\1 ver:\2/g' \ | grep "name:$name ver:" \ - | sed 's/^.*ver:\(.*\)/\1/g')" + | sed 's/^.*ver:\(.*\)/\1/g' diff --git a/cdist/conf/type/__rvm/explorer/state b/cdist/conf/type/__rvm/explorer/state index 74d17048..67e1c27c 100755 --- a/cdist/conf/type/__rvm/explorer/state +++ b/cdist/conf/type/__rvm/explorer/state @@ -28,7 +28,7 @@ if [ "$user" = "root" ]; then echo absent fi else - if su - "$user" -c "[ -d \"\$HOME/.rvm\" ]" ; then + if su -l "$user" -c "[ -d \"\$HOME/.rvm\" ]" ; then echo "present" else echo "absent" diff --git a/cdist/conf/type/__staged_file/gencode-local b/cdist/conf/type/__staged_file/gencode-local index 255f30ed..b953c40a 100755 --- a/cdist/conf/type/__staged_file/gencode-local +++ b/cdist/conf/type/__staged_file/gencode-local @@ -61,7 +61,7 @@ fetch_file() { } fetch_and_prepare_file() { - printf 'tmpdir="$(TMPDIR="/tmp" mktemp -d "%s")"\n' "${__type##*/}.XXXXXXXXXX" + printf 'tmpdir="$(TMPDIR=${TMPDIR:-/tmp} mktemp -d "%s")"\n' "${__type##*/}.XXXXXXXXXX" printf 'cd "$tmpdir"\n' printf "$fetch_command > \"%s\"\n" "$source" "$source_file_name" prepare_command="$(cat "$__object/parameter/prepare-command")"