]> gitweb.fluxo.info Git - hydra.git/commitdiff
Adding all-ssh and all-pgp arguments to newkeys
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 8 Apr 2014 18:58:05 +0000 (15:58 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 8 Apr 2014 18:58:05 +0000 (15:58 -0300)
TODO.md
share/hydra/newkeys

diff --git a/TODO.md b/TODO.md
index cce1abd8071c3b72c2f09d330705989a7fe0019b..f67485c086e270bb8ae41101102bf6ac7dff6f79 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -6,9 +6,7 @@ Hydra
 
   - module-update: get latest commit from production branch, setup branch if need.
   - bootless: properly support `$subdevice` in parted or always use first partition (like `/dev/sdb1`).
-  - newkeys:
-    - split SSH/OpenPGP check: just generate OpenPGP key if absent.
-    - add 'all-ssh' and 'all-pgp' options to generate either all SSH or all OpenPGP keys.
+  - newkeys: split SSH/OpenPGP check: just generate OpenPGP key if absent.
 
 Hydractl
 --------
index 66ce846b4e8c3e70b1baf2d92d21ed6a366cf428..35dce4f366e95a26e666efd30468e8e8aa907328 100755 (executable)
@@ -17,7 +17,7 @@
 # <http://www.gnu.org/licenses/>.
 
 function hydra_newkeys {
-  # Generates ssh and gpg keys for new nodes
+  # Generates ssh and gpg keys for new or existing nodes
   # GPG keys should be manually imported in the nodes
   for host in `hydra $HYDRA nodes`; do
     node="`echo $host | cut -d . -f 1`"
@@ -25,6 +25,13 @@ function hydra_newkeys {
     pubkey="$privkey.pub"
     if [ "$1" == "all" ]; then
       hydra_genpairs
+    elif [ "$1" == "all-ssh" ]; then
+      hydra_genpairs all-ssh
+    elif [ "$1" == "all-pgp" ]; then
+      hydra_genpairs all-pgp
+    elif [ ! -z "$1" ]; then
+      hydra_genpairs
+      exit $?
     elif [ ! -e "$privkey" ] || [ ! -e "$pubkey" ]; then
       hydra_genpairs
     fi
@@ -34,8 +41,13 @@ function hydra_newkeys {
 function hydra_genpairs {
   BASEDIR="/tmp"
 
-  keyringer $HYDRA genpair ssh $node/ssh/id_rsa $host $privkey
-  keyringer $HYDRA genpair gpg $node/gpg/key    $host
+  if [ "$1" != "all-pgp" ]; then
+    keyringer $HYDRA genpair ssh $node/ssh/id_rsa $host $privkey
+  fi
+
+  if [ "$1" != "all-ssh" ]; then
+    keyringer $HYDRA genpair gpg $node/gpg/key    $host
+  fi
 
   hydra_set_tmpfile genpair
   echo "Importing keys for $host" > $TMPWORK