Demo entry 6745048

py

   

Submitted by lu on May 25, 2018 at 13:55
Language: Bash. Code size: 1.1 kB.

#
# 模块get
# $1 module
# $2 param
#
dev_config_get() {
    local module=$1
    local param=$2
    local currentTime
    local cfg_file
    local subModule

    currentTime=$(date +%s)
    # 这个世锋实现的,不懂就问他
    if [ "$module" = "configDefault" ]; then
        subModule=$(echo "${param}" | jq  -r '.module')
        if [ -z "$subModule" ]; then
            debug "[get][$module]module is null,exit!"
            return 1
        fi
        cfg_file="${DEV_CONFIG_DIR}${subModule}_${DEV_SN}.json"
        dev_config_save_default_config_commit "$subModule" "true" "false" || return 1
        jq . ${cfg_file} | jq '.'currentTime'="'$currentTime'"'
        return 0
    fi

    cfg_file="${DEV_CONFIG_DIR}${module}_${DEV_SN}.json"
    [ ! -f "$cfg_file" ] && { dev_config_save_default_config_commit "$module" "fasle" "false" || return 1; }
	local cfg_file_num=$(cat $cfg_file) #避免配置文件为空的情况
	[ -z "$cfg_file_num" ] && { dev_config_save_default_config_commit "$module" "fasle" "false" || return 1; } 
    jq . ${cfg_file} | jq '.'currentTime'="'$currentTime'"'
    return 0
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).