aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xshare/hydra/import-keys43
1 files changed, 43 insertions, 0 deletions
diff --git a/share/hydra/import-keys b/share/hydra/import-keys
index 692e5eb..59114bf 100755
--- a/share/hydra/import-keys
+++ b/share/hydra/import-keys
@@ -122,6 +122,46 @@ EOF
fi
}
+# Import Borg key
+function hydra_import_keys_borg {
+ if [ "`facter fqdn`" != "$hostname" ]; then
+ echo "-----------------------------------------------------"
+ echo "Importing borg key at $hostname:/root/.borg/hydra/key..."
+ echo "-----------------------------------------------------"
+
+ echo "Creating folder structure at $hostname:/root/.borg..."
+ $HYDRA_CONNECT $hostname <<EOF
+ sudo mkdir -p /root/.borg/hydra
+ sudo chown root.root /root/.borg
+ sudo chown root.root /root/.borg/hydra
+ sudo chmod 700 /root/.borg
+ sudo chmod 700 /root/.borg/hydra
+ sudo touch /root/.borg/hydra/key
+ sudo chmod 600 /root/.borg/hydra/key
+EOF
+
+ echo "Importing borg key from keyringer to $hostname:/root/.borg/hydra/key..."
+ keyringer $HYDRA decrypt nodes/$hostname/borg/key | \
+ $HYDRA_CONNECT $hostname "cat - | sudo tee /root/.borg/hydra/key > /dev/null"
+ else
+ echo "-----------------------------------------------------"
+ echo "Importing borg key at $hostname:/root/.borg/hydra/key..."
+ echo "-----------------------------------------------------"
+
+ echo "Creating folder structure at $hostname:/root/.borg..."
+ sudo mkdir -p /root/.borg/hydra
+ sudo chown root.root /root/.borg
+ sudo chown root.root /root/.borg/hydra
+ sudo chmod 700 /root/.borg
+ sudo chmod 700 /root/.borg/hydra
+ sudo touch /root/.borg/hydra/key
+ sudo chmod 600 /root/.borg/hydra/key
+
+ echo "Importing borg key from keyringer to $hostname:/root/.borg/hydra/key..."
+ keyringer $HYDRA decrypt nodes/$hostname/borg/key | sudo tee /root/.borg/hydra/key > /dev/null
+ fi
+}
+
# Command line arguments
NODES="$*"
@@ -139,4 +179,7 @@ for node in $NODES; do
# Import OpenSSH keypair
hydra_import_keys_openssh
+
+ # Import Borg key
+ hydra_import_keys_borg
done