diff --git a/docker/Dockerfile b/docker/Dockerfile index aabae0ba..b759760d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -24,6 +24,7 @@ RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories nginx \ python3 \ yarn \ + jq \ && rm -rf /var/cache/apk/* \ && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && echo "Asia/Shanghai" > /etc/timezone \ diff --git a/shell/api.sh b/shell/api.sh index 1627468e..b633ff40 100755 --- a/shell/api.sh +++ b/shell/api.sh @@ -1,8 +1,7 @@ #!/usr/bin/env bash get_token() { - local authInfo=$(cat $AuthConf) - token=$(get_json_value "$authInfo" "token") + token=$(cat $AuthConf | jq -r .token) } get_json_value() { @@ -42,8 +41,7 @@ add_cron_api() { -H "Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7" \ --data-raw "{\"name\":\"$name\",\"command\":\"$command\",\"schedule\":\"$schedule\"}" \ --compressed) - echo $api - code=$(get_json_value $api "code") + code=$(echo $api | jq -r .code) if [[ $code == 200 ]]; then echo -e "$name 添加成功" else @@ -63,8 +61,7 @@ del_cron_api() { -H "Origin: http://localhost:5700" \ -H "Referer: http://localhost:5700/crontab" \ -H "Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7") - echo $api - code=$(get_json_value $api "code") + code=$(echo $api | jq -r .code) if [[ $code == 200 ]]; then echo -e "$name 删除成功" else