diff --git a/README.md b/README.md index 78a439b..91da8ba 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -csc : cluster ssh command +# csc : cluster ssh command -simple script to execute command over ssh on remote hosts with specific DEBIAN_FRONTEND +simple script to execute command over ssh on remote hosts with "dialog" DEBIAN_FRONTEND diff --git a/csc b/csc index d5866bc..f90eae9 100755 --- a/csc +++ b/csc @@ -1,15 +1,23 @@ -#!/bin/env sh +#!/usr/bin/env sh # csc : cluster ssh command # ./csc -# launch command over ssh on cluster hosts with specific DEBIAN FRONTEND +# launch command over ssh on cluster hosts with "dialog" DEBIAN_FRONTEND -# TODO -HOSTS_FILE="/home/flo/hosts.int" +VERBOSE=false -CMD=$@ +# TODO clush like +HOSTS="$HOME/.config/csc/hosts" -if [ -z "$CMD" ] +if [ ! -e "$HOSTS" ] +then + echo "hosts file do not exists !" + exit +fi + +COMMAND=$@ + +if [ -z "$COMMAND" ] then echo "command is missing" echo "USAGE: $0 " @@ -17,13 +25,22 @@ then fi # see http://askubuntu.com/questions/506158/unable-to-initialize-frontend-dialog-when-using-ssh -#FRONTEND="DEBIAN_FRONTEND=noninteractive" +#FRONTEND="DEBIAN_FRONTEND=noninteractive" # then you should use clush instead :) FRONTEND="TERM=$TERM DEBIAN_FRONTEND=dialog" #FRONTEND="DEBIAN_FRONTEND=readline" -echo "will do :" -echo "for i in `cat $HOSTS_FILE`; do ssh -t \$i "$FRONTEND $CMD"; done" +if [ "$VERBOSE" = true ] +then + echo "will do :" + echo "for i in `cat $HOSTS`; do ssh -t \$i "$FRONTEND $COMMAND"; done" +fi -for i in `cat $HOSTS_FILE` - do echo; echo "********** $i / $CMD **********"; ssh -t $i "$FRONTEND $CMD" +for i in `cat $HOSTS` + do + echo "\e[34m---------------\e[0m" + echo "\e[34m$i\e[0m" + echo "\e[34m---------------\e[0m" + ssh -t $i "$FRONTEND $COMMAND" done + +exit