github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/deploy/dev/ansible/setup_storage.sh (about)

     1  #!/bin/bash
     2  
     3  # Check if three arguments are provided
     4  if [ "$#" -ne 3 ]; then
     5    echo "Usage: $0 <string path of base dir> <comma-separated list of device names> <comma-separated list of mountpaths>"
     6    exit 1
     7  fi
     8  
     9  # Assign arguments to variables
    10  base_dir=$1
    11  devices=$2
    12  mountpaths=$3
    13  
    14  # Make directory base_dir
    15  mkdir -p "$base_dir"
    16  echo "Base directory created: $base_dir"
    17  
    18  # Split the comma-separated lists into arrays
    19  IFS=',' read -r -a devices <<< "$devices"
    20  IFS=',' read -r -a mountpaths <<< "$mountpaths"
    21  
    22  # Ensure devices and mountpaths lists are the same length
    23  if [ ${#devices[@]} -ne ${#mountpaths[@]} ]; then
    24    echo "Error: The number of devices and mountpaths should be the same."
    25    exit 1
    26  fi
    27  
    28  for ((i = 0; i < ${#devices[@]}; i++)); do
    29    nested_dir="${base_dir}/${mountpaths[i]}"
    30    mkdir -p "$nested_dir"
    31    echo "Nested directory created: $nested_dir"
    32  
    33    # Mount the device to the corresponding mountpath
    34    sudo mount "${devices[i]}" "$nested_dir"
    35    echo "Device ${devices[i]} mounted to $nested_dir"
    36  done