cd /
[[ $EUID == 0 ]] || exec sudo -E "$this_file" "$@"
-source /usr/local/lib/err
+source /usr/local/lib/bash-bear
usage() {
cat <<EOF
exit $1
}
-
+pre="mount-latest-subvol:${SSH_CLIENT:+ $HOSTNAME:}"
tu() {
while read -r line; do
}
d() {
if $verbose; then
- printf "%s\n" "$*"
+ printf "$pre %s\n" "$*"
fi
}
m() {
if $verbose; then
- printf "%s\n" "$*"
+ printf "$pre %s\n" "$*"
fi
"$@"
}
x() {
- printf "%s\n" "$*"
+ printf "$pre %s\n" "$*"
"$@"
}
fi
fstab <<EOF
/o/m /m none bind$mopts 0 0
+/o/debbugs /debbugs none bind$mopts 0 0
EOF
fi
##### end building up list of bind mounts ######
+
# if latest is already mounted, make sure binds are mounted and move on
m check-subvol-stale $d
# populated by check-subvol-stale if stale
continue
fi
+
+ ##### begin checking for loopback mounts ####
+ found_loop=false
+ for l in $(losetup -ln|awk '{print $6}'); do
+ for dir in $d ${binds[@]}; do
+ if [[ $l == $dir* ]]; then
+ echo "$0: found loopback mount $l. giving up on unmounting $dir"
+ ret=1
+ found_loop=true
+ break
+ fi
+ done
+ if $found_loop; then
+ break
+ fi
+ done
+ if $found_loop; then
+ continue
+ fi
+ ##### end end checking loopback mounts ####
+
+
## not using arbtt at the moment
# if [[ $vol == q ]]; then
# ## allow to fail, user might not be logged in
rm -f /nocow/btrfs-stale/$vol
done
-if (( $ret )); then
+if (( ret >= 1 )); then
echo "$0: exit status $ret. see error above"
fi
exit $ret