Skip to content

Instantly share code, notes, and snippets.

@rduplain
Created December 27, 2017 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rduplain/11aa60c3e8f0628606342472713287eb to your computer and use it in GitHub Desktop.
Save rduplain/11aa60c3e8f0628606342472713287eb to your computer and use it in GitHub Desktop.
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