Fix: scp-to-all-nodes args

This commit is contained in:
kayos@tcp.direct 2022-10-21 16:04:45 -07:00
parent 892a953ce6
commit 1c37f507e8
Signed by: kayos
GPG Key ID: 4B841471B4BEE979
2 changed files with 10 additions and 6 deletions

View File

@ -12,11 +12,11 @@ _recursive=false
if [[ "$1" == "-r" ]]; then
_recursive=true
_targetFile="$2"
else
_targetFile="$1"
shift
fi
_targetFile="$1"
if ! [[ -f "$_targetFile" ]]; then
echo -n "file not found: $1"
exit 1
@ -40,9 +40,9 @@ get-targets | while read -r line; do
if ! ignore "$line"; then
echo "copying to $line"
if $_recursive; then
scp -r "$_targetFile" "$line$_targetDir"
scp -r "$_targetFile" "$line$_targetDir"&
else
scp "$_targetFile" "$line$_targetDir"
scp "$_targetFile" "$line$_targetDir"&
fi
fi
done

6
lib.sh
View File

@ -1,7 +1,11 @@
#!/usr/bin/env bash
_dir="$(dirname -- "$0")/.."
_var="$_dir/var.sh"
source "$_var"
get-targets() {
cat /etc/hosts | awk '{print $NF}' | grep -v localhost | grep -v "$(uname -n | awk -F '.' '{print $1}')" | /bin/grep "[a-z]"
awk '{print $NF}' /etc/hosts | grep -v localhost | grep -v "$(uname -n | awk -F '.' '{print $1}')" | /bin/grep "[a-z]"
}
ignore() {