I have created a script to mount an usb device and cdrom drive automaticly when its plugged in. I had been trying to get this working with autofs (see https://superuser.com/questions/605896/automount-usb-pen-drive-and-cdrom-drive-on-plugin) but now trying to work with a script running at boot.
I think the logic is sound but I get line 13: [: missing ']'
The script is:
#!/bin/bash
while true
do
if [ -b /dev/sda1 ]
then
mkdir /media/usb
mount /dev/sda1 /media/usb
while [ -b /dev/sda1]; do
sleep 2
done
umount /media/usb
rmdir /media/usb
fi
if [ -b /dev/cdrom ]
then
mkdir /media/cdrom
mount /dev/sda1 /media/cdrom
while [ -b /dev/cdrom]; do
sleep 2
done
umount /media/cdrom
rmdir /media/cdrom
fi
sleep 5
done
And then script is launched from rc.local using ./path/to/script&
You need a space here:
while [ -b /dev/cdrom]; do
^
_____________________|
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With