Skip to content

Instantly share code, notes, and snippets.

@xupyprmv
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save xupyprmv/9322394 to your computer and use it in GitHub Desktop.

Select an option

Save xupyprmv/9322394 to your computer and use it in GitHub Desktop.
Automount a nonempty directory from /etc/fstab (bash, checked on Ubuntu 12.04)
#!/bin/sh
# Check parameter
if [ $# -eq 0 ]
then
echo "No argument specified. Right syntax is: automount.sh MOUNTPATH"
exit 1
else
# Check fstab contains directory
if [cat /etc/fstab/ | grep $1]
then
# Check directory already mapped
if [ mountpoint -q $1 ]
then
echo "123"
mount $1
fi
else
echo "/etc/fstab not contains $1 directory"
exit 1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment