diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2020-06-07 00:31:53 +0200 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2020-06-07 00:31:53 +0200 |
commit | a1407e29cf0b47d5db157ebedcec8139f82cfc6c (patch) | |
tree | f857432f675d08cf2579213218f544399b86df04 | |
parent | a1f34001696c44139b668918ea52c1add0dde7ea (diff) | |
download | ltask-a1407e29cf0b47d5db157ebedcec8139f82cfc6c.tar.gz |
Changed output to differentiate STDERR/STEDOUT
-rwxr-xr-x | ltask | 22 | ||||
-rwxr-xr-x | tools/rexec.sh | 5 |
2 files changed, 18 insertions, 9 deletions
@@ -43,6 +43,10 @@ INCLUDES=() #block run when sourcing task export readonly HOSTMODE="yes" +function perror() { + echo -e $@ 1>&2 +} + function parse_args() { for (( i=0; i < $ARGC;i++ )); do local ARGREGEX="^-.*" @@ -81,7 +85,7 @@ EOF } function interactive() { - echo Interactive mode TODO + perror Interactive mode TODO exit 1 } @@ -97,12 +101,15 @@ unset TASK_ISSET [ -f $TARGET_DIR/$TARGET ] && source $TARGET_DIR/$TARGET if [ -z $TASK_ISSET ]; then - echo Task did not load correctly + perror Task did not load correctly exit 1 fi HOSTS_UNIQUE=($(tr ' ' '\n' <<< "${HOSTS[@]}" | sort -u)) +COUNTER=0 +HOSTCOUNT=${#HOSTS_UNIQUE[@]} + for hoststring in "${HOSTS_UNIQUE[@]}"; do rexecargs="" IFS=$':' read hostname port <<< "$hoststring" @@ -117,14 +124,17 @@ for hoststring in "${HOSTS_UNIQUE[@]}"; do echo echo "<=== $hostname ===>" echo - echo $rexecargs $TOOL_DIR/rexec.sh $rexecargs [ $? -ne 0 ] && FAILED_HOSTS+=($hostname) + + COUNTER=$(($COUNTER + 1)) + PERCENT=$(($COUNTER * 100 / $HOSTCOUNT)) + perror -n "\r[$COUNTER: $PERCENT%] " done if [ ${#FAILED_HOSTS[@]} -gt 0 ]; then - echo - echo Some hosts failed the task: - echo ${FAILED_HOSTS[@]} + perror "\n" + perror ${#FAILED_HOSTS[@]} hosts failed the task: + perror ${FAILED_HOSTS[@]} exit 1 fi diff --git a/tools/rexec.sh b/tools/rexec.sh index 558540c..388cbc3 100755 --- a/tools/rexec.sh +++ b/tools/rexec.sh @@ -24,7 +24,7 @@ SSH_IDENTITY=~/.ssh/id_rsa SSH_PORT=22 SSH_HOST= -SSH_OPTIONS="-o NumberOfPasswordPrompts=0 -o StrictHostKeyChecking=no" +SSH_OPTIONS="-q -o NumberOfPasswordPrompts=0 -o StrictHostKeyChecking=no" SSH="ssh $SSH_OPTIONS" SCRIPT_FILES=() @@ -61,7 +61,6 @@ function parse_args() { echo $0 -h for help exit 1;; esac - done [ -z $SSH_HOST ] && echo No host specified && exit 1 @@ -87,5 +86,5 @@ parse_args [ ${#FILES[@]} -gt 0 ] && scp $SSH_OPTIONS -i $SSH_IDENTITY -P $SSH_PORT ${FILES[@]} $SSH_HOST: -cat ${SCRIPT_FILES[@]} | $SSH -p $SSH_PORT -i $SSH_IDENTITY $SSH_HOST "/bin/bash" +cat ${SCRIPT_FILES[@]} | $SSH -p $SSH_PORT -i $SSH_IDENTITY $SSH_HOST "/bin/bash 2>&1" 2>/dev/null exit $? |