diff --git a/cluster/providers/ova/setup.sh b/cluster/providers/ova/setup.sh index f4a4d44..d4683d2 100755 --- a/cluster/providers/ova/setup.sh +++ b/cluster/providers/ova/setup.sh @@ -5,14 +5,10 @@ set -ex [ -z "${NFS_IP_ADDRESS}" ] && { echo "Provider cannot be installed - NFS_IP_ADDRESS env required" ; return 2 ;} [ -z "${NFS_SHARE}" ] && { echo "Provider cannot be installed - NFS_SHARE env required" ; return 2 ;} -nfs_mount_point="/tmp/ova" +# Create a temporary directory for the NFS mount point +nfs_mount_point=$(mktemp -d) ova_file_url="https://github.com/kubev2v/forkliftci/releases/download/v9.0/vm.ova" -# Check if the mount point exists, and if not, create it -if [ ! -d "$nfs_mount_point" ]; then - mkdir -p "$nfs_mount_point" -fi - # Mount the NFS share and check if the mount was successful sudo mount -t nfs "$NFS_IP_ADDRESS:$NFS_SHARE" "$nfs_mount_point" if [ $? -eq 0 ]; then @@ -22,9 +18,8 @@ else exit 1 fi - -# Downloaded the file and check if the copy was successful -echo "Starting to download OVA file." +# Download the file and check if the copy was successful +echo "The VM ova file download started." sudo wget -P "$nfs_mount_point" "$ova_file_url" if [ $? -eq 0 ]; then echo "OVA file copied successfully to NFS share." @@ -35,5 +30,8 @@ fi # Unmount the NFS share sudo umount "$nfs_mount_point" -# deploy csi-driver-nfs -cluster/providers/utils/deploy_csi_driver_nfs.sh "${NFS_IP_ADDRESS}" "${NFS_SHARE}" +# Remove the temporary directory +rm -rf "$nfs_mount_point" + +# Deploy csi-driver-nfs +kubectl get StorageClass nfs-csi 2>/dev/null || cluster/providers/utils/deploy_csi_driver_nfs.sh "${NFS_IP_ADDRESS}" "${NFS_SHARE}"