Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ensure rrsync subdirectory is a mountpoint.
#!/bin/bash
# Simple pre-rsync check to ensure rrsync subdirectory is a mountpoint.
# That is, only allow rsyncing to a mounted drive, and fail otherwise.
#
# Drop-in replacement for rrsync in .ssh/authorized_keys.
rrsync="$HOME"/bin/rrsync
# Assume -ro always comes before the subdirectory, if provided.
if [ $# -eq 0 ]; then
exec $rrsync
elif [ $# -eq 1 ]; then
path=$1
elif [ $# -eq 2 ]; then
path=$2
else
exec $rrsync
fi
if ! mountpoint -q $path; then
echo "Path is not a mountpoint: $path" >&2
exit 2
fi
exec $rrsync "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment