Browse Source

fix shellcheck warn and shfmt the code

pull/6456/head
XuChao 4 months ago
parent
commit
bc190dd865
  1. 30
      deploy/ikuai.sh

30
deploy/ikuai.sh

@ -28,10 +28,10 @@ ikuai_deploy() {
_debug _cca "$_cca"
_debug _cfullchain "$_cfullchain"
[ -n "$IKUAI_SCHEME" ] || IKUAI_SCHEME=http
[ -n "$IKUAI_HOSTNAME" ] || IKUAI_HOSTNAME=192.168.9.1
[ -n "$IKUAI_SCHEME" ] || IKUAI_SCHEME="http"
[ -n "$IKUAI_HOSTNAME" ] || IKUAI_HOSTNAME="192.168.9.1"
[ -n "$IKUAI_PORT" ] || IKUAI_PORT=80
[ -n "$IKUAI_USERNAME" ] || IKUAI_USERNAME=admin
[ -n "$IKUAI_USERNAME" ] || IKUAI_USERNAME="admin"
# Get deploy conf
_getdeployconf IKUAI_SCHEME
@ -51,7 +51,7 @@ ikuai_deploy() {
_debug2 IKUAI_USERNAME "$IKUAI_USERNAME"
_secure_debug2 IKUAI_PASSWORD "$IKUAI_PASSWORD"
_debug "Login to ikuai ..."
_info "Login to ikuai ..."
_ikuai_url="$IKUAI_SCHEME://$IKUAI_HOSTNAME:$IKUAI_PORT"
_pass_md5="$(printf "%s" "$IKUAI_PASSWORD" | _digest md5 hex | _lower_case)"
_pass_salt="$(printf "salt_11%s" "$IKUAI_PASSWORD" | _base64)"
@ -61,13 +61,13 @@ ikuai_deploy() {
_response=$(_post "$_login_req" "$_ikuai_url/Action/login" "" "POST" "application/json")
if ! _contains "$_response" 'ErrMsg'; then
_err 'Failed to login to ikuai : $_response'
if ! _contains "$_response" "ErrMsg"; then
_err "Failed to login to ikuai : $_response"
return 1
fi
_err_msg="$(printf "%s" "$_response" | _normalizeJson | _egrep_o '"ErrMsg":"[^"]*"' | cut -d'"' -f4)"
# check ErrMsg
if [ "$_err_msg" != "Success" ];then
if [ "$_err_msg" != "Success" ]; then
_err "Failed to login to ikuai: $_err_msg"
return 1
fi
@ -77,7 +77,7 @@ ikuai_deploy() {
_err "Fail to get the cookie."
return 1
fi
_debug "Login to ikuai success ,now save the config ... "
_info "Login to ikuai success ,now save the config ... "
# Save the config
_savedeployconf IKUAI_SCHEME "$IKUAI_SCHEME"
@ -89,11 +89,11 @@ ikuai_deploy() {
# Set cookie header
_H1="Cookie: $_cookie username=$IKUAI_USERNAME; login=1"
_debug "Deploy the cert to ikuai ... "
_info "Deploy the cert to ikuai ... "
# Should replace \n to @ ," " to #
_cert_content_single_line="$(cat "$_ccert" | tr '\n' '@' | tr ' ' '#')"
_key_content_single_line="$(cat "$_ckey" | tr '\n' '@' | tr ' ' '#')"
_cert_content_single_line="$(<"$_ccert" tr '\n' '@' | tr ' ' '#')"
_key_content_single_line="$(<"$_ckey" tr '\n' '@' | tr ' ' '#')"
_debug2 _cert_content_single_line "$_cert_content_single_line"
_debug2 _key_content_single_line "$_key_content_single_line"
@ -103,16 +103,16 @@ ikuai_deploy() {
_err_msg="$(printf "%s" "$_response" | _normalizeJson | _egrep_o '"ErrMsg":"[^"]*"' | cut -d'"' -f4)"
if ! _contains "$_response" 'ErrMsg'; then
_err 'Failed to save cert to ikuai : $_response'
if ! _contains "$_response" "ErrMsg"; then
_err "Failed to save cert to ikuai : $_response"
return 1
fi
# check ErrMsg
if [ "$_err_msg" != "Success" ];then
if [ "$_err_msg" != "Success" ]; then
_err "Failed to save cert to ikuai: $_err_msg"
return 1
fi
_debug "Deploy the cert to ikuai success ,now enjoy it :>! "
_info "Deploy the cert to ikuai success ,now enjoy it :>! "
return 0
}
Loading…
Cancel
Save