aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2020-06-08 05:08:14 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2020-06-08 05:08:14 +0200
commit23bd461efadf946c5266a535a9bc3294e2ca7147 (patch)
tree0b51dc050bf2c165b96bb6885ab4dce85c63c8f1
parent2752f4a462004485afb6a5486375447b10cd7c36 (diff)
downloadltask-23bd461efadf946c5266a535a9bc3294e2ca7147.tar.gz
Added interactive mode
-rwxr-xr-xltask38
1 files changed, 33 insertions, 5 deletions
diff --git a/ltask b/ltask
index 38b507b..c75be20 100755
--- a/ltask
+++ b/ltask
@@ -75,6 +75,24 @@ function parse_args() {
done
}
+selector()
+{
+ local regex="^-?[0-9]+\$"
+ local cnt=0
+ for selection in "$@"
+ do
+ echo "$cnt) $selection"
+ ((cnt=$cnt + 1))
+ done
+
+ read -p "(default=0) >" inp
+ if [[ "$inp" =~ $regex ]] && [ $inp -ge 0 -a $inp -le $# ]
+ then
+ return $inp
+ fi
+ return 0
+}
+
function print_help() {
cat << EOF
Usage:
@@ -90,8 +108,16 @@ EOF
}
function interactive() {
- perror Interactive mode TODO
- exit 1
+ TASK_LIST=( $(ls $TASK_DIR) )
+ TARGET_LIST=( $(ls $TARGET_DIR) )
+
+ perror "\nSelect a Task"
+ >&2 selector ${TASK_LIST[@]}
+ TASK=${TASK_LIST[$?]}
+
+ perror "\nSelect a Target"
+ >&2 selector ${TARGET_LIST[@]}
+ TARGET=${TARGET_LIST[$?]}
}
parse_args
@@ -123,7 +149,7 @@ for hoststring in "${HOSTS_UNIQUE[@]}"; do
IFS=$':' read hostname port <<< "$hoststring"
[ ! -z $port ] && rexecargs+="-p $port "
- rexecargs+="-i ${SSH_IDENTITY_FILE:=~/.ssh/id_rsa} "
+ [ ! -z $SSH_IDENTITY_FILE ] && rexecargs+="-i $SSH_IDENTITY_FILE "
[ ${#FILES[@]} -gt 0 ] && for f in ${FILES[@]}; do rexecargs+="-f $f "; done
[ ! -z $SSH_USER ] && rexecargs+="$SSH_USER@"
@@ -144,16 +170,18 @@ for hoststring in "${HOSTS_UNIQUE[@]}"; do
done
if [ $PARALLEL = "yes" ]; then
- perror Waiting for remote tasks to finish...
+ perror Waiting for asynchronous tasks to finisch...
+
for hostname in ${!HOST_PID[@]}; do
wait ${HOST_PID[$hostname]}
[ $? -ne 0 ] && FAILED_HOSTS+=($hostname)
done
+
perror Done!
fi
if [ ${#FAILED_HOSTS[@]} -gt 0 ]; then
- perror "\n"
+ perror
perror ${#FAILED_HOSTS[@]} targets failed:
perror ${FAILED_HOSTS[@]}
exit 1