# is to determine whether the keactrl command belongs to the list of
# supported commands.
is_in_list() {
- member=${1} # Value to be checked
- list="${2}" # Comma separated list of items
+ local member=${1} # Value to be checked
+ local list="${2}" # Comma separated list of items
_inlist=0 # Return value: 0 if not in list, 1 otherwise.
if [ -z "${member}" ]; then
log_error "missing ${member}"
# be read the function exists with a error message. Note the PID file name
# is always returned in $_pid_file.
get_pid_from_file() {
- proc_name=${1} # Process name.
+ local proc_name=${1} # Process name.
- kea_config_file=
+ local kea_config_file=
case ${proc_name} in
kea-dhcp4)
kea_config_file=${kea_dhcp4_config_file}
esac
# Extract the name portion of the config file
- conf_name=$(basename "${kea_config_file}" | cut -f1 -d'.')
+ local conf_name=$(basename "${kea_config_file}" | cut -f1 -d'.')
# Default the directory to --localstatedir
- pid_file_dir=@localstatedir@/@PACKAGE@
+ local pid_file_dir=@localstatedir@/@PACKAGE@
# Use directory override if set (primarily for testing only)
if [ ! -z "$KEA_PIDFILE_DIR" ]; then
# PID file and checking the PID it contains. If the file does
# not exist, the process is assumed to not be running.
check_running() {
- proc_name=${1} # Process name.
+ local proc_name=${1} # Process name.
# Initially mark the process as not running.
_running=0
# Sends a signal to a process based on its PID file
send_signal() {
- sig=${1} # Signal number
- proc_name=${2} # Process name.
+ local sig=${1} # Signal number
+ local proc_name=${2} # Process name.
get_pid_from_file "${proc_name}"
if [ ${_pid} -eq 0 ]; then
binary_path=${1} # Full path to the binary.
full_command=$@ # Binary and arguments.
# Extract the name of the binary from the path.
- binary_name=$(basename "${binary_path}")
+ local binary_name=$(basename "${binary_path}")
# Use the binary name to check if the process is already running.
check_running "${binary_name}"
# If process is running, don't start another one. Just log a message.
# Instruct Kea process to shutdown by sending it signal 15
stop_server() {
binary_path=${1} # Full path to the binary.
- sig=15
+ local sig=15
# Extract the name of the binary from the path.
- binary_name=$(basename "${binary_path}")
+ local binary_name=$(basename "${binary_path}")
# Use the binary name to check if the process is already running.
check_running "${binary_name}"
# Instruct Kea process to reload config by sending it signal 1
reload_server() {
binary_path=${1} # Full path to the binary.
- sig=1
+ local sig=1
# Extract the name of the binary from the path.
- binary_name=$(basename "${binary_path}")
+ local binary_name=$(basename "${binary_path}")
# Use the binary name to check if the process is already running.
check_running "${binary_name}"
# and be set to yes, e.g. ${dhcp4} should be equal to yes if server name
# is dhcp4
run_conditional() {
- server=${1} # Server name: dhcp4, dhcp6, dhcp_ddns, ctrl_agent, netconf
- commands="${2}" # Commands to execute
- check_file_cfg=${3} # Check if server enabled in the configuration file
- is_all=0 # is all servers or a specific one
+ local server=${1} # Server name: dhcp4, dhcp6, dhcp_ddns, ctrl_agent, netconf
+ local commands="${2}" # Commands to execute
+ local check_file_cfg=${3} # Check if server enabled in the configuration file
+ local is_all=0 # is all servers or a specific one
# If keyword "all" is not on the list of servers we will have to check
# if our specific server is on the list. If, not return.
# Get the configuration value of the keactrl which indicates whether
# the server should be enabled or not. Variables that hold these values
# are: ${dhcp4}, ${dhcp6}, ${dhcp_ddns}.
- file_config=$( eval printf "%s" "\${$server}" )
+ local file_config=$( eval printf "%s" "\${$server}" )
# Get the location of the current Kea configuration file. This will be used
# to check that the file exists before it is used.
- kea_config_location=$( eval printf "%s" "\$kea_${server}_config_file" )
+ local kea_config_location=$( eval printf "%s" "\$kea_${server}_config_file" )
# Run the commands if we ignore the configuration setting or if the
# setting is "yes".
if [ "${check_file_cfg}" -eq 0 ] || [ "${file_config}" = "yes" ]; then