diff --git a/auto_install/install.sh b/auto_install/install.sh index c1a6676..778ed9e 100755 --- a/auto_install/install.sh +++ b/auto_install/install.sh @@ -1129,6 +1129,13 @@ installPiVPN(){ echo "pivpnPROTO=${pivpnPROTO}" >> ${tempsetupVarsFile} echo "pivpnMTU=${pivpnMTU}" >> ${tempsetupVarsFile} + # Write PERSISTENTKEEPALIVE if provided via unattended file + # May also be added manually to /etc/pivpn/wireguard/setupVars.conf + # post installation to be used for client profile generation + if [ "$pivpnPERSISTENTKEEPALIVE" ]; then + echo "pivpnPERSISTENTKEEPALIVE=${pivpnPERSISTENTKEEPALIVE}" >> ${tempsetupVarsFile} + fi + fi { diff --git a/examples/unattended_wireguard_example.conf b/examples/unattended_wireguard_example.conf index c8e354e..1316313 100644 --- a/examples/unattended_wireguard_example.conf +++ b/examples/unattended_wireguard_example.conf @@ -9,4 +9,5 @@ pivpnPORT=51820 pivpnDNS1=9.9.9.9 pivpnDNS2=149.112.112.112 pivpnHOST=pivpn.example.com +pivpnPERSISTENTKEEPALIVE=25 UNATTUPG=1 diff --git a/scripts/wireguard/makeCONF.sh b/scripts/wireguard/makeCONF.sh index 17b55c7..82bcd01 100755 --- a/scripts/wireguard/makeCONF.sh +++ b/scripts/wireguard/makeCONF.sh @@ -120,6 +120,10 @@ PublicKey = $(cat keys/server_pub) PresharedKey = $(cat "keys/${CLIENT_NAME}_psk") Endpoint = ${pivpnHOST}:${pivpnPORT} AllowedIPs = ${ALLOWED_IPS}" >> "configs/${CLIENT_NAME}.conf" + +if [ -n "${pivpnPERSISTENTKEEPALIVE}" ]; then + echo "PersistentKeepalive = ${pivpnPERSISTENTKEEPALIVE}" >> "configs/${CLIENT_NAME}.conf" +fi echo "::: Client config generated" echo "### begin ${CLIENT_NAME} ###