🔨adjust

This commit is contained in:
Leon 2021-08-07 20:45:56 +08:00
parent 7189cff146
commit 808d8bfffe
2 changed files with 15 additions and 15 deletions

View File

@ -145,19 +145,19 @@ set_default_code(){
sed -i "/^repo6=/a\repo7='yuannian1112_jd_scripts'" $code_shell_path sed -i "/^repo6=/a\repo7='yuannian1112_jd_scripts'" $code_shell_path
fi fi
} }
# 将 bash code.sh 添加到定时任务 # 将 task code.sh 添加到定时任务
add_bash_code(){ add_task_code(){
if [ "$(grep -c "code.sh" /ql/config/crontab.list)" != 0 ]; then if [ "$(grep -c "code.sh" /ql/config/crontab.list)" != 0 ]; then
echo "您的任务列表中已存在 task:bash code.sh" echo "您的任务列表中已存在 task:task code.sh"
else else
echo "开始添加 task:bash code.sh" echo "开始添加 task:task code.sh"
# 获取token # 获取token
token=$(cat /ql/config/auth.json | jq --raw-output .token) token=$(cat /ql/config/auth.json | jq --raw-output .token)
curl -s -H 'Accept: application/json' -H "Authorization: Bearer $token" -H 'Content-Type: application/json;charset=UTF-8' -H 'Accept-Language: zh-CN,zh;q=0.9' --data-binary '{"name":"格式化更新助力码","command":"bash /ql/config/code.sh &","schedule":"*/10 * * * *"}' --compressed 'http://127.0.0.1:5700/api/crons?t=1626247939659' curl -s -H 'Accept: application/json' -H "Authorization: Bearer $token" -H 'Content-Type: application/json;charset=UTF-8' -H 'Accept-Language: zh-CN,zh;q=0.9' --data-binary '{"name":"格式化更新助力码","command":"task /ql/config/code.sh","schedule":"*/10 * * * *"}' --compressed 'http://127.0.0.1:5700/api/crons?t=1626247939659'
fi fi
} }
if [ "${all}" = 1 ]; then if [ "${all}" = 1 ]; then
dl_code_shell && set_default_code && add_bash_code dl_code_shell && set_default_code && add_task_code
elif [ "${code}" = 'n' ]; then elif [ "${code}" = 'n' ]; then
echo "已为您跳过操作 code.sh" echo "已为您跳过操作 code.sh"
else else
@ -168,7 +168,7 @@ else
set_default_code set_default_code
fi fi
if [[ ${code} =~ 'c' ]]; then if [[ ${code} =~ 'c' ]]; then
add_bash_code add_task_code
fi fi
fi fi

View File

@ -192,30 +192,30 @@ set_default_code(){
sed -i "/^repo6=/a\repo7='yuannian1112_jd_scripts'" $code_shell_path sed -i "/^repo6=/a\repo7='yuannian1112_jd_scripts'" $code_shell_path
fi fi
} }
# 将 bash code.sh 添加到定时任务 # 将 task code.sh 添加到定时任务
add_bash_code(){ add_task_code(){
if [ "$(grep -c "code.sh" /ql/config/crontab.list)" != 0 ]; then if [ "$(grep -c "code.sh" /ql/config/crontab.list)" != 0 ]; then
echo "您的任务列表中已存在 task:bash code.sh" echo "您的任务列表中已存在 task:task code.sh"
else else
echo "开始添加 task:bash code.sh" echo "开始添加 task:task code.sh"
# 获取token # 获取token
token=$(cat /ql/config/auth.json | jq --raw-output .token) token=$(cat /ql/config/auth.json | jq --raw-output .token)
curl -s -H 'Accept: application/json' -H "Authorization: Bearer $token" -H 'Content-Type: application/json;charset=UTF-8' -H 'Accept-Language: zh-CN,zh;q=0.9' --data-binary '{"name":"格式化更新助力码","command":"bash /ql/config/code.sh &","schedule":"*/10 * * * *"}' --compressed 'http://127.0.0.1:5700/api/crons?t=1626247939659' curl -s -H 'Accept: application/json' -H "Authorization: Bearer $token" -H 'Content-Type: application/json;charset=UTF-8' -H 'Accept-Language: zh-CN,zh;q=0.9' --data-binary '{"name":"格式化更新助力码","command":"task /ql/config/code.sh","schedule":"*/10 * * * *"}' --compressed 'http://127.0.0.1:5700/api/crons?t=1626247939659'
fi fi
} }
if [ "${all}" = 1 ]; then if [ "${all}" = 1 ]; then
get_valid_code && dl_code_shell && set_default_code && add_bash_code get_valid_code && dl_code_shell && set_default_code && add_task_code
elif [ "${code}" = 'n' ]; then elif [ "${code}" = 'n' ]; then
echo "已为您跳过操作 code.sh" echo "已为您跳过操作 code.sh"
else else
if [[ ${code} =~ 'a' ]]; then if [[ ${code} =~ 'a' ]]; then
get_valid_code && dl_code_shell dl_code_shell
fi fi
if [[ ${code} =~ 'b' ]]; then if [[ ${code} =~ 'b' ]]; then
set_default_code set_default_code
fi fi
if [[ ${code} =~ 'c' ]]; then if [[ ${code} =~ 'c' ]]; then
add_bash_code add_task_code
fi fi
fi fi