change config file and enhance output

- move config file to $HOME/.config
- add colors to output
- enhance README
This commit is contained in:
Flo 2017-04-29 20:04:29 +02:00
parent 98ce2ac0f9
commit ec96f4d51b
2 changed files with 30 additions and 13 deletions

View File

@ -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

37
csc
View File

@ -1,15 +1,23 @@
#!/bin/env sh #!/usr/bin/env sh
# csc : cluster ssh command # csc : cluster ssh command
# ./csc <command> # ./csc <command>
# launch command over ssh on cluster hosts with specific DEBIAN FRONTEND # launch command over ssh on cluster hosts with "dialog" DEBIAN_FRONTEND
# TODO VERBOSE=false
HOSTS_FILE="/home/flo/hosts.int"
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 then
echo "command is missing" echo "command is missing"
echo "USAGE: $0 <command>" echo "USAGE: $0 <command>"
@ -17,13 +25,22 @@ then
fi fi
# see http://askubuntu.com/questions/506158/unable-to-initialize-frontend-dialog-when-using-ssh # 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="TERM=$TERM DEBIAN_FRONTEND=dialog"
#FRONTEND="DEBIAN_FRONTEND=readline" #FRONTEND="DEBIAN_FRONTEND=readline"
if [ "$VERBOSE" = true ]
then
echo "will do :" echo "will do :"
echo "for i in `cat $HOSTS_FILE`; do ssh -t \$i "$FRONTEND $CMD"; done" echo "for i in `cat $HOSTS`; do ssh -t \$i "$FRONTEND $COMMAND"; done"
fi
for i in `cat $HOSTS_FILE` for i in `cat $HOSTS`
do echo; echo "********** $i / $CMD **********"; ssh -t $i "$FRONTEND $CMD" do
echo "\e[34m---------------\e[0m"
echo "\e[34m$i\e[0m"
echo "\e[34m---------------\e[0m"
ssh -t $i "$FRONTEND $COMMAND"
done done
exit