Skip to content

Commit

Permalink
oops: Fix check for existing remote path at init
Browse files Browse the repository at this point in the history
df505c1 added a check for the remote path's existance at init time. This made
the assumption that the remote path was local. This patch fixes the issue by
connecting to the remote host and checking for the existance of the remote path
if a remote is specified.
  • Loading branch information
Jared Hancock committed Oct 19, 2018
1 parent a726870 commit bf2b8b0
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions bin/bitpocket
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,16 @@ you encounter.
fi

# Decide on runner (ssh / bash -c)
if [[ -n "$REMOTE_HOST" ]]; then
REMOTE_RUNNER="$RSYNC_RSH $REMOTE_HOST"
REMOTE="$REMOTE_HOST:$REMOTE_PATH"
else
REMOTE_RUNNER="bash -c"
REMOTE="$REMOTE_PATH"
fi
function setup_remote() {
if [[ -n "$REMOTE_HOST" ]]; then
REMOTE_RUNNER="$RSYNC_RSH $REMOTE_HOST"
REMOTE="$REMOTE_HOST:$REMOTE_PATH"
else
REMOTE_RUNNER="bash -c"
REMOTE="$REMOTE_PATH"
fi
}
setup_remote

# Version of the state files. Original version is 1, second version with
# leading mode is 2.
Expand Down Expand Up @@ -118,8 +121,9 @@ function init {
fi

REMOTE_PATH="$1"
if [[ ! -d "$1" ]]; then
echo "fatal: '$1': Remote path is not accessible"
setup_remote
if $REMOTE_RUNNER "[ ! -d '$1' ]"; then
echo "fatal: '$REMOTE': Remote path is not accessible"
exit 128
fi

Expand Down Expand Up @@ -755,7 +759,7 @@ Available commands:
sync Run the sync process. If no command is specified, sync is run by
default.
init Initialize a new bitpocket folder. Requires path and optional
remote hostparams.
remote host params. Remote path must already exist.
pack Pack any existing (automatic) backups into a git repository.
cron Run sync optimized for cron, logging output to file instead of
stdout.
Expand Down

0 comments on commit bf2b8b0

Please sign in to comment.