I've been working a bash script to automate the process of opening and closing an LVM over LUKS external hard drive. However I continue to receive errors on line 28:
$(vgchange -a n ; cryptsetup luksClose vol)
The error I receive:
$ sudo ./encryption.sh -l Locking System.............. ./encryption.sh: line 28: 0: command not found System Locked!
Here is the rest of the code for reference:
if [ $1 = -u ] ; then $(cryptsetup luksOpen /dev/sdb2 vol) echo "Unlocking.................." | pv -qL 10 $(mount /dev/mapper/vol-lvroot /mnt ; mount /dev/mapper/vol-lvvar /mnt/var ; mount /dev/mapper/vol-lvhome /mnt/home ; mount /dev/sdb1 /mnt/boot) echo "System Mounted!" | pv -qL 10 # exit 0 fi if [ $1 = -l ] ; then $(umount /mnt/var ; umount /mnt/home ; umount /mnt/boot ; umount /mnt/) echo "Locking System.............." | pv -qL 10 $(vgchange -a n ; cryptsetup luksClose vol) echo "System Locked!" | pv -qL 10 exit 0 fi
I receive no apparent error when running the command in question by itself interactively.
I'm new to writing bash, so any recommendations and constructive criticism is appreciated.
The process appears to complete successfully, but I don't understand the error or how to make them go away.
Upon further research when running the troubled code alone in interactive mode it does provide output after being executed.
This is given after posting the troubled code interactively.
0 logical volume(s) in volume group "vol" now active