Shell 操作练习2

时间:2023-12-23 10:13:38
#! /bin/sh
###############################
# -- #
# author jackluo #
# net.webjoy@gmail.com #
###############################
serverid=$ #服务器的id
api_url=$ #API服务器的url地址
api_file_path=/home/wwwroot/cy/application/config/server_lists_config.php #文件的url 路径
if [ -z "${serverid}" ] || [ -z "${api_url}" ];then
echo "你要提供两个参数第一个是serverid第二个是api_url地址 不够"
exit
fi
sed -i '$d' ${api_file_path} #删除最后一行
echo " '${serverid}'=> array(
'KEY' => "passed",
'MAIL_GIFT_URL' => 'http://${api_url}/mailgift',
'SEND_NOTICE_URL' => 'http://${api_url}/broadcast',
'GM_TOOLS_URL' =>'http://${api_url}/ban'
),
);" >> ${api_file_path}
sed -i 's/\r//' ${api_file_path}