Created
April 11, 2013 07:25
-
-
Save aterga/5361419 to your computer and use it in GitHub Desktop.
This is the bitbucket2masterhost.ru site updater called univup.exp!
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
#!/opt/local/bin/expect -f | |
################################ | |
# Hello, | |
# this | |
# is | |
# the | |
# bitbucket2masterhost.ru | |
# site | |
# updater | |
# called | |
# univup.exp! | |
################################ | |
# Setup: need to change the code below... (1), (2) | |
# Usage: univup.exp [bitbucket_password's_base64_code] [ssh_server_passwprd's_base64_code] | |
# (1) Define Stuff: | |
set SSH_USER_NAME "u123456" | |
set SSH_SERVER "$SSH_USER_NAME@$SSH_USER_NAME.ssh.masterhost.ru" | |
set repo_password [exec echo [lindex $argv 0] | base64 --decode] | |
set ssh_password [exec echo [lindex $argv 1] | base64 --decode] | |
set BASE_LINE "bash-3.2" | |
# Param names: | |
proc univup {project_name repo_user_name team_name repo_project_prefix ssh_project_prefix repo_password ssh_password } { | |
global SSH_SERVER BASE_LINE | |
send -- "curl -u $repo_user_name:$repo_password https://bitbucket.org/$team_name/$project_name/get/master.zip --digest -o /tmp/$project_name.zip\r" | |
expect -exact "\r\n$BASE_LINE\$ " | |
send -- "scp /tmp/$project_name.zip $SSH_SERVER:~\r" | |
expect -exact "\r\nPassword:" | |
send -- "$ssh_password\r" | |
expect -exact "\r\n$BASE_LINE\$ " | |
send -- "rm /tmp/$project_name.zip\r" | |
expect -exact "\r\n$BASE_LINE\$ " | |
send -- "ssh $SSH_SERVER 'rm -fr $ssh_project_prefix && unzip -o -qq $project_name.zip && mv $team_name-$project_name*/$repo_project_prefix $ssh_project_prefix && rm -fr $team_name-$project_name*/ && rm $project_name.zip'\r" | |
expect -exact "\r\nPassword:" | |
send -- "$ssh_password\r" | |
expect -exact "\r\n$BASE_LINE\$ " | |
puts ">>>> Updating project '$project_name' done. <<<<" | |
puts "" | |
} | |
################################ | |
spawn $env(SHELL) | |
match_max 100000 | |
# (2) Usage examples: 'technoblog' is a subproject of 'technoworks.ru', the paths are like this: ~/technoworks.ru/www/blog | |
#proc univup {project_name repo_user_name team_name repo_project_prefix ssh_project_prefix repo_password ssh_password }... | |
univup "technoworks.ru" "wirelesswizard" "technoworks" "" "technoworks.ru" $repo_password $ssh_password | |
univup "technoblog" "wirelesswizard" "wirelesswizard" "www" "technoworks.ru/www/blog" $repo_password $ssh_password | |
send -- "exit\r" | |
expect eof | |
################################ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment