first push
This commit is contained in:
52
distribute.sh
Normal file
52
distribute.sh
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/bin/bash
|
||||
|
||||
## Author Oriol Filter
|
||||
# Date 16/02/2022
|
||||
|
||||
|
||||
## Find which user is the correct one
|
||||
|
||||
### VAR
|
||||
export _USERS="$(cat ./users)"
|
||||
|
||||
|
||||
### Main
|
||||
|
||||
sed '/^$/d' h | tee ./curr_h >/dev/null # remove empty lines
|
||||
|
||||
printf "Attempting to SSH\n"
|
||||
|
||||
for u in $_USERS
|
||||
do
|
||||
printf "\033[0;33m $u\n\033[0m"
|
||||
rm ./${u}/h
|
||||
touch ./${u}/h
|
||||
for h in $(cat ./curr_h)
|
||||
do
|
||||
printf "${h}: -->"
|
||||
# sshpass -f "./${u}/p" ssh -q -o GSSAPIAuthentication=no -o StrictHostKeyChecking=no -T "${u}@${h}" 'echo true' &> /dev/null &&
|
||||
|
||||
sshpass -f "./${u}/p" ssh -q -o StrictHostKeyChecking=no -T "${u}@${h}" 'echo true' &> /dev/null &&
|
||||
printf "${h}: \033[1;32mYES \033[0m\n" &&
|
||||
printf "${h}\n" | tee -a "./${u}/h" > /dev/null ||
|
||||
printf "${h}: \033[1;31mNo \033[0m\n" < "./${u}/p"
|
||||
done
|
||||
diff --new-line-format="" --unchanged-line-format="" ./curr_h "${u}/h" > left_h
|
||||
mv ./left_h ./curr_h
|
||||
done
|
||||
mv curr_h discards_h
|
||||
|
||||
printf "Distributed hosts\n"
|
||||
|
||||
for u in $_USERS
|
||||
do
|
||||
printf "\033[0;32m $u\n\033[0m"
|
||||
awk '{ printf" %s\n",$0 }' < "./${u}/h"
|
||||
done
|
||||
|
||||
printf "\033[0;31mDISCARDS:\033[0m\n"
|
||||
awk '{ printf" %s\n",$0 }' < ./discards_h
|
||||
|
||||
printf "Discards are stored in './discards_h'\n"
|
||||
|
||||
bash ./send_files.sh
|
||||
Reference in New Issue
Block a user