From 2856684e51a30ec78fe245bc3786b1a783c39541 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 22 Jun 2012 09:30:47 +0200 Subject: [PATCH 1/2] ignore errors in global explorers Signed-off-by: Steven Armstrong --- conf/explorer/hostname | 5 ++++- conf/explorer/interfaces | 5 +++++ conf/explorer/machine | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/conf/explorer/hostname b/conf/explorer/hostname index a3ae4e15..429a5077 100755 --- a/conf/explorer/hostname +++ b/conf/explorer/hostname @@ -1,6 +1,7 @@ #!/bin/sh # # 2010-2011 Nico Schottelius (nico-cdist at schottelius.org) +# 2012 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -19,4 +20,6 @@ # # -hostname +if which hostname >/dev/null 2>&1; then + hostname +fi diff --git a/conf/explorer/interfaces b/conf/explorer/interfaces index 76ff32bb..5333b408 100755 --- a/conf/explorer/interfaces +++ b/conf/explorer/interfaces @@ -29,6 +29,11 @@ if which ip >/dev/null 2>&1; then exit 0 fi +if ! which ifconfig >/dev/null 2>&1; then + # no ifconfig, nothing we could do + exit 0 +fi + uname_s="$(uname -s)" REGEXP='s/^(.*)(:[[:space:]]*flags=|Link encap).*/\1/p' diff --git a/conf/explorer/machine b/conf/explorer/machine index 25fc76a9..d295c8e0 100755 --- a/conf/explorer/machine +++ b/conf/explorer/machine @@ -22,4 +22,6 @@ # # -uname -m +if which uname >/dev/null 2>&1; then + uname -m +fi From d13a201cd092b5eb078988d53224a8ec52d4152b Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Mon, 25 Jun 2012 20:19:10 +0200 Subject: [PATCH 2/2] /which/command -v/ Signed-off-by: Steven Armstrong --- conf/explorer/hostname | 2 +- conf/explorer/interfaces | 4 ++-- conf/explorer/lsb_codename | 2 +- conf/explorer/lsb_description | 2 +- conf/explorer/lsb_id | 2 +- conf/explorer/lsb_release | 2 +- conf/explorer/machine | 2 +- conf/explorer/runlevel | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/conf/explorer/hostname b/conf/explorer/hostname index 429a5077..2ae23759 100755 --- a/conf/explorer/hostname +++ b/conf/explorer/hostname @@ -20,6 +20,6 @@ # # -if which hostname >/dev/null 2>&1; then +if command -v hostname; then hostname fi diff --git a/conf/explorer/interfaces b/conf/explorer/interfaces index 5333b408..6804f2db 100755 --- a/conf/explorer/interfaces +++ b/conf/explorer/interfaces @@ -24,12 +24,12 @@ # # Use ip, if available -if which ip >/dev/null 2>&1; then +if command -v ip; then ip -o link show | sed -n 's/^[0-9]\+: \(.\+\): <.*/\1/p' exit 0 fi -if ! which ifconfig >/dev/null 2>&1; then +if ! command -v ifconfig; then # no ifconfig, nothing we could do exit 0 fi diff --git a/conf/explorer/lsb_codename b/conf/explorer/lsb_codename index 22b6d51e..eebd3e0f 100755 --- a/conf/explorer/lsb_codename +++ b/conf/explorer/lsb_codename @@ -25,7 +25,7 @@ case "$($__explorer/os)" in (. /etc/openwrt_release && echo "$DISTRIB_CODENAME") ;; *) - lsb_release=$(which lsb_release 2>/dev/null) + lsb_release=$(command -v lsb_release) if [ -x "$lsb_release" ]; then $lsb_release --short --codename fi diff --git a/conf/explorer/lsb_description b/conf/explorer/lsb_description index 48aff30d..23f45421 100755 --- a/conf/explorer/lsb_description +++ b/conf/explorer/lsb_description @@ -25,7 +25,7 @@ case "$($__explorer/os)" in (. /etc/openwrt_release && echo "$DISTRIB_DESCRIPTION") ;; *) - lsb_release=$(which lsb_release 2>/dev/null) + lsb_release=$(command -v lsb_release) if [ -x "$lsb_release" ]; then $lsb_release --short --description fi diff --git a/conf/explorer/lsb_id b/conf/explorer/lsb_id index 0dd0f9f4..9754eb63 100755 --- a/conf/explorer/lsb_id +++ b/conf/explorer/lsb_id @@ -25,7 +25,7 @@ case "$($__explorer/os)" in (. /etc/openwrt_release && echo "$DISTRIB_ID") ;; *) - lsb_release=$(which lsb_release 2>/dev/null) + lsb_release=$(command -v lsb_release) if [ -x "$lsb_release" ]; then $lsb_release --short --id fi diff --git a/conf/explorer/lsb_release b/conf/explorer/lsb_release index 8266171a..35b5547c 100755 --- a/conf/explorer/lsb_release +++ b/conf/explorer/lsb_release @@ -25,7 +25,7 @@ case "$($__explorer/os)" in (. /etc/openwrt_release && echo "$DISTRIB_RELEASE") ;; *) - lsb_release=$(which lsb_release 2>/dev/null) + lsb_release=$(command -v lsb_release) if [ -x "$lsb_release" ]; then $lsb_release --short --release fi diff --git a/conf/explorer/machine b/conf/explorer/machine index d295c8e0..bb6e0beb 100755 --- a/conf/explorer/machine +++ b/conf/explorer/machine @@ -22,6 +22,6 @@ # # -if which uname >/dev/null 2>&1; then +if command -v uname; then uname -m fi diff --git a/conf/explorer/runlevel b/conf/explorer/runlevel index 7cdd81ef..02d3a245 100755 --- a/conf/explorer/runlevel +++ b/conf/explorer/runlevel @@ -20,7 +20,7 @@ # set +e -executable=$(which runlevel 2>/dev/null) +executable=$(command -v runlevel) if [ -x "$executable" ]; then "$executable" | awk '{ print $2 }' fi