Skip to content

Instantly share code, notes, and snippets.

@amolpednekar
Created June 26, 2019 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amolpednekar/3551c94c419e01238c1231f889ca99c4 to your computer and use it in GitHub Desktop.
Save amolpednekar/3551c94c419e01238c1231f889ca99c4 to your computer and use it in GitHub Desktop.
Script to copy using scp
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