Skip to content

Commit

Permalink
customize script for OS type (#14)
Browse files Browse the repository at this point in the history
Signed-off-by: Sheetal Pamecha <[email protected]>
  • Loading branch information
Sheetalpamecha authored Aug 12, 2024
1 parent c358955 commit 193e20a
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions hack/check-drenv-prereqs.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
#!/bin/bash
set -e

if ! groups "$USER" | grep -qw libvirt; then
echo "Error: User is not part of the libvirt group."
exit 1
os=$(uname -s)

if [[ "$os" == "Linux" ]]
then
if ! groups "$USER" | grep -qw libvirt; then
echo "Error: User is not part of the libvirt group."
exit 1
fi
fi

commands=("minikube" "kubectl" "clusteradm" "subctl" "velero" "helm" "virtctl"
"virt-host-validate" "kustomize" "mc")
"kustomize" "mc")

linux_only_commands=("virt-host-validate")

for cmd in "${commands[@]}"; do
if ! command -v "$cmd" &> /dev/null; then
Expand All @@ -16,9 +23,21 @@ for cmd in "${commands[@]}"; do
fi
done

if ! virt-host-validate qemu -q; then
echo "Error: 'virt-host-validate qemu' did not return 0."
exit 1
if [[ "$os" == "Linux" ]]
then
for cmd in "${linux_only_commands[@]}"; do
if ! command -v "$cmd" &> /dev/null; then
echo "Error: $cmd could not be found in PATH."
exit 1
fi
done
fi
if [[ "$os" == "Linux" ]]
then
if ! virt-host-validate qemu -q; then
echo "Error: 'virt-host-validate qemu' did not return 0."
exit 1
fi
fi

echo "All prerequisites met for drenv"

0 comments on commit 193e20a

Please sign in to comment.