From a28026bf598dda7679ae55fc442b4dc9750c8797 Mon Sep 17 00:00:00 2001 From: Justin Shepherd Date: Wed, 6 Sep 2017 14:34:11 -0500 Subject: [PATCH] Adding guards around tracepath/tracepath6 commands The scripts-library.sh file is calling commands without testing if they exist first. This change adds guards to prevent a non-existant binary from being called. Change-Id: I94df013d17722e218771b90ffe5a8f990bcdea57 --- scripts/scripts-library.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/scripts-library.sh b/scripts/scripts-library.sh index 5d54915591..7152b20194 100755 --- a/scripts/scripts-library.sh +++ b/scripts/scripts-library.sh @@ -186,10 +186,14 @@ function get_instance_info { systemd-resolve --statistics && \ cat /etc/systemd/resolved.conf) > \ "/openstack/log/instance-info/host_dns_info_${TS}.log" || true - { tracepath "8.8.8.8" -m 5 2>/dev/null || tracepath "8.8.8.8"; } > \ - "/openstack/log/instance-info/host_tracepath_info_${TS}.log" || true - { tracepath6 "2001:4860:4860::8888" -m 5 2>/dev/null || tracepath6 "2001:4860:4860::8888"; } >> \ - "/openstack/log/instance-info/host_tracepath_info_${TS}.log" || true + if [ "$(which tracepath)" ]; then + { tracepath "8.8.8.8" -m 5 2>/dev/null || tracepath "8.8.8.8"; } > \ + "/openstack/log/instance-info/host_tracepath_info_${TS}.log" || true + fi + if [ "$(which tracepath6)" ]; then + { tracepath6 "2001:4860:4860::8888" -m 5 2>/dev/null || tracepath6 "2001:4860:4860::8888"; } >> \ + "/openstack/log/instance-info/host_tracepath_info_${TS}.log" || true + fi if [ "$(which lxc-ls)" ]; then lxc-ls --fancy > \ "/openstack/log/instance-info/host_lxc_container_info_${TS}.log" || true