From: Michael Tremer Date: Thu, 17 Aug 2017 19:49:16 +0000 (+0000) Subject: Dropping port_dir() X-Git-Tag: 010~243 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0d994c190b457e83c4030369925e1fef83bdd653;p=network.git Dropping port_dir() This function is always returning constant values but needs to fork a subshell for that which has some performance impact. Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.colors b/src/functions/functions.colors index 816af487..9a6caff2 100644 --- a/src/functions/functions.colors +++ b/src/functions/functions.colors @@ -158,7 +158,7 @@ color_format_filename() { echo "$(zone_dir ${name})/color" ;; port) - echo "$(port_dir ${name})/color" + echo "${NETWORK_PORTS_DIR}/${name}/color" ;; esac } diff --git a/src/functions/functions.constants b/src/functions/functions.constants index c2db955c..0403478a 100644 --- a/src/functions/functions.constants +++ b/src/functions/functions.constants @@ -35,6 +35,7 @@ NETWORK_DB_DIR="${RUN_DIR}/db" NETWORK_ZONE_DIR="${NETWORK_CONFIG_DIR}" NETWORK_HOOKS_DIR=/usr/lib/network/hooks NETWORK_HELPERS_DIR=/usr/lib/network/helpers +NETWORK_PORTS_DIR="${NETWORK_CONFIG_DIR}/ports" NETWORK_TRIGGERS_DIR=/usr/lib/network/triggers NETWORK_SHARE_DIR=/usr/share/network NETWORK_CACHE_DIR=/var/cache/network diff --git a/src/functions/functions.description b/src/functions/functions.description index 728ec2ca..6a0206d4 100644 --- a/src/functions/functions.description +++ b/src/functions/functions.description @@ -32,7 +32,7 @@ description_format_filename() { echo "$(zone_dir ${name})/description" ;; port) - echo "$(port_dir ${name})/description" + echo "${NETWORK_PORTS_DIR}/${name}/description" ;; esac } diff --git a/src/functions/functions.ports b/src/functions/functions.ports index 2537f815..82945a8f 100644 --- a/src/functions/functions.ports +++ b/src/functions/functions.ports @@ -19,13 +19,8 @@ # # ############################################################################### -port_dir() { - local port="${1}" - echo "${NETWORK_CONFIG_DIR}/ports/${port}" -} - port_list() { - list_directory "$(port_dir)" + list_directory "${NETWORK_PORTS_DIR}" } port_list_in_use() { @@ -108,7 +103,7 @@ port_file() { local port="${1}" assert isset port - echo "$(port_dir ${port})/settings" + echo "${NETWORK_PORTS_DIR}/${port}/settings" } port_exists() { @@ -193,7 +188,7 @@ port_destroy() { return ${EXIT_ERROR} fi - rm -rf $(port_dir ${port}) + rm -rf "${NETWORK_PORTS_DIR}/${port}" } port_create() { @@ -274,7 +269,7 @@ port_cmd() { ports_get() { local port - for port in $(list_directory "$(port_dir)"); do + for port in $(list_directory "${NETWORK_PORTS_DIR}"); do if port_exists ${port}; then echo "${port}" fi