Skip to content

Commit

Permalink
Create script to run commands on targets
Browse files Browse the repository at this point in the history
  • Loading branch information
ThetaSinner committed Jun 19, 2024
1 parent 04ef509 commit 03b2736
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 10 deletions.
110 changes: 100 additions & 10 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
};
};

amber = {
url = "github:Ph0enixKM/Amber";
inputs.nixpkgs.follows = "holochain/nixpkgs";
};

nixpkgs.follows = "holochain/nixpkgs";
};

Expand Down Expand Up @@ -60,6 +65,7 @@
pkgs.shellcheck
pkgs.statix
inputs.tryorama.packages.${system}.trycp-server
inputs.amber.packages.${system}.default
];

shellHook = ''
Expand Down
27 changes: 27 additions & 0 deletions scripts/exec_on_targets.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { input, lines } from "std"

let cmd = input("Enter the command to run: ")

let x = $cat "./targets.yaml" | grep "ws://"$ failed {
echo "[{status}] Failed to read file"
}

let attempted = 0
let succeeded = 0

loop index, line in lines(x) {
let ip = $echo {line} | cut -b 8- | rev | cut -b 6- | rev$ failed {
echo "[{status}] failed to extract ip from {line}"
}
echo "Running on target {index} at {ip}"
attempted = attempted + 1
let result = $ssh "-oPreferredAuthentications publickey" "root@{ip}" {cmd}$ failed {
succeeded = succeeded - 1
echo "[{status}] failed to run command on {ip}"
}

succeeded = succeeded + 1
echo result
}

echo "Ran command on successfully on {succeeded}/{attempted} targets"

0 comments on commit 03b2736

Please sign in to comment.