[root@controller01 home]# cat expect.sh
#!/bin/bash
read -p "please put IP address:" IP
read -p "please put password:" PASSWORD
/usr/bin/expect <<-END
set timeout 3000
spawn ssh root@$IP
expect {
"*yes/no" { send "yes\r";exp_continue}
"*Y/N" {send "Y\r";exp_continue}
"*password" {send "$PASSWORD\r"}
}
expect "#*" {
send "yum install epel-release -y\r"
send "yum clean all && yum repolist\r"
send "yum install docker -y\r"
send "systemctl start docker && systemctl enable docker\r"
send "docker load -i /root/registry_latest.tar \r"
send "docker run -d -p 9999:5000 -v /root/tj2.0-release:/var/lib/registry --restart=always --name registry f32a97de94e1 \r"
send "exit\r"
}
#interact
expect eof
exit
END
sleep 15
curl -l $IP:9999/v2/_catalog
##执行:sh expet.sh