歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

check_env函數解析

又是一個比較長的函數,是用來檢查文件權限,目錄條件的。具體代碼如下:
check_env()
{
    # Check user privilege.
    #檢查用戶權限
    check_user root

    # Check FQDN hostname.
    #檢查主機名是否符合規則
    check_hostname

    # Check config tool: dialog.
    #檢查配置工具dialog是否存在
    check_pkg ${BIN_DIALOG} ${PKG_DIALOG}

    ECHO_INFO -n "Checking configuration file: ${IREDMAIL_CONFIG_FILE} ..."
    #判斷配置文件是否存在,默認的安裝包下是沒有的,應該是用於安裝中斷後,恢復安裝的。
    if [ -f ${IREDMAIL_CONFIG_FILE} ]; then
        if grep '^#EOF$' ${IREDMAIL_CONFIG_FILE} >/dev/null; then
            echo -e " [FOUND]"
            ECHO_QUESTION -n "Use it for mail server setting? [y|N]"
            
            #讀取已經存在的配置文件
            read_setting ${AUTO_USE_EXISTING_CONFIG_FILE}
            #給用戶一個選擇,是用已經存在的配置文件,還是重新安裝
            case $ANSWER in
                Y|y )
                    ECHO_INFO "Use config file: ${IREDMAIL_CONFIG_FILE} for mail server setting."
                    . ${IREDMAIL_CONFIG_FILE}

                    # Check installation status.
                    # After each component installation was completed, there
                    # should be a variable in ${STATUS_FILE}, e.g.
                    #
                    #   export STATUS_PHP_INSTALLATION='DONE'
                    #   export STATUS_PHP_CONFIGURATION='DONE'
                    #
                    #判斷狀態文件是否存在,如果存在則讀取狀態文件
                                    if [ -f ${STATUS_FILE} ]; then
                        ECHO_INFO "Import installation process status from file: ${STATUS_FILE}."
                        . ${STATUS_FILE}
                    else
                        echo '' > ${STATUS_FILE}
                    fi

                    # Initialize tip file.
                    if [ ! -f ${TIP_FILE} ]; then
                        cat > ${TIP_FILE} <<EOF
${CONF_MSG}
EOF
                    fi
                    ;;
                N|n|* )
                    ECHO_INFO "Skip configuration file: ${IREDMAIL_CONFIG_FILE}."
                    . ${CONFIG_VIA_DIALOG}
                    ;;
            esac
        else
            ECHO_INFO "Found, but not finished."
            . ${CONFIG_VIA_DIALOG}
        fi
    else
        ECHO_INFO "[NOT FOUND]"
        . ${CONFIG_VIA_DIALOG}
    fi

    check_runtime_dir
}

 

Copyright © Linux教程網 All Rights Reserved