加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

SHELL 中直接替换 template 中变量方法

发布时间:2020-12-15 09:16:11 所属栏目:安全 来源:网络整理
导读:目标: 分别定义 parameter template 文件利用 shell 直接一次性替换 template 中变量 parameter 文件 cephuuid= c45b752d- 5 d4d- 4 d3a-a3b2- 04 e73eff4ccd cephmonhost= hh-ceph- 128040 ,hh-ceph- 128214 ,hh-ceph- 128215 cephmonipaddr= 10.199 . 128.

目标:

分别定义 parameter  template 文件
利用 shell 直接一次性替换 template 中变量

parameter 文件

cephuuid=c45b752d-5d4d-4d3a-a3b2-04e73eff4ccd
cephmonhost=hh-ceph-128040,hh-ceph-128214,hh-ceph-128215
cephmonipaddr=10.199.128.40,10.199.128.214,10.199.128.215
cephmonnetwork=10.199.128.0/22
cephdatanetwork=240.30.128.0/21
cephpgnum=1024
cephpgpnum=1024

template 文件

[global]
fsid = $cephuuid
mon initial members = $cephmonhost
mon host = $cephmonipaddr
public network = $cephmonnetwork
cluster network = $cephdatanetwork
auth cluster required = cephx
auth service required = cephx
auth client required = cephx
osd journal size = 2048
filestore xattr use omap = true
osd pool default size = 3
osd pool default min size = 1
osd pool default pg num = $cephpgnum
osd pool default pgp num = $cephpgpnum
osd crush chooseleaf type = 1

执行方法

#!/bin/bash
source parameter

eval "cat <<EOF $(<ceph.conf.template) EOF " 2> /dev/null

结果

[root@hh-ceph-128040 ceph]# . gen_ceph_conf.sh
[global]
fsid = c45b752d-5d4d-4d3a-a3b2-04e73eff4ccd
mon initial members = hh-ceph-128040,hh-ceph-128215
mon host = 10.199.128.40,10.199.128.214,10.199.128.215
public network = 10.199.128.0/22
cluster network = 240.30.128.0/21
auth cluster required = cephx
auth service required = cephx
auth client required = cephx
osd journal size = 2048
filestore xattr use omap = true
osd pool default size = 3
osd pool default min size = 1
osd pool default pg num = 1024
osd pool default pgp num = 1024
osd crush chooseleaf type = 1

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读