Skip to content

Commit

Permalink
Do not run the backup in case the .ssh inside the container is empty
Browse files Browse the repository at this point in the history
It close #19.
  • Loading branch information
maxcnunes committed Mar 30, 2016
1 parent eed9526 commit fca9960
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions ONVAULT
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,14 @@ fi
if curl -s "${VAULT_URI}/_ping"; then
mkdir -p ~/.ssh/

# check if is required the ssh backup
ssh_backup_enabled="$(ls -A ~/.ssh)"

# creating backup of existing ssh directory
tmp_ssh_vault=`mktemp -d ~/.vault-backup-ssh-XXXX`
cp -r ~/.ssh/* $tmp_ssh_vault
if [[ -n "$ssh_backup_enabled" ]]; then
tmp_ssh_vault=`mktemp -d ~/.vault-backup-ssh-XXXX`
cp -r ~/.ssh/* $tmp_ssh_vault
fi

log "Downloading private keys..."
curl -s "${VAULT_URI}/ssh.tgz" | tar -C ~/.ssh/ -zxf -
Expand All @@ -55,8 +60,10 @@ if curl -s "${VAULT_URI}/_ping"; then
rm -rf ~/.ssh/*

# copying backup to ssh directory
cp -r $tmp_ssh_vault/* ~/.ssh
rm -rf $tmp_ssh_vault
if [[ -n "$ssh_backup_enabled" ]]; then
cp -r $tmp_ssh_vault/* ~/.ssh
rm -rf $tmp_ssh_vault
fi
else
log "ERROR: Start the dockito/vault container before using ONVAULT!"
log "ex: docker run -d -p ${VAULT_HOST}:14242:3000 -v ~/.ssh:/vault/.ssh dockito/vault"
Expand Down

0 comments on commit fca9960

Please sign in to comment.