linux 下使用配置文件

最近鼓捣双机热备,写了些shell脚本

适用配置文件

以 ifbeat 为例,linux的标准的配置文件中等号两遍不能存在括号, 空格 或特殊符号可以用转衣服 ' '

beat=true
primary=true
vip=12.22.192.146
 

shell中读取配置文件

source 命令会读取配置文件,然后将配置文件中等号左面的key列作为变量读入内存中

source cofingfile

echo $beat      // true
echo $primary   // true
echo $vip       // 12.22.192.146