aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xltask22
-rwxr-xr-xtools/rexec.sh5
2 files changed, 18 insertions, 9 deletions
diff --git a/ltask b/ltask
index 864664f..306e972 100755
--- a/ltask
+++ b/ltask
@@ -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 $?