On a Ubuntu 16.04.2 server, I have a simple expect script /etc/pipes.expect
to setup vm routing through the server's ports.
Here is the content of /etc/pipes.expect
:
#!/usr/bin/expect -f
sleep 60
spawn virsh start lucas
spawn virsh start ssix-project
spawn virsh start allsorter
sleep 300 #some time to boot the vms
spawn ssh -f -N -L [my_ip]:22003:localhost:22 lucas@ssix-project
expect "*assword:*" { send "[pass1]\r" }
expect "*yes/no*" {
send "yes\r"
expect "*assword:*" { send "[pass1]\r" }
}
spawn ssh -f -N -L [my_ip]:22004:localhost:22 lucas@allsorter
expect "*assword:*" { send "[pass2]\r" }
expect "*yes/no*" {
send "yes\r"
expect "*assword:*" { send "[pass2]\r"}
}
spawn ssh -f -N -L [my_ip]:22002:localhost:22 lucas@lucas
expect "*assword:*" { send "pass3\r" }
expect "*yes/no*" {
send "yes\r"
expect "*assword:*" { send "pass\r"}
}
The script runs perfectly if I call it with:
/etc/pipes.expect
, expect /etc/pipes.expect
or /usr/bin/expect /etc/pipes.expect
But the ssh
calls don't take effect when pipes.expect
is called via pipes.service
. What bugs me is that the virsh
calls(lines 3 to 5) work when the script is called manually or by the service.
Here is the content of my pipes.service
:
[Unit]
Description=Spark service
[Service]
ExecStart=/usr/bin/expect /etc/pipes.expect
[Install]
WantedBy=multi-user.target
P.S.: I've tried many methods of making this script run on boot, including init.d, crontab, rc.local and nothing seems to work :(. Can anyone light things over here a bit?
Thanks.