I am new at scripting ... I can do very basic stuff, but now I need a hand.
I have a local filesystem that only will be mounted when I need to do a backup.
I'm starting with this.
#!/bin/bash
export MOUNT=/myfilesystem
if grep -qs $MOUNT /proc/mounts; then
echo "It's mounted."
else
echo "It's not mounted."; then
mount $MOUNT;
fi
As I said, I'm very basic at scripting. I heard that you can check the status of the mount command by looking at the return codes.
RETURN CODES
mount has the following return codes (the bits can be ORed):
0 success
1 incorrect invocation or permissions
2 system error (out of memory, cannot fork, no more loop devices)
4 internal mount bug
8 user interrupt
16 problems writing or locking /etc/mtab
32 mount failure
64 some mount succeeded
I don't know how to check that. Any guidance?
; thenin your script. – Mat May 17 '12 at 16:18