1
0
mirror of synced 2024-12-02 01:26:03 +03:00

Update IKEv2 script

- Minor improvement to IKEv2 config password retrieval
This commit is contained in:
hwdsl2 2022-02-11 21:50:00 -06:00
parent 7e809c2042
commit d20f82e6f2

View File

@ -651,10 +651,8 @@ create_client_cert() {
create_p12_password() { create_p12_password() {
config_file="/etc/ipsec.d/.vpnconfig" config_file="/etc/ipsec.d/.vpnconfig"
if grep -qs '^IKEV2_CONFIG_PASSWORD=.\+' "$config_file"; then p12_password=$(grep -s '^IKEV2_CONFIG_PASSWORD=.\+' "$config_file" | tail -n 1 | cut -f2- -d= | sed -e "s/^'//" -e "s/'$//")
. "$config_file" if [ -z "$p12_password" ]; then
p12_password="$IKEV2_CONFIG_PASSWORD"
else
p12_password=$(LC_CTYPE=C tr -dc 'A-HJ-NPR-Za-km-z2-9' </dev/urandom 2>/dev/null | head -c 18) p12_password=$(LC_CTYPE=C tr -dc 'A-HJ-NPR-Za-km-z2-9' </dev/urandom 2>/dev/null | head -c 18)
[ -z "$p12_password" ] && exiterr "Could not generate a random password for .p12 file." [ -z "$p12_password" ] && exiterr "Could not generate a random password for .p12 file."
mkdir -p /etc/ipsec.d mkdir -p /etc/ipsec.d