Sun Cluster 数据服务开发者指南(适用于 Solaris OS)

检验配置

要进行操作,DNS 需要配置目录中 named.conf 文件的信息。 因此,在尝试启动 DNS 之前,Start 方法将执行一些合理性检查,以检验该目录和文件是否可以存取。

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