1
0
mirror of synced 2024-11-23 05:26:02 +03:00

Update IKEv2 script

- Cleanup
This commit is contained in:
hwdsl2 2022-02-15 21:17:47 -06:00
parent 4bc8fba344
commit 3d817c7fd4

View File

@ -601,7 +601,7 @@ check_config_password() {
use_config_password=1 use_config_password=1
;; ;;
*) *)
if grep -qs '^IKEV2_CONFIG_PASSWORD=.\+' "$CONFIG_FILE"; then if grep -qs '^IKEV2_CONFIG_PASSWORD=.\+' "$CONF_FILE"; then
use_config_password=1 use_config_password=1
fi fi
;; ;;
@ -719,13 +719,13 @@ get_p12_password() {
if [ "$use_config_password" = "0" ]; then if [ "$use_config_password" = "0" ]; then
create_p12_password create_p12_password
else else
p12_password=$(grep -s '^IKEV2_CONFIG_PASSWORD=.\+' "$CONFIG_FILE" | tail -n 1 | cut -f2- -d= | sed -e "s/^'//" -e "s/'$//") p12_password=$(grep -s '^IKEV2_CONFIG_PASSWORD=.\+' "$CONF_FILE" | tail -n 1 | cut -f2- -d= | sed -e "s/^'//" -e "s/'$//")
if [ -z "$p12_password" ]; then if [ -z "$p12_password" ]; then
create_p12_password create_p12_password
if [ -n "$CONFIG_FILE" ] && [ -n "$CONFIG_DIR" ]; then if [ -n "$CONF_FILE" ] && [ -n "$CONF_DIR" ]; then
mkdir -p "$CONFIG_DIR" mkdir -p "$CONF_DIR"
printf '%s\n' "IKEV2_CONFIG_PASSWORD='$p12_password'" >> "$CONFIG_FILE" printf '%s\n' "IKEV2_CONFIG_PASSWORD='$p12_password'" >> "$CONF_FILE"
chmod 600 "$CONFIG_FILE" chmod 600 "$CONF_FILE"
fi fi
fi fi
fi fi
@ -1291,8 +1291,8 @@ delete_certificates() {
crlutil -D -d "$CERT_DB" -n "$CA_NAME" 2>/dev/null crlutil -D -d "$CERT_DB" -n "$CA_NAME" 2>/dev/null
certutil -F -d "$CERT_DB" -n "$CA_NAME" certutil -F -d "$CERT_DB" -n "$CA_NAME"
certutil -D -d "$CERT_DB" -n "$CA_NAME" 2>/dev/null certutil -D -d "$CERT_DB" -n "$CA_NAME" 2>/dev/null
if grep -qs '^IKEV2_CONFIG_PASSWORD=.\+' "$CONFIG_FILE"; then if grep -qs '^IKEV2_CONFIG_PASSWORD=.\+' "$CONF_FILE"; then
sed -i '/IKEV2_CONFIG_PASSWORD=/d' "$CONFIG_FILE" sed -i '/IKEV2_CONFIG_PASSWORD=/d' "$CONF_FILE"
fi fi
} }
@ -1358,8 +1358,8 @@ ikev2setup() {
CA_NAME="IKEv2 VPN CA" CA_NAME="IKEv2 VPN CA"
CERT_DB="sql:/etc/ipsec.d" CERT_DB="sql:/etc/ipsec.d"
CONFIG_DIR="/etc/ipsec.d" CONF_DIR="/etc/ipsec.d"
CONFIG_FILE="/etc/ipsec.d/.vpnconfig" CONF_FILE="/etc/ipsec.d/.vpnconfig"
IKEV2_CONF="/etc/ipsec.d/ikev2.conf" IKEV2_CONF="/etc/ipsec.d/ikev2.conf"
IPSEC_CONF="/etc/ipsec.conf" IPSEC_CONF="/etc/ipsec.conf"