#!/bin/bash # Auteur : Belgotux # Site : www.monlinux.net # Adresse : belgotux@monlinux.net # Version : 1.0 # Date : 08-03-2015 # Licence : GPLv3 # Changelog : # Description : # use openvpn local environment variable, see openvpn man # In your server config file : # client-connect /usr/local/bin/openvpn-notify.sh # client-disconnect /usr/local/bin/openvpn-notify.sh MAILTO=root function connect-action () { mail-notify } function disconnect-action () { mail-notify } function mail-notify () { (echo " action = $script_type VPN = $config Common name = $common_name Public IP address = $trusted_ip VPN get address = $ifconfig_remote" ) | mail -s "$script_type $(basename $config .conf) $common_name" $MAILTO return $? } case $script_type in client-connect) connect-action ;; client-disconnect) disconnect-action ;; *) exit 0 ;; esac exit 0