#! /bin/bash
oci_cli_server=$(oci -v)
if [ "$oci_cli_server" == "" ]; then
echo "请运行 bash <(curl –L -s https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)"
echo "安装oci—cli"
echo "详细教程请访问 https://him.plus/archives/274 第二小节"
else
oracle_Replace_ip_file="/root/oracle_Replace/oracle_Replace_ip.sh"
wget -P /root/oracle_Replace -N https://pan.him.plus/shell/oracle_Replace_ip.sh
read -p "请输入CF邮箱：" cf_email
read -p "请输入CF密钥：" cf_key
read -p "请输入根域名（域名需在CF托管）：" web_name
read -p "请输入二级域名（如 www.example.com）：" web_url
#替换CloudFlare参数
sed -i "s|cf_email|$cf_email|" $oracle_Replace_ip_file
sed -i "s|cf_key|$cf_key|" $oracle_Replace_ip_file
sed -i "s|example.com|$web_name|" $oracle_Replace_ip_file
sed -i "s|www.example.com|$web_url|" $oracle_Replace_ip_file
read -p "几分钟运行一次：" restart_time
crontab_job="${restart_time} * * * * bash /root/oracle_Replace/oracle_Replace_ip.sh"
  (
    crontab -l | grep -v "$crontab_job"
    echo -e "$crontab_job"
  ) | crontab -
echo "日志文件：
甲骨文更换ip日志：/root/oracle_Replace/oracle_Replace_ip.log
CF DDNS日志：/root/oracle_Replace/cloudflare.log
"
fi

