]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blame - scripts/send_and_run.tcl
Merge branch 'dev'
[perso/Immae/Projets/Puppet.git] / scripts / send_and_run.tcl
CommitLineData
c15f2234
IB
1#!/usr/bin/expect -f
2set dest [lindex $argv 0]
3set password [lindex $argv 1]
4set git_branch [lindex $argv 2]
5set environment [lindex $argv 3]
6set script [lindex $argv 4]
7set files [lrange $argv 4 end]
8
69da835d 9if {$password == "x"} {
c15f2234
IB
10 set ask_password 0
11} else {
12 set ask_password 1
13}
14
15set scriptname [file tail $script]
16
17set sshopts [split "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o CheckHostIP=no"]
18
19set timeout -1
20spawn scp {*}$sshopts {*}$files $dest:/tmp
21if {$ask_password} {
22 expect "assword:"
23 send "$password\n"
24}
25expect eof
26spawn ssh {*}$sshopts $dest /tmp/$scriptname $git_branch $environment
27if {$ask_password} {
28 expect "assword:"
29 send "$password\n"
30}
31expect eof