Created
June 26, 2019 10:11
-
-
Save amolpednekar/3551c94c419e01238c1231f889ca99c4 to your computer and use it in GitHub Desktop.
Script to copy using scp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set fileformat=unix | |
HOSTS=/root/fabric-network-scripts/hosts_3.txt | |
for peer in `cat $HOSTS`; do | |
IFS=',' | |
ary=($peer) | |
ip=${ary[0]} | |
file_name=${ary[1]} | |
username=${ary[2]} | |
password=${ary[3]} | |
SOURCE=/home/$username/folder1/folder2/ #location of files | |
sshpass -p $password scp -o StrictHostKeyChecking=no -r $file_name $username@$ip:$SOURCE/$file_name | |
sshpass -p $password ssh -o StrictHostKeyChecking=no $ip -l $username docker-compose -f $SOURCE/$file_name up -d | |
done | |
#SAMPLE HOST FILE FOR THE PROGRAM USED ABOVE | |
10.244.5.43,file1.yaml,username,password | |
10.244.5.41,file2.yaml,username,password | |
10.244.5.42,file3.yaml,username,password | |
10.244.5.44,file4.yaml,username,password | |
10.244.5.45,file5.yaml,username,password |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment