You are not logged in.
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
Other information:
1. I receive no apparent error when running the command in question by itself interactively. However running the troubled code interactively does provide this output:
0 logical volume(s) in volume group "vol" now active
2. I'm new to writing bash, so any recommendations and constructive criticism is appreciated.
3. The process appears to complete successfully, but I don't understand the error or how to make them go away.
Offline
Your problems are self-inflicted from wrapping commands arbitrarily in $(). Don't do that.
http://mywiki.wooledge.org/CommandSubstitution
Last edited by falconindy (2014-11-13 14:11:04)
Offline
Your problems are self-inflicted from wrapping commands arbitrarily in $(). Don't do that.
Thanks
Offline