strongswan: remove checks for UCI config

In commit 36e073d820, some checks were
added to see if the UCI config file exists and if there are any peers
configured in it. Due to these checks, if /etc/config/ipsec exists, but
contains no enabled peers, strongswan will not be started. This is not
ideal, as a user might want to experiment with the UCI config while
keeping existing connections in /etc/ipsec.conf operational.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
This commit is contained in:
Stijn Tintel 2017-08-01 02:49:42 +02:00
parent 3097a8919e
commit 44ef6048e2

View file

@ -5,8 +5,6 @@ STOP=10
. $IPKG_INSTROOT/lib/functions.sh . $IPKG_INSTROOT/lib/functions.sh
UCI_IPSEC_CONFIG=/etc/config/ipsec
IPSEC_SECRETS_FILE=/etc/ipsec.secrets IPSEC_SECRETS_FILE=/etc/ipsec.secrets
IPSEC_CONN_FILE=/etc/ipsec.conf IPSEC_CONN_FILE=/etc/ipsec.conf
STRONGSWAN_CONF_FILE=/etc/strongswan.conf STRONGSWAN_CONF_FILE=/etc/strongswan.conf
@ -15,8 +13,6 @@ IPSEC_VAR_SECRETS_FILE=/var/ipsec/ipsec.secrets
IPSEC_VAR_CONN_FILE=/var/ipsec/ipsec.conf IPSEC_VAR_CONN_FILE=/var/ipsec/ipsec.conf
STRONGSWAN_VAR_CONF_FILE=/var/ipsec/strongswan.conf STRONGSWAN_VAR_CONF_FILE=/var/ipsec/strongswan.conf
ENABLED_REMOTE_PEERS=0
file_reset() { file_reset() {
: > "$1" : > "$1"
} }
@ -227,8 +223,6 @@ config_remote() {
config_get_bool enabled "$1" enabled 0 config_get_bool enabled "$1" enabled 0
[ "$enabled" = "0" ] && return [ "$enabled" = "0" ] && return
ENABLED_REMOTE_PEERS=$((ENABLED_REMOTE_PEERS + 1))
config_get gateway "$1" gateway config_get gateway "$1" gateway
config_get pre_shared_key "$1" pre_shared_key config_get pre_shared_key "$1" pre_shared_key
config_get auth_method "$1" authentication_method config_get auth_method "$1" authentication_method
@ -323,7 +317,7 @@ prepare_env() {
start() { start() {
prepare_env prepare_env
[ $ENABLED_REMOTE_PEERS != 0 -o ! -f $UCI_IPSEC_CONFIG ] && ipsec start ipsec start
} }
stop() { stop() {
@ -332,17 +326,15 @@ stop() {
restart() { restart() {
prepare_env prepare_env
[ $ENABLED_REMOTE_PEERS != 0 -o ! -f $UCI_IPSEC_CONFIG ] && ipsec restart || ipsec stop ipsec restart
} }
reload() { reload() {
prepare_env prepare_env
[ $ENABLED_REMOTE_PEERS != 0 -o ! -f $UCI_IPSEC_CONFIG ] && {
ipsec secrets ipsec secrets
if [[ ! -z "$(ipsec status)" ]]; then if [[ ! -z "$(ipsec status)" ]]; then
ipsec reload ipsec reload
else else
ipsec start ipsec start
fi fi
} || ipsec stop
} }