#!/bin/sh
-# Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
fi
}
+### Functions testing the existence of the Kea config file
+
+# Check if the Kea configuration file location has been specified in the
+# keactrl configuration file. If not, it is a warning or a fatal error.
+check_kea_conf() {
+ local conf_file=${1} # Kea config file name.
+ if [ -z ${conf_file} ]; then
+ log_error "Configuration file for Kea not specified."
+ exit 1
+ elif [ ! -f ${conf_file} ]; then
+ log_error "Configuration file for Kea does not exist: ${conf_file}."
+ exit 1
+ fi
+}
+
### Script starts here ###
# Configure logger to log messages into the file.
exit 1
fi
-# Check if the Kea configuration file location has been specified in the
-# keactrl configuration file. If not, it is a fatal error.
-if [ -z ${kea_config_file} ]; then
- log_error "Configuration file for Kea not specified."
- exit 1
-elif [ ! -f ${kea_config_file} ]; then
- log_error "Configuration file for Kea does not exist: ${kea_config_file}."
- exit 1
-fi
-
# dhcp4 and dhcp6 (=yes) indicate if we should start DHCPv4 and DHCPv6 server
# respectively.
dhcp4=$( printf "%s" ${dhcp4} | tr [:upper:] [:lower:] )
case ${command} in
# Start the servers.
start)
+ check_kea_conf ${kea_config_file}
+
args="-c ${kea_config_file}"
if [ "${kea_verbose}" = "yes" ]; then
# Stop running servers.
stop)
+ check_kea_conf ${kea_config_file}
+
# Stop all servers or servers specified from the command line.
run_conditional "dhcp4" "send_signal 15 $(basename ${dhcp4_srv})" 0
run_conditional "dhcp6" "send_signal 15 $(basename ${dhcp6_srv})" 0
# Reconfigure the servers.
reload)
+ check_kea_conf ${kea_config_file}
+
# Reconfigure all servers or servers specified from the command line.
run_conditional "dhcp4" "send_signal 1 $(basename ${dhcp4_srv})" 0
run_conditional "dhcp6" "send_signal 1 $(basename ${dhcp6_srv})" 0
printf "Kea configuration file: %s\n" ${kea_config_file}
printf "keactrl configuration file: %s\n" ${keactrl_conf}
+ check_kea_conf ${kea_config_file}
+
exit 0 ;;
# No other commands are supported.
#!/bin/sh
-# Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
+# Copyright (C) 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
assert_string_contains "DHCP DDNS: inactive" "${output}" \
"Expected keactrl status command return %s"
+ # Make sure that the status command no longer checks first config file
+ printf "Getting status without a Kea config file\n"
+ mv ${CFG_FILE} ${CFG_FILE}.saved
+ output=$( ${keactrl} status -c ${KEACTRL_CFG_FILE} )
+ ret=${?}
+ mv ${CFG_FILE}.saved ${CFG_FILE}
+ assert_eq 1 ${ret} "Expected keactrl to return %d, returned %d"
+ assert_string_contains "DHCPv4 server: active" "${output}" \
+ "Expected keactrl status command return %s"
+ assert_string_contains "DHCPv6 server: inactive" "${output}" \
+ "Expected keactrl status command return %s"
+ assert_string_contains "DHCP DDNS: inactive" "${output}" \
+ "Expected keactrl status command return %s"
+ assert_string_contains "Configuration file for Kea does not exist" \
+ "${output}" "Expected keactrl status command return %s"
+
# Use keactrl stop to shutdown the servers.
printf "Stopping Kea: ${keactrl} stop -c ${KEACTRL_CFG_FILE}\n"
${keactrl} stop -c ${KEACTRL_CFG_FILE}