]> git.ipfire.org Git - people/stevee/network.git/commitdiff
Remove zone_dir and zone_file
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 17 Aug 2017 20:02:42 +0000 (20:02 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 17 Aug 2017 20:06:44 +0000 (20:06 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.colors
src/functions/functions.constants
src/functions/functions.description
src/functions/functions.firewall-zones
src/functions/functions.util
src/functions/functions.zone

index 9a6caff2d14d1c55fa9f695882ea429f3c66d8c9..669587b688d55b88fa7b6050d2c50ea3e296a863 100644 (file)
@@ -155,7 +155,7 @@ color_format_filename() {
                        echo "${NETWORK_IPSEC_CONNS_DIR}/${name}/color"
                        ;;
                zone)
-                       echo "$(zone_dir ${name})/color"
+                       echo "${NETWORK_ZONES_DIR}/${name}/color"
                        ;;
                port)
                        echo "${NETWORK_PORTS_DIR}/${name}/color"
index 0403478ae6e4bdd4ca4fdb4fb0b1e0b9a98e6567..5467801e5f1696d2a51f87c9eca2f1a9150ff559 100644 (file)
@@ -32,11 +32,11 @@ PPP_SECRETS=/etc/ppp/secrets
 # Network directory configuration.
 NETWORK_CONFIG_DIR="/etc/network"
 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_ZONES_DIR="${NETWORK_CONFIG_DIR}/zones"
 NETWORK_SHARE_DIR=/usr/share/network
 NETWORK_CACHE_DIR=/var/cache/network
 
index 6a0206d45139a1ec7e3ba0ab1820395b893355a7..857b3893e31ebaa068b0b688802c0822d8d09fe3 100644 (file)
@@ -29,7 +29,7 @@ description_format_filename() {
                        echo "${NETWORK_IPSEC_CONNS_DIR}/${name}/description"
                        ;;
                zone)
-                       echo "$(zone_dir ${name})/description"
+                       echo "${NETWORK_ZONES_DIR}/${name}/description"
                        ;;
                port)
                        echo "${NETWORK_PORTS_DIR}/${name}/description"
index 6b06fdf4e153b0c7d5dbbf4861639a4569ac74b8..7440a859494c282f4a6e61a58c5fc5d95bd77172 100644 (file)
@@ -39,7 +39,7 @@ firewall_zone_config() {
        local zone=${1}
        assert isset zone
 
-       print "$(zone_dir ${zone})/fwsettings"
+       print "${NETWORK_ZONES_DIR}/${zone}/fwsettings"
        return ${EXIT_OK}
 }
 
index 24e3e66b1682ed536722744a66a618af2f3f8d01..2e76e53fdc3ce761c5170c6140b64094cacdb88c 100644 (file)
@@ -248,11 +248,16 @@ file_get_age() {
        return ${EXIT_ERROR}
 }
 
+make_directory() {
+       local path="${1}"
+
+       mkdir -p "${path}"
+}
+
 make_parent_dir() {
        local path="${1}"
 
-       local dirname="$(dirname "${path}")"
-       mkdir -p "${dirname}"
+       make_directory "$(dirname "${path}")"
 }
 
 enabled() {
index 0d9c29ad3cf57703fdd21c1a85f60fed2b78c6db..f724f503bd182e44869ba9cc82df91cbc654e83d 100644 (file)
 #                                                                             #
 ###############################################################################
 
-zone_dir() {
-       local zone=${1}
-
-       echo "${NETWORK_ZONE_DIR}/zones/${zone}"
-}
-
 zone_exists() {
        local zone=${1}
        assert isset zone
 
-       [ -d "$(zone_dir ${zone})" ]
+       [ -d "${NETWORK_ZONES_DIR}/${zone}" ]
 }
 
 zone_match() {
@@ -68,7 +62,7 @@ zone_get_hook() {
        local zone=${1}
        assert isset zone
 
-       config_get_hook $(zone_dir ${zone})/settings
+       config_get_hook "${NETWORK_ZONES_DIR}/${zone}/settings"
 }
 
 zone_start() {
@@ -233,10 +227,11 @@ zone_new() {
                return ${EXIT_ERROR}
        fi
 
-       mkdir -p $(zone_dir ${zone})
-
        # Create directories for configs and ports
-       mkdir -p $(zone_dir ${zone})/{configs,ports}
+       local what
+       for what in configs ports; do
+               make_directory "${NETWORK_ZONES_DIR}/${zone}/${what}"
+       done
 
        hook_zone_exec "${hook}" "new" "${zone}" "$@"
        local ret=$?
@@ -305,7 +300,7 @@ zone_rename() {
        zone_disable "${zone}"
 
        # Rename the configuration files
-       mv -f "$(zone_dir "${zone}")" "$(zone_dir "${name}")"
+       mv -f "${NETWORK_ZONES_DIR}/${zone}" "${NETWORK_ZONES_DIR}/${name}"
 
        # Enable the zone if it was enabled before
        [ ${zone_was_enabled} -eq ${EXIT_TRUE} ] && zone_enable "${name}"
@@ -335,7 +330,7 @@ zone_destroy() {
        # Disable zone auto-start
        zone_disable "${zone}"
 
-       rm -rf "$(zone_dir "${zone}")"
+       rm -rf "${NETWORK_ZONES_DIR}/${zone}"
 }
 
 zone_up() {
@@ -457,7 +452,7 @@ zone_get_ports() {
        assert isset zone
 
        local port
-       for port in $(list_directory "$(zone_dir ${zone})/ports"); do
+       for port in $(list_directory "${NETWORK_ZONES_DIR}/${zone}/ports"); do
                if port_exists "${port}"; then
                        echo "${port}"
                fi
@@ -470,7 +465,7 @@ zone_get_ports_num() {
 
        local counter=0
        local port
-       for port in $(list_directory "$(zone_dir "${zone}")/ports"); do
+       for port in $(list_directory "${NETWORK_ZONES_DIR}/${zone}/ports"); do
                if port_exists "${port}"; then
                        counter=$(( ${counter} + 1 ))
                fi
@@ -491,7 +486,7 @@ zone_has_port() {
        assert isset zone
        assert isset port
 
-       [ -e "$(zone_dir ${zone})/ports/${port}" ]
+       [ -e "${NETWORK_ZONES_DIR}/${zone}/ports/${port}" ]
 }
 
 zone_config() {
@@ -719,7 +714,7 @@ zones_show() {
 
 zones_get_all() {
        local zone
-       for zone in $(list_directory "$(zone_dir)"); do
+       for zone in $(list_directory "${NETWORK_ZONES_DIR}"); do
                if zone_exists ${zone}; then
                        echo "${zone}"
                fi
@@ -811,7 +806,7 @@ zones_get() {
 zone_ports_list() {
        local zone=${1}
 
-       list_directory "$(zone_dir ${zone})/ports"
+       list_directory "${NETWORK_ZONES_DIR}/${zone}/ports"
 }
 
 zone_port_attach() {
@@ -1076,7 +1071,7 @@ zone_configs_status() {
 zone_configs_list() {
        local zone=${1}
 
-       list_directory "$(zone_dir ${zone})/configs"
+       list_directory "${NETWORK_ZONES_DIR}/${zone}/configs"
 }
 
 zone_config_get_new_id() {
@@ -1085,7 +1080,7 @@ zone_config_get_new_id() {
        assert [ $# -eq 1 ]
        local zone=${1}
 
-       local zone_path=$(zone_dir ${zone})
+       local zone_path="${NETWORK_ZONES_DIR}/${zone}"
        local i=0
 
        while true; do
@@ -1176,7 +1171,7 @@ zone_config_id_is_valid() {
        local zone=${1}
        local id=${2}
 
-       local zone_path=$(zone_dir ${zone})
+       local zone_path="${NETWORK_ZONES_DIR}/${zone}"
 
        [ -f ${zone_path}/configs/*.${id} ];
 }
@@ -1256,14 +1251,6 @@ zone_get_supported_config_hooks() {
        hook_config_get_all
 }
 
-zone_file() {
-       local zone=${1}
-
-       assert isset zone
-
-       echo "$(zone_dir ${zone})/settings"
-}
-
 zone_settings_read() {
        local zone=${1}
        assert isset zone
@@ -1279,7 +1266,7 @@ zone_settings_read() {
        # Save the HOOK variable.
        local hook="${HOOK}"
 
-       settings_read "$(zone_file "${zone}")" ${args}
+       settings_read "${NETWORK_ZONES_DIR}/${zone}/settings" ${args}
 
        # Restore hook.
        HOOK="${hook}"
@@ -1295,7 +1282,7 @@ zone_settings_write() {
        fi
        list_append args ${HOOK_SETTINGS}
 
-       settings_write "$(zone_file ${zone})" ${args}
+       settings_write "${NETWORK_ZONES_DIR}/${zone}/settings" ${args}
 }
 
 zone_settings_set() {
@@ -1345,7 +1332,7 @@ zone_config_settings_read() {
                list_append args "$@"
        fi
 
-       local path="$(zone_dir "${zone}")/configs/${config}"
+       local path="${NETWORK_ZONES_DIR}/${zone}/configs/${config}"
        settings_read "${path}" ${args}
 }
 
@@ -1367,7 +1354,7 @@ zone_config_settings_write() {
        fi
        list_append args ${HOOK_CONFIG_SETTINGS}
 
-       local path="$(zone_dir "${zone}")/configs/${hook}.${id}"
+       local path="${NETWORK_ZONES_DIR}/${zone}/configs/${hook}.${id}"
        settings_write "${path}" ${args}
 }
 
@@ -1377,7 +1364,7 @@ zone_config_settings_destroy() {
        local zone="${1}"
        local config="${2}"
 
-       local path="$(zone_dir "${zone}")/configs/${config}"
+       local path="${NETWORK_ZONES_DIR}/${zone}/configs/${config}"
 
        # Check if path is valid
        if [ ! -f ${path} ]; then
@@ -1403,7 +1390,7 @@ zone_port_settings_read() {
                list_append args "$@"
        fi
 
-       local path="$(zone_dir "${zone}")/ports/${port}"
+       local path="${NETWORK_ZONES_DIR}/${zone}/ports/${port}"
        settings_read "${path}" ${args}
 }
 
@@ -1420,7 +1407,7 @@ zone_port_settings_write() {
        fi
        list_append args ${HOOK_PORT_SETTINGS}
 
-       local path="$(zone_dir "${zone}")/ports/${port}"
+       local path="${NETWORK_ZONES_DIR}/${zone}/ports/${port}"
        settings_write "${path}" ${args}
 }
 
@@ -1430,7 +1417,7 @@ zone_port_settings_remove() {
        local zone="${1}"
        local port="${2}"
 
-       local path="$(zone_dir "${zone}")/ports/${port}"
+       local path="${NETWORK_ZONES_DIR}/${zone}/ports/${port}"
        settings_remove "${path}"
 }