為了執行作業,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 |
在啟動應用程式常駐程式之前,該方法將執行最後的檢查,以驗證 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 |