This is Ubuntu 18.04.
I have tried several different permutations of online advice, but the script is not being executed.
I have tried client-connect, up and route-up, none of them make the script run.
I have tested the script on its own and it runs successfully, the email is sent fine.
I have removed this from the .service files:
Code: Select all
PrivateTmp=True
With the client-connect set, it makes my VPN unusable (client can't connect).
I have also tried to include the --script security and --client-connect options in the exec command in the .service file, no luck.
UPDATE: I have added 'exit 0' to my script, and now the client connects to the VPN successfully. But the script still doesn't run (no email).
Also one of the many things I am not very clear on is - options set in server.conf need to be matched in my ovpn file, right? So these should go in both files:
Code: Select all
script-security 2
client-connect /etc/openvpn/server/connect-email-simple.sh
My server.conf:
Code: Select all
local x.x.x.x
port xx
proto udp
dev tun
ca ca.crt
cert server.crt
key server.key
dh dh.pem
auth SHA512
tls-crypt tc.key
topology subnet
script-security 2
client-connect /etc/openvpn/server/connect-email-simple.sh
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 1.1.1.1"
push "dhcp-option DNS 1.0.0.1"
keepalive 10 120
cipher AES-256-CBC
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
verb 3
crl-verify crl.pem
management localhost 6666
explicit-exit-notify 0
duplicate-cn
Code: Select all
#!/bin/bash
echo "VPN is connected" | mail -s "OpenVPN Connected!" my@email.address