Improve help output with latest changes from sequencer

This commit is contained in:
2022-01-23 23:06:46 +01:00
parent e641373a57
commit 6dd40bc6c2
12 changed files with 80 additions and 83 deletions

View File

@@ -1,7 +1,7 @@
#!/bin/bash
toolName="ssh"
toolIdentity=~/.ssh/id_rsa
toolIdentity=~/".ssh/id_rsa"
aList=""
aHost=""
@@ -27,27 +27,8 @@ step_3() {
}
step_5_info() {
shift
local arg
local sshOption="[OPTIONS] "
local userHost="<USER@HOST>"
local userPort=" [PORT]"
for arg in "$@" ; do
case "$1" in
-4)
sshOption="-o Addressfamily=inet "
shift
;;
*)
break
;;
esac
done
if [ ! -z $1 ] ; then userHost="$1"; userPort=":22"; fi
if [ ! -z $2 ] ; then userPort=":$2"; fi
echo "Send key to remote host ${sshOption}${userHost}$userPort"
echoinfoArgs "[OPTIONS] <USER@HOST> [PORT]"
echo "Send key to remote host"
echoinfo "[OPTIONS]"
echoinfo " -4 : Force Ipv4"
}
@@ -89,14 +70,19 @@ step_5() {
exe ssh-copy-id -p ${sshPort} ${sshOption} ${sshHost}
}
step_10_info() { echo "Send command(ssh)/file(scp) list to remote(s) <CMDLIST> [USER:HOST]"; }
step_10_info() {
echoinfoArgs "<CMDLIST> [USER:HOST] [PORT]"
echo "Send command(ssh)/file(scp) list to remote(s)"
echoinfo "[USER:HOST] and [PORT] are overwritten by \"host\" command from <CMDLIST>"
}
step_10_alias() { ALIAS="sendlist"; }
step_10() {
aList=$2
aHost=$3
shift
aList=$1
aHost=$2
# Set port only if not empty
if [ ! -z "$4" ] || [ "$4" != "" ]; then
aPort=$4
if [ ! -z "$3" ]; then
aPort=$3
fi
parseList $aList
saveReturn $?
@@ -128,7 +114,7 @@ parseList() {
local errorMsg=""
if [ -z "$1" ] || [ ! -f "$1" ]; then
if [ -z "$1" ] || [ "$1" == "" ] ; then
if [ -z "$1" ]; then
echoerr " [E] No Command list found"
else
echoerr " [E] Command list not found: $1"
@@ -146,21 +132,21 @@ parseList() {
return 1
fi
echo " [I] Parsing $(realpath $1) ..."
echoseq " [I] Parsing $(realpath $1) ..."
local line=1
# Working loop without ssh "stealing standard input" by
# https://unix.stackexchange.com/questions/24260/reading-lines-from-a-file-with-bash-for-vs-while
while IFS='|' read -r lcmd lsrc ldst lopt<&3; do
case "$lcmd" in
h|H|host)
if [ -z "$lsrc" ] || [ "$lsrc" == "" ]; then
if [ -z "$lsrc" ]; then
errorMsg="No host found"
#Prevent unwanted actions if parsing is continued
aHost=""
saveReturn 1
else
aHost="$lsrc"
if [ ! -z "$ldst" ] || [ "$ldst" != "" ]; then
if [ ! -z "$ldst" ]; then
aPort=$ldst
else
# Set port (back) to default in case no port is given
@@ -171,7 +157,7 @@ parseList() {
fi
;;
f|F|file)
if [ -z "$aHost" ] || [ "$aHost" == "" ]; then
if [ -z "$aHost" ]; then
errorMsg="No host found"
saveReturn 1
else
@@ -181,7 +167,7 @@ parseList() {
fi
;;
c|C|command)
if [ -z "$aHost" ] || [ "$aHost" == "" ]; then
if [ -z "$aHost" ]; then
errorMsg="No host found"
saveReturn 1
else
@@ -206,7 +192,7 @@ parseList() {
((line++))
done 3<"$1"
echo " [I] Parsed $((--line)) lines"
echoseq " [I] Parsed $((--line)) lines"
}
listFileTemplate="# following files are send to host given on command line
@@ -224,5 +210,5 @@ f|/sourcedir/sourcefile|/destdir/destfile
f|/sourcedir/sourcefile|/destdir/destfile
c|/destdir2/update.sh"
VERSION_SEQREV=10
VERSION_SEQREV=14
. sequencer.sh