From f2917af59191911f3de04b367ce37eb9683d30c2 Mon Sep 17 00:00:00 2001 From: Trolli Schmittlauch Date: Thu, 28 Sep 2023 19:31:15 +0200 Subject: [PATCH] add ssh-loop shell helpers for FC infra --- home/home.nix | 3 ++- home/scripts/ssh-loop-fc.nix | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 home/scripts/ssh-loop-fc.nix diff --git a/home/home.nix b/home/home.nix index 0aed480..65513cc 100644 --- a/home/home.nix +++ b/home/home.nix @@ -524,7 +524,8 @@ programs.bat = { realpath $(${pkgs.which}/bin/which $1) } '' - + (import ./scripts/reporsync.nix {inherit pkgs;}); + + (import ./scripts/reporsync.nix {inherit pkgs;}) + + (import ./scripts/ssh-loop-fc.nix {inherit pkgs;}); oh-my-zsh = { diff --git a/home/scripts/ssh-loop-fc.nix b/home/scripts/ssh-loop-fc.nix new file mode 100644 index 0000000..25404c8 --- /dev/null +++ b/home/scripts/ssh-loop-fc.nix @@ -0,0 +1,19 @@ +{pkgs, ...}: +'' +ssh-loop () { + setopt shwordsplit + local hosts=$1 + local cmd=$2 + + for x in $1; do echo $x; ${pkgs.openssh}/bin/ssh $x.fcio.net -o StrictHostKeyChecking=no -C "$2"; done +} + +ssh-loop-parallel () { + setopt shwordsplit + local hosts=$1 + local cmd=$2 + + for x in $1; do echo $x; ${pkgs.openssh}/bin/ssh $x.fcio.net -o StrictHostKeyChecking=no -C "$2" 2>&1 | sed -e "s/^/$x: /;" & done + wait +} +''