aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-05-26 10:52:51 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-05-26 10:52:51 -0300
commitb75fa5cc871c958284d2e25dc0845a99058d3e88 (patch)
tree2685d701b43030f4f31297f9d264cc17622a2270
parent37d3e5c6463e2b62e34ed06de3b371f5614e7376 (diff)
downloadhydra-b75fa5cc871c958284d2e25dc0845a99058d3e88.tar.gz
hydra-b75fa5cc871c958284d2e25dc0845a99058d3e88.tar.bz2
Fix import-keys for borg
-rwxr-xr-xshare/hydra/deploy10
-rwxr-xr-xshare/hydra/import-keys50
2 files changed, 32 insertions, 28 deletions
diff --git a/share/hydra/deploy b/share/hydra/deploy
index f64a56e..9a43edf 100755
--- a/share/hydra/deploy
+++ b/share/hydra/deploy
@@ -90,7 +90,7 @@ for node in $NODES; do
# Check if keys should be imported
if ! $SUDO test -f $FOLDER/root/.ssh/id_rsa || \
- ! $SUDO test -f $FOLDER/root/.borg/hydra/key || \
+ ! $SUDO test -f $FOLDER/root/.config/borg/hydra/key || \
! $SUDO gpg --homedir=$FOLDER/root --list-secret-keys root@$FQDN &> /dev/null; then
echo "No $FOLDER/root/.ssh/id_rsa found. Please import it and other keys when the system is online using import-keys action"
fi
@@ -131,9 +131,9 @@ for node in $NODES; do
# Import keys if needed
if ! $SUDO test -f /root/.ssh/id_rsa || \
- ! $SUDO test -f /root/.borg/hydra/key || \
+ ! $SUDO test -f /root/.config/borg/hydra/key || \
! $SUDO gpg --list-secret-keys root@$FQDN &> /dev/null; then
- hydra $HYDRA import-keys localhost
+ hydra $HYDRA import-keys $FQDN
fi
else
echo "Deploying to $node..."
@@ -216,9 +216,9 @@ EOF
# Import keys if needed
if ! $HYDRA_CONNECT $FQDN sudo test -f /root/.ssh/id_rsa || \
- ! $HYDRA_CONNECT $FQDN sudo test -f /root/.borg/hydra/key || \
+ ! $HYDRA_CONNECT $FQDN sudo test -f /root/.config/borg/hydra/key || \
! $HYDRA_CONNECT $FQDN sudo gpg --list-secret-keys root@$FQDN &> /dev/null; then
- hydra $HYDRA import-keys localhost
+ hydra $HYDRA import-keys $FQDN
fi
fi
done
diff --git a/share/hydra/import-keys b/share/hydra/import-keys
index 59114bf..21fe744 100755
--- a/share/hydra/import-keys
+++ b/share/hydra/import-keys
@@ -126,39 +126,43 @@ EOF
function hydra_import_keys_borg {
if [ "`facter fqdn`" != "$hostname" ]; then
echo "-----------------------------------------------------"
- echo "Importing borg key at $hostname:/root/.borg/hydra/key..."
+ echo "Importing borg key at $hostname:/root/.config/borg/hydra/key..."
echo "-----------------------------------------------------"
- echo "Creating folder structure at $hostname:/root/.borg..."
+ echo "Creating folder structure at $hostname:/root/.config/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
+ sudo rm -rf /root/.borg
+ sudo mkdir -p /root/.config/borg/hydra
+ sudo chown root.root /root/.config/borg
+ sudo chown root.root /root/.config/borg/hydra
+ sudo chmod 700 /root/.config/borg
+ sudo chmod 700 /root/.config/borg/hydra
+ sudo touch /root/.config/borg/hydra/key
+ sudo chmod 600 /root/.config/borg/hydra/key
EOF
- echo "Importing borg key from keyringer to $hostname:/root/.borg/hydra/key..."
+ echo "Importing borg key from keyringer to $hostname:/root/.config/borg/hydra/key..."
keyringer $HYDRA decrypt nodes/$hostname/borg/key | \
- $HYDRA_CONNECT $hostname "cat - | sudo tee /root/.borg/hydra/key > /dev/null"
+ $HYDRA_CONNECT $hostname "cat - | sudo tee /root/.config/borg/hydra/key > /dev/null"
else
echo "-----------------------------------------------------"
- echo "Importing borg key at $hostname:/root/.borg/hydra/key..."
+ echo "Importing borg key at $hostname:/root/.config/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
+ # Remove old, wrong borg config
+ sudo rm -rf /root/.borg
+
+ echo "Creating folder structure at $hostname:/root/.config/borg..."
+ sudo mkdir -p /root/.config/borg/hydra
+ sudo chown root.root /root/.config/borg
+ sudo chown root.root /root/.config/borg/hydra
+ sudo chmod 700 /root/.config/borg
+ sudo chmod 700 /root/.config/borg/hydra
+ sudo touch /root/.config/borg/hydra/key
+ sudo chmod 600 /root/.config/borg/hydra/key
+
+ echo "Importing borg key from keyringer to $hostname:/root/.config/borg/hydra/key..."
+ keyringer $HYDRA decrypt nodes/$hostname/borg/key | sudo tee /root/.config/borg/hydra/key > /dev/null
fi
}