智能
助手
最大化  清空记录 停止  历史记录
翻译选中文本
选中一段文本后进行翻译
名词解释
选中一段文本后进行名词解释
知识图谱生成
通过图谱展示知识信息
登录用户在知识浏览页面可用
答案生成
AI自动回答一个问答功能中的问题
登录用户在问答浏览页面,且问题开放回答中可用
知识摘要
自动为当前知识生成摘要
知识浏览页面可用
知识问答
针对当前知识进行智能问答
知识浏览面可用
   1105  
查询码: 00000139
一键安装程序,expect自动交互
作者: wyasw 于 2020年03月29日 发布在分类 / Linux / 常用shell脚本 ,于 2020年03月29日 编辑
shell

需求:一键安装程序,需要用到expect自动交互。

#!/bin/bash

basedir=`cd $(dirname $0); pwd -P`

cd $basedir


function YumDokcer(){

yum install -y yum-utils device-mapper-persistent-data lvm2

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

yum install docker-ce -y

systemctl start docker.service

systemctl enable docker.service

docker pull golang:alpine

docker pull alpine

}

rpm -qa |grep docker &>/dev/null

if [ $? -ne 0 ];then

    YumDokcer

fi

if [ $? -ne 0 ];then

    echo 'Dcoekr build error !!!'

    exit 1

fi

docker image ls|awk -F " "  '{ print $1 }'|grep golang &>/dev/null

if [ $? -ne 0 ];then

    docker pull golang:alpine

fi

if [ $? -ne 0 ] ;then

    echo 'docker pull golang:alpine error !!!'

    exit 1

fi


install_file=`ls -l bcb-node_*.tar.gz| grep ^[^d] | awk '{print $9}'`

if [ ! -f "$install_file" ];then

    echo 'The installation file does not exist !!!'

    exit 1

  else

    tar xf $install_file

fi

rpm -q expect &> /dev/null

if [ $? -ne 0 ] ;then

        yum install -y expect

fi

if [ $? -ne 0 ] ;then

    echo 'Install expect error !!!'

    exit 1

fi


#expect install.expect

/usr/bin/expect  << EOF

set timeout -1 

spawn  /bin/bash setup.sh

expect {

 "#?" {send "2\r";exp_continue}

 "node or FOLLOWER to follow:" {send "earth.testchain.io \r";exp_continue}

 "#?" {send "2\r";exp_continue}

 "nodes or FOLLOWERs to follow:" {send "earth.testchain.io \r"}

}

expect eof

EOF


笔记
0人参与


 历史版本

备注 修改日期 修改人
创建版本 2020-03-29 21:02:00[当前版本] wyasw

文艺知识分享平台 -V 5.2.5 -wcp