Skip to content

Commit

Permalink
added volume mounting
Browse files Browse the repository at this point in the history
  • Loading branch information
viktor-ribchev committed Nov 8, 2023
1 parent 81d9811 commit 718dfcd
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions modules/vm/templates/entrypoint.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ until ping -c 1 google.com &> /dev/null; do
sleep 5
done

# TODO: Find/create/mount volumes
# https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/tutorial-use-disks-cli
# Find/create/attach volumes

instanceHostname=\'$(hostname)\'
subscriptionID=$(az account show --query "id" --output tsv)
Expand All @@ -21,10 +20,10 @@ vmssName=$(az vmss list --query "[0].name" --output tsv)
instanceID=$(az vmss list-instances --resource-group $resourceGroup --name $vmssName --query "[?contains(osProfile.computerName, ${instanceHostname})].instanceId" --output tsv)
zoneID=$(az vmss list-instances --resource-group $resourceGroup --name $vmssName --query "[?contains(osProfile.computerName, ${instanceHostname})].zones" --output tsv)
regionID=$(az vmss list-instances --resource-group $resourceGroup --name $vmssName --query "[?contains(osProfile.computerName, ${instanceHostname})].location" --output tsv)

# TODO replace with external variables
tier="P40"
lun=2
lun=2 # device will be mounted as sdb
graphdb_device="/dev/sdb"
diskSizeGB=128

# Define the disk name based on the hostname
Expand Down Expand Up @@ -61,6 +60,34 @@ else
echo "Device /dev/sdb is not available. Something went wrong."
fi

# create a file system if there isn't any
if [ "$graphdb_device: data" = "$(file -s $graphdb_device)" ]; then
mkfs -t ext4 $graphdb_device
fi

disk_mount_point="/var/opt/graphdb"

# Check if the disk is already mounted
if ! mount | grep -q "$graphdb_device"; then
echo "The disk at $graphdb_device is not mounted."

# Create the mount point if it doesn't exist
if [ ! -d "$disk_mount_point" ]; then
mkdir -p "$disk_mount_point"
fi

# Add an entry to the fstab file to automatically mount the disk
if ! grep -q "$graphdb_device" /etc/fstab; then
echo "$graphdb_device $disk_mount_point ext4 defaults 0 2" >> /etc/fstab
fi

# Mount the disk
mount "$disk_mount_point"
echo "The disk at $graphdb_device is now mounted at $disk_mount_point."
else
echo "The disk at $graphdb_device is already mounted."
fi

#
# DNS hack
#
Expand Down

0 comments on commit 718dfcd

Please sign in to comment.