diff --git a/run_tests.sh b/run_tests.sh index 1fe763b52b..d80eb04183 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -62,7 +62,7 @@ case ${ID,,} in esac # Install git so that we can clone the tests repo if git is not available -which git &>/dev/null || eval sudo "${pkg_mgr_cmd}" git +command -v git &>/dev/null || eval sudo "${pkg_mgr_cmd}" git # Clone the tests repo for access to the common test script if [[ ! -d "${COMMON_TESTS_PATH}" ]]; then diff --git a/scripts/bootstrap-ansible.sh b/scripts/bootstrap-ansible.sh index 5bc7ce0988..9476b027cc 100755 --- a/scripts/bootstrap-ansible.sh +++ b/scripts/bootstrap-ansible.sh @@ -70,12 +70,12 @@ case ${DISTRO_ID} in case ${DISTRO_VERSION_ID} in 8) dnf -y install python38 python38-devel libselinux-python3 - PYTHON_EXEC_PATH="$(which python3.8)" + PYTHON_EXEC_PATH="$(command -v python3.8)" OSA_ANSIBLE_PYTHON_INTERPRETER="/usr/bin/python3" ;; 9|9.[0-9]*) dnf -y install python3 python3-devel python3-libselinux - PYTHON_EXEC_PATH="$(which python3)" + PYTHON_EXEC_PATH="$(command -v python3)" OSA_ANSIBLE_PYTHON_INTERPRETER="/usr/bin/python3" ;; esac @@ -84,11 +84,11 @@ case ${DISTRO_ID} in case ${DISTRO_VERSION_ID} in 8) dnf -y install python38 python38-devel libselinux-python3 - PYTHON_EXEC_PATH="$(which python3.8)" + PYTHON_EXEC_PATH="$(command -v python3.8)" ;; 9) dnf -y install python3 python3-devel libselinux-python3 - PYTHON_EXEC_PATH="$(which python3)" + PYTHON_EXEC_PATH="$(command -v python3)" ;; esac ;; diff --git a/scripts/gate-check-commit.sh b/scripts/gate-check-commit.sh index f29713996b..f457a1ffd0 100755 --- a/scripts/gate-check-commit.sh +++ b/scripts/gate-check-commit.sh @@ -92,7 +92,7 @@ if [[ -z "${SKIP_OSA_BOOTSTRAP_AIO+defined}" ]]; then fi # Flush all the iptables rules set by openstack-infra -if which iptables; then +if command -v iptables; then iptables -F iptables -X iptables -t nat -F diff --git a/scripts/log-collect.sh b/scripts/log-collect.sh index 1b766fe8ee..15720aa1b0 100755 --- a/scripts/log-collect.sh +++ b/scripts/log-collect.sh @@ -84,12 +84,12 @@ function repo_information { [[ "${1}" != "host" ]] && lxc_cmd="lxc-attach --name ${1} --" || lxc_cmd="" echo "Collecting list of installed packages and enabled repositories for \"${1}\"" # Redhat package debugging - if eval sudo ${lxc_cmd} which dnf &>/dev/null; then + if eval sudo ${lxc_cmd} command -v dnf &>/dev/null; then eval sudo ${lxc_cmd} dnf repolist -v > "${WORKING_DIR}/logs/redhat-rpm-repolist-${1}-${TS}.txt" || true eval sudo ${lxc_cmd} dnf list installed > "${WORKING_DIR}/logs/redhat-rpm-list-installed-${1}-${TS}.txt" || true # Ubuntu package debugging - elif eval sudo ${lxc_cmd} which apt-get &> /dev/null; then + elif eval sudo ${lxc_cmd} command -v apt-get &> /dev/null; then eval sudo ${lxc_cmd} apt-cache policy | grep http | awk '{print $1" "$2" "$3}' | sort -u > "${WORKING_DIR}/logs/ubuntu-apt-repolist-${1}-${TS}.txt" || true eval sudo ${lxc_cmd} apt list --installed > "${WORKING_DIR}/logs/ubuntu-apt-list-installed-${1}-${TS}.txt" || true fi @@ -171,7 +171,7 @@ done # Gather container etc artifacts -if which lxc-ls &> /dev/null; then +if command -v lxc-ls &> /dev/null; then for CONTAINER_NAME in $(sudo lxc-ls -1); do CONTAINER_PID=$(sudo lxc-info -p -n ${CONTAINER_NAME} | awk '{print $2}') ETC_DIR="/proc/${CONTAINER_PID}/root/etc" @@ -213,7 +213,7 @@ env > "${WORKING_DIR}/logs/environment-${TS}.txt" || true repo_information host # Record the active interface configs -if which ethtool &> /dev/null; then +if command -v ethtool &> /dev/null; then for interface in $(ip -o link | awk -F':' '{print $2}' | sed 's/@.*//g'); do echo "ethtool -k ${interface}" ethtool -k ${interface} > "${WORKING_DIR}/logs/ethtool-${interface}-${TS}-cfg.txt" || true diff --git a/scripts/scripts-library.sh b/scripts/scripts-library.sh index 81ba8c48cf..a7b66abd52 100755 --- a/scripts/scripts-library.sh +++ b/scripts/scripts-library.sh @@ -281,27 +281,27 @@ function get_repos_info { function get_instance_info { TS="$(date +"%H-%M-%S")" (cat /etc/resolv.conf && \ - which systemd-resolve &> /dev/null && \ + command -v systemd-resolve &> /dev/null && \ systemd-resolve --statistics && \ cat /etc/systemd/resolved.conf) > \ "/openstack/log/instance-info/host_dns_info_${TS}.log" || true - if [ "$(which tracepath)" ]; then + if [ "$(command -v 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 + if [ "$(command -v 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 + if [ "$(command -v lxc-ls)" ]; then lxc-ls --fancy > \ "/openstack/log/instance-info/host_lxc_container_info_${TS}.log" || true fi - if [ "$(which lxc-checkconfig)" ]; then + if [ "$(command -v lxc-checkconfig)" ]; then lxc-checkconfig > \ "/openstack/log/instance-info/host_lxc_config_info_${TS}.log" || true fi - if [ "$(which networkctl)" ]; then + if [ "$(command -v networkctl)" ]; then networkctl list > \ "/openstack/log/instance-info/host_networkd_list_${TS}.log" || true networkctl status >> \ @@ -309,11 +309,11 @@ function get_instance_info { networkctl lldp >> \ "/openstack/log/instance-info/host_networkd_lldp_${TS}.log" || true fi - if [ "$(which iptables)" ]; then + if [ "$(command -v iptables)" ]; then (iptables -vnL && iptables -t nat -vnL && iptables -t mangle -vnL) > \ "/openstack/log/instance-info/host_firewall_info_${TS}.log" || true fi - if [ "$(which ansible)" ]; then + if [ "$(command -v ansible)" ]; then ANSIBLE_HOST_KEY_CHECKING=False \ ansible -i "localhost," localhost -m setup > \ "/openstack/log/instance-info/host_system_info_${TS}.log" || true @@ -338,7 +338,7 @@ function get_instance_info { # Storage reports for dir_name in lxc machines; do - if [ "$(which btrfs)" ]; then + if [ "$(command -v btrfs)" ]; then btrfs filesystem usage /var/lib/${dir_name} 2>/dev/null > \ "/openstack/log/instance-info/btrfs_${dir_name}_usage_${TS}.log" || true btrfs filesystem show /var/lib/${dir_name} 2>/dev/null > \ @@ -350,7 +350,7 @@ function get_instance_info { fi done - if [ "$(which zfs)" ]; then + if [ "$(command -v zfs)" ]; then zfs list > "/openstack/log/instance-info/zfs_lxc_${TS}.log" || true fi