On 7/31/13, Pol Hallen <de...@fuckaround.org> wrote: >> if mountpoint -q $SECURE_MOUNTPOINT ;then >> exec $PROGRAM >> fi > > Cool! Very thanks! :-)
In my local bash library, I have the following function, which shows the various iterations and tests I have used over the last few years: isMounted () { # make sure a target/ arg is passed in: [ -z "$1" ] && return 1 # turn target into fully qualified filename/ location # (not doing so can cause problems with some of the tests I've tried, # eg perhaps the one currently used see below): DIR=`readlink -f "$1"` # Option 1, from: http://arstechnica.com/civis//viewtopic.php?f=16&t=1174539 #grep -q "$DIR" /proc/mounts #[ $? -eq 0 ] && return 0 # Alternatively: "return $?", I guess # or alt alternative, make sure no other commands like echo follow :) # # From url: "For more robust bash scripting, using $? is preferred as it # allows you to detect extra error conditions (like the command not # existing, or you gave it syntactically invalid arguments, etc.)" # Option 2: # # The following seemed unsophisticated, and clunky, when the /bin/mountpoint # command is installed by default, thus option 3 below. But as can be seen # with option 3, the "sophisticated" option is in fact buggy. I emailed # this bug to initscripts maintainer, debian and ubuntu, on 20101029. # See also: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=359717 # See also: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=622595 # See also: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=460898 #mount | grep "on ${DIR} type" > /dev/null && return 0 #mount | grep -q "on ${DIR} type" && return 0 mount | grep -q "on ${DIR} type" # Option 3: # # The following (off the web, and a standard command in debian) # fails for a directory mounted on itself, # which is needed prior to mount --make-rshared /directory. #mountpoint -q ${DIR} } -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/caosgnsq5sp-ojzr6m+pmjjj00ctjbah5_mhkujtyokowwit...@mail.gmail.com