From 95b7157b0baaf780da24eeb76150547868166eae Mon Sep 17 00:00:00 2001 From: Fergus Yu Date: Mon, 8 May 2017 18:10:36 +0800 Subject: [PATCH] Do not use those commands when they are not exist. Sometimes we may get these errors: scripts/scripts-library.sh: line 199: lxc-ls: command not found scripts/scripts-library.sh: line 201: lxc-checkconfig: command not found scripts/scripts-library.sh: line 209: ansible: command not found There is no need to use them since they may not be installed yet. Change-Id: I5e78bf39df0b8b7095cd6f9e0ce14a3adc39df66 --- scripts/scripts-library.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/scripts-library.sh b/scripts/scripts-library.sh index 68ff703854..1c970995bf 100755 --- a/scripts/scripts-library.sh +++ b/scripts/scripts-library.sh @@ -196,15 +196,21 @@ function get_instance_info { "/openstack/log/instance-info/host_tracepath_info_${TS}.log" || true tracepath6 "2001:4860:4860::8888" -m 5 >> \ "/openstack/log/instance-info/host_tracepath_info_${TS}.log" || true - lxc-ls --fancy > \ - "/openstack/log/instance-info/host_lxc_container_info_${TS}.log" || true - lxc-checkconfig > \ - "/openstack/log/instance-info/host_lxc_config_info_${TS}.log" || true + if [ "$(which lxc-ls)" ]; then + lxc-ls --fancy > \ + "/openstack/log/instance-info/host_lxc_container_info_${TS}.log" || true + fi + if [ "$(which lxc-checkconfig)" ]; then + lxc-checkconfig > \ + "/openstack/log/instance-info/host_lxc_config_info_${TS}.log" || true + fi (iptables -vnL && iptables -t nat -vnL && iptables -t mangle -vnL) > \ "/openstack/log/instance-info/host_firewall_info_${TS}.log" || true - ANSIBLE_HOST_KEY_CHECKING=False \ - ansible -i "localhost," localhost -m setup > \ - "/openstack/log/instance-info/host_system_info_${TS}.log" || true + if [ "$(which ansible)" ]; then + ANSIBLE_HOST_KEY_CHECKING=False \ + ansible -i "localhost," localhost -m setup > \ + "/openstack/log/instance-info/host_system_info_${TS}.log" || true + fi get_repos_info > \ "/openstack/log/instance-info/host_repo_info_${TS}.log" || true