From bc6902fde438b69b017709bd848f2df4eb3758b1 Mon Sep 17 00:00:00 2001 From: JenswBE <jens@jensw.be> Date: Thu, 4 Jul 2019 09:35:04 +0200 Subject: [PATCH] Ignore hidden files in /sshkeys/clients --- README.md | 2 +- data/run.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3e0e788..a9e181a 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ We will need two persistent storage directories for our borgserver to be usefull This directory has two subdirectories: ##### /sshkeys/clients/ -Here we will put all SSH public keys from our borg clients, we want to backup. Every key must be it's own file, containing only one line, with the key. The name of the file will become the name of the borg repository, we need for our client to connect. +Here we will put all SSH public keys from our borg clients, we want to backup. Every key must be it's own file, containing only one line, with the key. The name of the file will become the name of the borg repository, we need for our client to connect. Hidden files are ignored. That means every client get's it's own repository. So you might want to use the hostname of the client as the name of the sshkey file. diff --git a/data/run.sh b/data/run.sh index d8eca9f..5d3d82f 100755 --- a/data/run.sh +++ b/data/run.sh @@ -27,7 +27,7 @@ for dir in BORG_DATA_DIR SSH_KEY_DIR ; do exit 1 fi - if [ "$(find ${SSH_KEY_DIR}/clients -type f | wc -l)" == "0" ] ; then + if [ "$(find ${SSH_KEY_DIR}/clients -type f -not -iname ".*" | wc -l)" == "0" ] ; then echo "ERROR: No SSH-Pubkey file found in ${SSH_KEY_DIR}" exit 1 fi @@ -48,7 +48,7 @@ echo " * Starting SSH-Key import..." # Add every key to borg-users authorized_keys rm /home/borg/.ssh/authorized_keys &>/dev/null -for keyfile in $(find "${SSH_KEY_DIR}/clients" -type f); do +for keyfile in $(find "${SSH_KEY_DIR}/clients" -type f -not -iname ".*"); do client_name=$(basename ${keyfile}) mkdir ${BORG_DATA_DIR}/${client_name} 2>/dev/null echo " ** Adding client ${client_name} with repo path ${BORG_DATA_DIR}/${client_name}"