2020-11-13 10:25:04 -08:00
|
|
|
#!/bin/bash
|
|
|
|
# must be json as a string, depends on jq
|
|
|
|
mounted () {
|
|
|
|
[[ ! $1 ]] && echo no mount point to test && return 2
|
|
|
|
mountpoint "$1" &> /dev/null && echo yes || return 1
|
|
|
|
}
|
2020-12-03 20:48:04 -08:00
|
|
|
|
2022-03-28 10:02:17 -07:00
|
|
|
# peals back sub-directories until if finds a mountpoint
|
2020-12-03 20:48:04 -08:00
|
|
|
find_mountpoint () {
|
|
|
|
local dir=$1
|
|
|
|
if [[ ! $dir = "/" ]]; then
|
|
|
|
# echo trying $dir for mountpoint
|
|
|
|
[[ $(mounted $dir) ]] && echo $dir || find_mountpoint "$(dirname $1)"
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
2023-01-18 16:43:21 -08:00
|
|
|
|