]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
local directiver restored
authorTomek Mrugalski <tomasz@isc.org>
Mon, 4 Mar 2019 14:12:08 +0000 (15:12 +0100)
committerTomek Mrugalski <tomek@isc.org>
Wed, 6 Mar 2019 14:15:28 +0000 (09:15 -0500)
src/bin/keactrl/keactrl.in

index 5daf6e3fa46857c2cf1ebba2d9f5ab684423c11a..77c334e79c0ea3a20be88cad51beba8589e7ba1b 100644 (file)
@@ -37,8 +37,8 @@ log_info() {
 # 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}"
@@ -67,9 +67,9 @@ usage() {
 # 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}
@@ -89,10 +89,10 @@ get_pid_from_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
@@ -119,7 +119,7 @@ get_pid_from_file() {
 # 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
 
@@ -137,8 +137,8 @@ check_running() {
 
 # 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
@@ -158,7 +158,7 @@ start_server() {
     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.
@@ -175,9 +175,9 @@ PID ${_pid}, PID file: ${_pid_file}."
 # 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}"
@@ -197,9 +197,9 @@ to process ${proc_name}, PID ${_pid}.\n"
 # 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}"
@@ -258,10 +258,10 @@ check_kea_conf() {
 #   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.
@@ -292,10 +292,10 @@ run_conditional() {
     # 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