要进行操作,DNS 需要位于配置目录下的 named.conf 文件中的信息。因此,Start 方法在尝试启动 DNS 之前,将执行一些完整性检查,以验证目录和文件是否可访问。
Confdir 扩展属性提供了指向配置目录的路径。属性本身是在 RTR 文件中定义的,但是,群集管理员在配置数据服务时需指定实际位置。
在数据服务样例中,Start 方法通过使用 scha_resource_get() 函数检索配置目录的位置。
因为 Confdir 是扩展属性,所以 scha_resource_get() 将同时返回类型和值。awk 命令仅检索值并将该值放入 shell 变量 CONFIG_DIR 中。
# find the value of Confdir set by the cluster administrator at the time of # adding the resource. config_info=`scha_resource_get -O Extension -R $RESOURCE_NAME \ -G $RESOURCEGROUP_NAME Confdir` # scha_resource_get returns the "type" as well as the "value" for the # extension properties. Get only the value of the extension property CONFIG_DIR=`echo $config_info | awk '{print $2}'`
Start 方法使用 CONFIG_DIR 的值来验证目录是否可访问。如果该目录不可访问,则 Start 将记录一条错误消息,并在出错状态下退出。请参见Start 退出状态。
# Check if $CONFIG_DIR is accessible. if [ ! -d $CONFIG_DIR ]; then logger -p ${SYSLOG_FACILITY}.err \ -t [$SYSLOG_TAG] \ "${ARGV0} Directory $CONFIG_DIR is missing or not mounted" exit 1 fi
在启动应用程序守护进程之前,此方法将执行 final 检查,以检验 named.conf 文件是否存在。如果该文件不存在,则 Start 将记录一条错误消息,并在出错状态下退出。
# Change to the $CONFIG_DIR directory in case there are relative # pathnames in the data files. cd $CONFIG_DIR # Check that the named.conf file is present in the $CONFIG_DIR directory if [ ! -s named.conf ]; then logger -p ${SYSLOG_FACILITY}.err \ -t [$SYSLOG_TAG] \ "${ARGV0} File $CONFIG_DIR/named.conf is missing or empty" exit 1 fi