Docker 容器中实现nginx服务启动前替换指定文件夹下的特定字符串

Docker 容器中实现nginx服务启动前替换指定文件夹下的特定字符串,第1张

#!/bin/bash
echo "update supervisor.config !"
if [ ! -d "/usr/local/pys/" ];then
mkdir -p /usr/local/pys/
else
echo "文件夹/usr/local/pys已经存在"
fi

cd /usr/local/pys/
for file in $(ls *)
do
  python $file
done
  echo "没有需要执行的py脚本"

cd /etc/nginx/conf.d
for file in $(ls *)
do
  mkdir -p /etc/nginx/conf.d.bak/
  cp -rf $file ../conf.d.bak/$file.bak
done
sed -i "s/#PB_GATEWAY/$PB_GATEWAY/g"  `grep \#PB_GATEWAY -rl /etc/nginx/conf.d`
sed -i "s/#IFRAME_ENTRY/$IFRAME_ENTRY/g"  `grep \#IFRAME_ENTRY -rl /etc/nginx/conf.d`
sed -i "s/#IFRAME_PTS/$IFRAME_PTS/g"  `grep \#IFRAME_PTS -rl /etc/nginx/conf.d`
sed -i "s/#PB_GATEWAY/$PB_GATEWAY/g"  `grep \#PB_GATEWAY -rl /home/soft/`
sed -i "s/#IP_ADDR/$IP_ADDR/g"  `grep \#IP_ADDR -rl /home/soft/`

time=$(date "+%Y-%m-%d %H:%M:%S")
filePath="/usr/project/supervisor_file.cfg"
if [ ! -f "$filePath" ];then
supervisorctl update all
sleep 10s
supervisorctl reload
touch $filePath
  echo $time > $filePath
  echo "成功创建认证文件"
else
  echo "已存在认证文件"
fi
 

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/732327.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-27
下一篇 2022-04-27

发表评论

登录后才能评论

评论列表(0条)

保存