###made by h###
echo ---------------------------------
#筛出本机IP并存为变量
IP=`ifconfig | grep -E 'inet.[0-9]' | grep -v '127.0.0.1' | awk '{ print $2}'` ;
echo 本机IP为:::
echo $IP
echo ---------------------------------
echo [开始修改datasource.conf配置文件]
echo ---------------------------------
sleep 2
cd /opt/server/web/ms/etc
#cp datasource.conf.templ datasource.conf
#eval sed用于shell中执行sed方式
eval sed -i 's/localhost/"$IP"/' datasource.conf
#将jdbc.user=后面的替换为root
#将jdbc.password=后面的替换为abc123+
sed -i "s/\(jdbc.user=\)\S\S*/\1root/" datasource.conf
sed -i "s/\(jdbc.password=\)\S\S*/\1abc123+/" datasource.conf
echo [默认修改为root/abc123+ 需要自定义修改请取消下方注释]
#echo 输入本机数据库账号:::
#read sqluser
#echo 输入数据库账号为:::$sqluser
#sed -i "s/\(jdbc.user=\)\S\S*/\1$sqluser/" datasource.conf
#echo ---------------------------------
#echo 输入本机数据库密码:::
#read sqlpass
#echo 输入数据库密码为:::$sqlpass
#sed -i "s/\(jdbc.password=\)\S\S*/\1$sqlpass/" datasource.conf
echo ---------------------------------
sleep 5
#显示第3行至第6行
cat /opt/server/web/ms/etc/datasource.conf|head -n 6 | tail -n +3
echo ---------------------------------
echo ---------------------------------
echo [开始修改ms-config.conf配置文件]
echo ---------------------------------
sleep 5
sed -i "s/\(MS_IP=\)\S\S*/\1$IP/" ms-config.conf
cat /opt/server/web/ms/etc/ms-config.conf|head -n 8 | tail -n +8
echo ---------------------------------
echo [ms-config.conf中只修改了MS_IP 如需修改其他请取消和自定义下方注释]
echo 附加修改项:::
echo
#echo 输入LC_IP:::
#read lc
#echo 输入LC_IP为:::$lc
#sed -i "s/\(LC_IP=\)\S\S*/\1$lc/" ms-config.conf
#echo
#echo 输入AS_FOREIGN_IP:::
#read as1
#echo 输入AS_FOREIGN_IP为:::$as1
#sed -i "s/\(AS_FOREIGN_IP=\)\S\S*/\1$as1/" ms-config.conf
#echo
#echo 输入AS_WEB_IP:::
#read as2
#echo 输入AS_IP为:::$as2
#sed -i "s/\(AS_WEB_IP=\)\S\S*/\1$as2/" ms-config.conf
#echo
#echo 输入AS_WEB_PORT:::
#read as3
#echo 输入AS_WEB_PORT为:::$as3
#sed -i "s/\(AS_WEB_PORT=\)\S\S*/\1$as3/" ms-config.conf
#echo
#echo 输入AS_CONFIG_IP:::
#read as4
#echo 输入AS_CONFIG_IP为:::$as4
#sed -i "s/\(AS_CONFIG_IP=\)\S\S*/\1$as4/" ms-config.conf
#echo
echo ---------------------------------
echo -e "\033[32mFinish[MS配置文件已修改]\033[0m"
echo ---------------------------------
修改配置文件脚本
最新推荐文章于 2024-05-09 18:03:28 发布