I have a File under Linux /tmp/volume.log and the content is:
[id:1091666, name:root, deviceName:/dev/sda, maxStorage:107374182400, unitNumber:0, displayOrder:0, rootVolume:true],[id:1091851, name:/var/log/devops|40GB;/home/devops|150GB, deviceName:/dev/sdb, maxStorage:289910292480, unitNumber:1, displayOrder:1, rootVolume:false]],
It will be in single line. This file is generated by some other script.
My Aim is to find the non-root volume disk and parse it to LVM Commands as Variable to extend or create new volumes, at the time of OS Build.
In the above Example.
There are two disks, 1 - sda which is root disk, (if rootVolume is true it is root disk) 2 - sdb which is non root disk (if rootVolume is false it is non root disk)
I have to grep only
rootVolume=false
and grep then
deviceName:/dev/sdb
followed by:
name:/var/log/devops|40GB;/home/devops|150GB
Once I parse all the above in to Variables, I can call those variables in the Commands like
#!/bin/bash
Disk_name=/dev/sdb
Size_Value=40G
LV_name=var_log_devops
Mount_Point=/var/log/devops
sudo pvcreate $Disk_name
sudo vgcreate vgrp01 $Disk_name
sudo lvcreate -L $Size_Value -n $var_log_devops vgrp01
sudo mkfs.xfs $var_log_devops
sudo mkdir -p $/var/log/devops
sudo mount $var_log_devops $/var/log/devops
Right now I am struck with, Extracting the Values from the Text file, becasue they are in single line and multiple Delimiters are present.