你的位置:首页 > 操作系统

[操作系统]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}