aboutsummaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-05-23 14:25:37 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-05-23 14:25:37 -0300
commit3b2e6c2e05d3821b60052aabdcdcfb41341347df (patch)
treee5fe93ce0f50ad10819a89ede24551b01caf1403 /share
parentbf85e9d8e4d396e1c4243594e5ece0ee0f7d8347 (diff)
downloadhydra-3b2e6c2e05d3821b60052aabdcdcfb41341347df.tar.gz
hydra-3b2e6c2e05d3821b60052aabdcdcfb41341347df.tar.bz2
Import Borg key into nodes
Diffstat (limited to 'share')
-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