1 Star 0 Fork 170

cmarker/kubernetes-ha-kubeadm-private

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
init.sh 1.00 KB
一键复制 编辑 原始数据 按行查看 历史
liuyi01 提交于 2019-04-05 16:37 . coding
#!/bin/bash
target=target
declare -A kvs=()
function replace_files() {
local file=$1
if [ -f $file ];then
echo "$file"
for key in ${!kvs[@]}
do
value=${kvs[$key]}
value=${value//\//\\\/}
sed -i "s/{{$key}}/${value}/g" $file
done
return 0
fi
if [ -d $file ];then
for f in `ls $file`
do
replace_files "${file}/${f}"
done
fi
return 0
}
rm -fr $target
mkdir -p $target
cp -r configs $target
cp -r scripts $target
cp -r addons $target
cd $target
echo "====替换变量列表===="
while read line;do
if [ "${line:0:1}" == "#" -o "${line:0:1}" == "" ];then
continue;
fi
key=${line/=*/}
value=${line#*=}
echo "$key=$value"
kvs["$key"]="$value"
done < ../global-config.properties
echo -e "\n====替换脚本===="
replace_files scripts
echo -e "\n====替换配置文件===="
replace_files configs
replace_files addons
echo "配置生成成功,位置: `pwd`"
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/cmarker/kubernetes-ha-kubeadm-private.git
git@gitee.com:cmarker/kubernetes-ha-kubeadm-private.git
cmarker
kubernetes-ha-kubeadm-private
kubernetes-ha-kubeadm-private
kubernetes-1.14

搜索帮助

0d507c66 1850385 C8b1a773 1850385