#!/bin/bash

set -u -e

exist=`which kubectl > /dev/null 2>&1 || echo $?`
if [[ $exist -eq 0 ]]; then
  count=`which kubectl|grep /usr/bin/kubectl|wc -l`
  if [[ $count -gt 0 ]]; then
    exit 1
  fi
fi

exist=`which kubeadm > /dev/null 2>&1 || echo $?`
if [[ $exist -eq 0 ]]; then
  exit 2
fi

exist=`which kubelet > /dev/null 2>&1 || echo $?`
if [[ $exist -eq 0 ]]; then
  exit 3
fi

exist=`which docker > /dev/null 2>&1 || echo $?`
if [[ $exist -eq 0 ]]; then
  count=`which docker|grep /usr/bin/docker|wc -l`
  if [[ $count -gt 0 ]]; then
    exit 4
  fi
fi
