Last active
August 29, 2015 13:56
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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