Browse Source

rsync support

Nathaniel van Diepen 10 years ago
parent
commit
5b83d3d482
1 changed files with 51 additions and 14 deletions
  1. 51 14
      bin/repo-update

+ 51 - 14
bin/repo-update

@@ -18,6 +18,33 @@ for val in "${sites[@]}"; do
 	if ! $force || [[ "$host_to_sync" == "all" ]] || [[ "$host_to_sync" == "$user@$host" ]];then
 		echo "Updating $user@$host";
 		case ${site[type]} in
+			rsync)
+				rsyncd(){
+					echo -e "\t\tSyncing $1";
+					expect -c "
+						set timeout 1
+						log_user 0
+						spawn rsync -ra --exclude=\".gitignore\" --exclude=\"$reponame.db\" $1 $user@$host:${site[root]};
+						expect {
+							yes/no {
+								send yes\r;
+								exp_continue
+							}
+							password: {
+								send $(echo ${site[password]} | base64 --decode | gpg -d -q --no-mdc-warning)\r 
+								set timeout -1
+							}
+							eof {
+								exit
+							}
+						}
+					";
+				}
+				echo -e "\tUploading files to ${site[root]}";
+				rsyncd $root/skel/;
+				rsyncd $root/repo/latest/;
+				echo -e "\tDone.";
+			;;
 			ssh)
 				escp(){
 					length=$(($#-1));
@@ -26,13 +53,18 @@ for val in "${sites[@]}"; do
 						set timeout 1
 						log_user 0
 						spawn scp -r $files \"$user@$host:${site[root]}/${!#}\"
-						expect yes/no { send yes\r ; exp_continue }
-						expect password: {
-							send $(echo ${site[password]} | base64 --decode | gpg -d -q --no-mdc-warning)\r 
-							set timeout -1
-						}
-						expect eof {
-							exit
+						expect {
+							yes/no {
+								send yes\r;
+								exp_continue
+							}
+							password: {
+								send $(echo ${site[password]} | base64 --decode | gpg -d -q --no-mdc-warning)\r 
+								set timeout -1
+							}
+							eof {
+								exit
+							}
 						}";
 				}
 				essh(){
@@ -41,13 +73,18 @@ for val in "${sites[@]}"; do
 						set timeout 1
 						log_user 0
 						spawn ssh $user@$host $args
-						expect yes/no { send yes\r ; exp_continue }
-						expect password: {
-							send $(echo ${site[password]} | base64 --decode | gpg -d -q --no-mdc-warning)\r 
-							set timeout -1
-						}
-						expect eof {
-							exit
+						expect {
+							yes/no {
+								send yes\r;
+								exp_continue
+							}
+							password: {
+								send $(echo ${site[password]} | base64 --decode | gpg -d -q --no-mdc-warning)\r 
+								set timeout -1
+							}
+							eof {
+								exit
+							}
 						}";
 				}
 				upload_local_dir(){