I need to insert on some service scripts a condition on the top to check whether a device is mounted or not.
I'm not very familiar with bash script...
This is a first try I wrote but it doesn't work.
### START CHECK
volume="/media/MyMountName"
if ! mount | grep "on ${volume} type" > /dev/null
then
exit;
fi
### END CHECK
#... rest of the service script
This is another solution I'd like best:
### START CHECK
volume="/media/MyMountName"
delay=5
while ! mount | grep "on ${volume} type" > /dev/null
do
sleep $delay
if delay >= 60
then
exit;
$delay = $dealy + 5
done
### END CHECK
#... rest of the service script
The second one should try to check the mount for a minute before giving up and exit without running the service.