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.

Revisions

  1. xupyprmv renamed this gist Mar 3, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. xupyprmv revised this gist Mar 3, 2014. 1 changed file with 25 additions and 18 deletions.
    43 changes: 25 additions & 18 deletions gistfile1.bat
    Original file line number Diff line number Diff line change
    @@ -1,22 +1,29 @@
    #!/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
    if [ $# -eq 0 ]; then
    echo "No argument specified. Right syntax is: automount.sh MOUNTPATH"
    exit 1
    else
    # Check fstab contains folder
    if cat /etc/fstab | grep $1 > /dev/null; then
    # Check directory already mapped
    if mountpoint $1 | grep 'is not a mountpoint' > /dev/null; then
    # Move content into tmp folder if dir is not empty
    if [ "$(ls -A $1)" ]; then
    TDIR=`mktemp -d`.
    mv "$1"/* $TDIR || exit 1
    # Mount folder
    mount $1 || true
    # Copy content from tmp folder to mounted folder
    mv "$TDIR"/* $1
    else.
    # Just mount folder
    mount $1
    fi
    fi
    else
    echo "/etc/fstab not contains folder $1"
    exit 1
    fi
    fi
  3. xupyprmv revised this gist Mar 3, 2014. 2 changed files with 22 additions and 7 deletions.
    22 changes: 22 additions & 0 deletions gistfile1.bat
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #!/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
    7 changes: 0 additions & 7 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,7 +0,0 @@
    Проверено на Ubuntu 12.04.




    automount.sh
    mountpoint -q /foo/bar || mount -o bind /some/directory/here /foo/bar
  4. xupyprmv created this gist Mar 3, 2014.
    7 changes: 7 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    Проверено на Ubuntu 12.04.




    automount.sh
    mountpoint -q /foo/bar || mount -o bind /some/directory/here /foo/bar