又是一个比较长的函数,是用来检查文件权限,目录条件的。具体代码如下:
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.
#
tip文件是安装完成后的一些账号密码文件,此处初始化该文件
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在conf/global中定义,他的值是 #export CONFIG_VIA_DIALOG="${DIALOG_DIR}/config_via_dialog.sh" 执行窗口安装程序,开始新的安装
. ${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
}