shell脚本初始化nacos

shell脚本初始化nacos

#!/bin/bash
#

choose_nacos() {
    # 重新选择
 
    echo '欢迎进行naocs服务配置'
    echo 'q.结束'
    
    echo '端口是否修改,默认值8848'
    echo '回车键结束该配置分配默认值'

    read  port

    if [ -z "$port" ];then
        echo ''
    else
        sudo sed -i "23s/.*/ server.port=$port/" nacos/conf/application.properties    
    fi

   

	# 修改nacos数据  11.162.196.16:3306/nacos_devtest
    echo  "请输入数据库链接url,格式:11.162.196.16:3306/nacos_devtest  "

    read -p '请输入数据库url'  dburl
    read -p '请输入数据库user: '   dbuser
    read -p '请输入数据库pwd: '   dbpwd

    sudo sed -i "41s|.*| db.url.0=jdbc:mysql://$dburl?characterEncoding=utf8\&connectTimeout=1000\&socketTimeout=3000\&autoReconnect=true|" nacos/conf/application.properties
    sudo sed -i "42s/.*/ db.user.0=$dbuser/" nacos/conf/application.properties
    sudo sed -i "43s/.*/ db.password.0=$dbpwd/" nacos/conf/application.properties


    # 是否进行集群配置

    echo '是否进行集群类型配置'
    echo '1:进行集群配置'
    echo '其余内容或回车结束配置'
   
    read -p "请输出:"  select
    
    if [[ $select != 1 ]];then
        echo '欢迎再次使用'
        echo '单应用启动命令: sh startup.sh -m standalone'
        exit 1
    else
      
      sudo cp nacos/conf/cluster.conf.example  nacos/conf/cluster.conf
      sed -i '/192.168.16.10/d'   nacos/conf/cluster.conf


      echo '请输入ip 地址,q 键或回车退出该配置'
      echo 'example ip'
      echo ' 192.168.16.101:8847'
      echo ' 192.168.16.102'

     while true; do  
       read -p "请输入ip地址: " input  
       if [[ "$input" == "q" || $input == "" ]]; then  
         break
       fi  
       sudo echo $input >> nacos/conf/cluster.conf

     done  
    
    echo '配置结束'
    echo '集群应用启动命令: sh startup.sh'
    echo 'ng配置'
    echo upstream nacos-cluster { 
    echo    server 127.0.0.1:8848; 
    echo    server 127.0.0.2:8848; 
    echo    server 127.0.0.3:8848; 
    echo } 

    # 集群Http方式入口 8848
    echo server {
    echo   listen       8848;
    echo   server_name  xxxx.xxxx.xxxx.xxxx;

    echo   lient_max_body_size 100m;
    echo   proxy_max_temp_file_size 100m;
    
    echo   location / { 
    echo      proxy_pass http://nacos-cluster; 
    echo   } 
    echo }






    fi


}

choose_nacos 0



你可能感兴趣的:(linux,运维开发,spring,cloud)