Skip to content

Commit

Permalink
Made environment_check.sh POSIX compliant
Browse files Browse the repository at this point in the history
Signed-off-by: Harold Holsappel <h.holsappel@iwink.nl>
Harold Holsappel committed Jan 19, 2023
1 parent 4fa27a3 commit e71e157
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions scripts/environment_check.sh
Original file line number Diff line number Diff line change
@@ -109,9 +109,9 @@ detect_node_os()
{
local pod="$1"

OS=`kubectl exec -i $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c 'grep -E "^ID_LIKE=" /etc/os-release | cut -d= -f2'`
OS=$(kubectl exec -i $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c 'grep -E "^ID_LIKE=" /etc/os-release | cut -d= -f2')
if [[ -z "${OS}" ]]; then
OS=`kubectl exec -i $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c 'grep -E "^ID=" /etc/os-release | cut -d= -f2'`
OS=$(kubectl exec -i $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c 'grep -E "^ID=" /etc/os-release | cut -d= -f2')
fi
echo "$OS"
}
@@ -229,7 +229,7 @@ check_package_installed() {
local all_found=true

for pod in ${pods}; do
OS=`detect_node_os $pod`
OS=$(detect_node_os $pod)
if [ x"$OS" == x"" ]; then
error "Unable to detect OS on node $node."
exit 2
@@ -243,7 +243,7 @@ check_package_installed() {
kubectl exec -i $pod -- nsenter --mount=/proc/1/ns/mnt -- timeout 30 bash -c "$CHECK_CMD $package" > /dev/null 2>&1
if [ $? != 0 ]; then
all_found=false
node=`kubectl get ${pod} --no-headers -o=custom-columns=:.spec.nodeName`
node=$(kubectl get ${pod} --no-headers -o=custom-columns=:.spec.nodeName)
error "$package is not found in $node."
fi
done
@@ -283,7 +283,7 @@ check_multipathd() {
kubectl exec -t $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c "systemctl status --no-pager multipathd.service" > /dev/null 2>&1
if [ $? = 0 ]; then
all_not_found=false
node=`kubectl get ${pod} --no-headers -o=custom-columns=:.spec.nodeName`
node=$(kubectl get ${pod} --no-headers -o=custom-columns=:.spec.nodeName)
warn "multipathd is running on $node."
fi
done
@@ -302,7 +302,7 @@ check_iscsid() {

if [ $? != 0 ]; then
all_found=false
node=`kubectl get ${pod} --no-headers -o=custom-columns=:.spec.nodeName`
node=$(kubectl get ${pod} --no-headers -o=custom-columns=:.spec.nodeName)
error "iscsid is not running on $node."
fi
done
@@ -321,13 +321,13 @@ check_nfs_client_kernel_support() {
declare -A nodes=()

for pod in ${pods}; do
node=`kubectl get ${pod} --no-headers -o=custom-columns=:.spec.nodeName`
res=`kubectl exec -t $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c "grep -E \"^# ${config} is not set\" /boot/config-$(uname -r)" > /dev/null 2>&1`
node=$(kubectl get ${pod} --no-headers -o=custom-columns=:.spec.nodeName)
res=$(kubectl exec -t $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c "grep -E \"^# ${config} is not set\" /boot/config-$(uname -r)" > /dev/null 2>&1)
if [[ $? == 0 ]]; then
all_found=false
nodes["${node}"]="${node}"
else
res=`kubectl exec -t $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c "grep -E \"^${config}=\" /boot/config-$(uname -r)" > /dev/null 2>&1`
res=$(kubectl exec -t $pod -- nsenter --mount=/proc/1/ns/mnt -- bash -c "grep -E \"^${config}=\" /boot/config-$(uname -r)" > /dev/null 2>&1)
if [[ $? != 0 ]]; then
all_found=false
warn "Unable to check kernel config ${config} on node ${node}"

0 comments on commit e71e157

Please sign in to comment.