From 9c9c776213478023d4cab6290efcb6adfdbbbe86 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 20 Apr 2022 13:01:51 +0200 Subject: Refactor deployment scripts --- sshtool | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100755 sshtool (limited to 'sshtool') diff --git a/sshtool b/sshtool new file mode 100755 index 0000000..94a3ea0 --- /dev/null +++ b/sshtool @@ -0,0 +1,83 @@ +#!/usr/bin/env bash + +cd $(dirname $0) + +CMDFILE="$1" +shift 1 + +CLUSTER="$1" +if [ -z "$CLUSTER" ] || [ ! -d "cluster/$CLUSTER" ]; then + echo "Usage: $CMDFILE " + echo "The cluster name must be the name of a subdirectory of cluster/" + exit 1 +fi +shift 1 + +if [ -z "$1" ]; then + NIXHOSTLIST=$(ls cluster/$CLUSTER/node | grep -v '\.site\.') +else + NIXHOSTLIST="$@" +fi + +if [ -z "$ROOT_PASS" ]; then + read -s -p "Enter remote root password: " ROOT_PASS + echo +fi + +SSH_CONFIG=cluster/$CLUSTER/ssh_config + +function header { + cat < /tmp/deploytool_askpass < /dev/null +$(base64 <$FROM) +EOG +EOF +} + +for NIXHOST in $NIXHOSTLIST; do + NIXHOST=${NIXHOST%.*} + + if [ -z "$SSH_USER" ]; then + SSH_DEST=$NIXHOST + else + SSH_DEST=$SSH_USER@$NIXHOST + fi + + echo "==== DOING $NIXHOST ====" + + (header; . $CMDFILE; footer) | ssh -F $SSH_CONFIG $SSH_DEST sh - +done -- cgit v1.2.3