This is a revised version of the Turris documentation here , translated into english and with Maxmilian_Picmaus’s up/down scripts.
This example uses the feature create_notification to send a message according to the settings in the Foris administration section of the Maintenance section.
1. in the file /etc/config/openvpn add:
If you are using Foris openVPN plugin, add it to the section
config openvpn 'server_turris
option script_security '2'
option client_connect '/etc/openvpn/up.sh'
option client_disconnect '/etc/openvpn/down.sh'
2. create a file /etc/openvpn/up.sh
#!/bin/bash
message="$(echo -e "${common_name} connected to: ${HOSTNAME} \\nRemote: ${untrusted_ip} \\nVirtual: ${ifconfig_pool_remote_ip}")"
/usr/bin/create_notification -s news "${message}"
/usr/bin/notifier
exit 0
3. create a file /etc/openvpn/down.sh
#!/bin/bash
message="$(echo -e "${common_name} disconnected from: ${HOSTNAME} \\nRemote: ${untrusted_ip} \\nVirtual: ${ifconfig_pool_remote_ip}")"
/usr/bin/create_notification -s news "${message}"
/usr/bin/notifier
exit 0
4. set the scripts to 0755
chmod 0755 /etc/openvpn/up.sh
chmod 0755 /etc/openvpn/down.sh
5. Make sure scripts are backed-up
If you want to include these extra scripts in the backups of the router, add /etc/openvpn directory to the /etc/config/backups. Something like:
config generate generate
list dirs "/etc/openvpn"
6. Restart OpenVPN
/etc/init.d/openvpn restart