ssh执行远程命令和bash -c string的用法

ssh执行远程命令和bash -c string的用法
说明:
今天在学习k8s的Run a Replicated Stateful Application (运行一个有状态应用的副本)时,官网上给出StatefulSet yaml配置文件中出现如下内容:

spec:
      initContainers:
      - name: init-mysql
        image: mysql:5.7
        command:
        - bash
        - "-c"
        - |
          set -ex
          # Generate mysql server-id from pod ordinal index.
          [[ `hostname` =~ -([0-9]+)$ ]] || exit 1
          ordinal=${BASH_REMATCH[1]}
          echo [mysqld] > /mnt/conf.d/server-id.cnf
          # Add an offset to avoid reserved server-id=0 value.
          echo server-id=$((100 + $ordinal)) >> /mnt/conf.d/server-id.cnf
          # Copy appropriate conf.d files from config-map to emptyDir.
          if [[ $ordinal -eq 0 ]]; then
            cp /mnt/config-map/master.cnf /mnt/conf.d/
          else
            cp /mnt/config-map/slave.cnf /mnt/conf.d/
          fi

其中的bash -c有些不明白,所以man bash查看下:

-c string If the -c option is present, then commands are read from string.  If there are arguments after the string, they are assigned to the positional parameters,  starting
                 with $0.

参考文档:
http://baohaojun.github.io/blog/2013/12/11/0-ssh-remote-command-and-bash--c-string.html

转载于:https://blog.51cto.com/wutengfei/2136688

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值