From: Michael Tremer Date: Sun, 30 Jul 2017 13:29:13 +0000 (+0200) Subject: ipsec: Move connections to /etc/network/vpn/ipsec/connections X-Git-Tag: 009~99 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cf8685a166497c0112342ec17a4d549280404ff3;p=network.git ipsec: Move connections to /etc/network/vpn/ipsec/connections Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.constants b/src/functions/functions.constants index d9ece3ea..aa7c3eba 100644 --- a/src/functions/functions.constants +++ b/src/functions/functions.constants @@ -37,6 +37,8 @@ NETWORK_HOOKS_DIR=/usr/lib/network/hooks NETWORK_TRIGGERS_DIR=/usr/lib/network/triggers NETWORK_SHARE_DIR=/usr/share/network +NETWORK_IPSEC_CONNS_DIR="${NETWORK_CONFIG_DIR}/vpn/ipsec/connections" + # Network file configuration. NETWORK_SETTINGS_FILE=${NETWORK_CONFIG_DIR}/config NETWORK_SETTINGS_FILE_PARAMS="DEBUG" diff --git a/src/functions/functions.ipsec b/src/functions/functions.ipsec index 11e2e9ae..86bbdd73 100644 --- a/src/functions/functions.ipsec +++ b/src/functions/functions.ipsec @@ -96,7 +96,7 @@ ipsec_connection_write_config() { return ${EXIT_ERROR} fi - local path="$(ipsec_connection_path "${connection}")/settings" + local path="${NETWORK_IPSEC_CONNS_DIR}/${connection}/settings" if ! settings_write "${path}" ${IPSEC_CONNECTION_CONFIG_SETTINGS}; then log ERROR "Could not write configuration settings for VPN IPsec connection ${connection}" @@ -160,7 +160,7 @@ ipsec_connection_read_config() { list_append args $@ fi - local path="$(ipsec_connection_path "${connection}")/settings" + local path="${NETWORK_IPSEC_CONNS_DIR}/${connection}/settings" if ! settings_read "${path}" ${args}; then log ERROR "Could not read settings for VPN IPsec connection ${connection}" @@ -168,15 +168,6 @@ ipsec_connection_read_config() { fi } -# Returns the path to a the directory for given connection -ipsec_connection_path() { - assert [ $# -eq 1 ] - - local connection=${1} - - echo "${NETWORK_CONFIG_DIR}/vpn/ipsec/connection/${connection}" -} - # This function checks if a vpn ipsec connection exists # Returns True when yes and false when not ipsec_connection_exists() { @@ -184,7 +175,7 @@ ipsec_connection_exists() { local connection=${1} - local path=$(ipsec_connection_path "${connection}") + local path="${NETWORK_IPSEC_CONNS_DIR}/${connection}" [ -d "${path}" ] && return ${EXIT_TRUE} || return ${EXIT_FALSE} } @@ -595,7 +586,7 @@ ipsec_connection_new() { log DEBUG "Creating VPN IPsec connection ${connection}" - if ! mkdir -p $(ipsec_connection_path "${connection}"); then + if ! mkdir -p "${NETWORK_IPSEC_CONNS_DIR}/${connection}"; then log ERROR "Could not create config directory for ${connection}" return ${EXIT_ERROR} fi @@ -623,7 +614,7 @@ ipsec_connection_destroy() { fi log DEBUG "Deleting VPN IPsec connection ${connection}" - if ! rm -rf $(ipsec_connection_path "${connection}"); then + if ! rm -rf "${NETWORK_IPSEC_CONNS_DIR}/${connection}"; then log ERROR "Deleting the VPN IPsec connection ${connection} was not sucessful" return ${EXIT_ERROR} fi