hey guys, im trying to write a script that gets a .csv file and creates lvm's and mount points , mount the lvm to the mount points and writing into /etc/fstab,
but it seems that the for loop isnt working for me and it prints insted of creating my
variables , can someone give it a look and tell me where are my mistakes?
the .csv file
Code:
ProductsLV, /products
OracleLV, /products/Oracle
PlsqlLV, /products/plsql
my script:
Code:
#!/bin/bash
for i in 'cat list.csv'
do
lv_name1='echo $i | cut -d, -f1 | sed '1!d''
lv_name2='echo $i | cut -d, -f1 | sed '2!d''
lv_name3='echo $i | cut -d, -f1 | sed '3!d''
mount_point1='echo $i | cut -d, -f2 | cut -c 2- | sed '1!d''
mount_point2='echo $i | cut -d, -f2 | cut -c 2- | sed '2!d''
mount_point3='echo $i | cut -d, -f2 | cut -c 2- | sed '3!d''
vg_name='centos'
lvcreate -L 10m -n $lv_name1 $vg_name
lvcreate -L 10m -n $lv_name2 $vg_name
lvcreate -L 10m -n $lv_name3 $vg_name
mkdir -p $mount_point1
mkdir -p $mount_point2
mkdir -p $mount_point3
mount -t ext4 /dev/$vg_name/$lv_name1 $mount_point1
mount -t ext4 /dev/$vg_name/$lv_name2 $mount_point2
mount -t ext4 /dev/$vg_name/$lv_name3 $mount_point3
mount -a
echo "/dev/$vg_name/$lv_name1 $mount_point1 ext4 defaults 0 0">>/etc/fstab
echo "/dev/$vg_name/$lv_name2 $mount_point2 ext4 defaults 0 0">>/etc/fstab
echo "/dev/$vg_name/$lv_name3 $mount_point3 ext4 defaults 0 0">>/etc/fstab
done