#!/bin/sh
echo $script_type > /tmp/script
if [ "$script_type" = "client-connect" ]; then
if [ -f /tmp/$common_name ]; then
/bin/cat /tmp/$common_name > $1
/bin/rm /tmp/$common_name
fi
/usr/bin/env > /tmp/blabla
/bin/echo " user_name: ${common_name}
remote_pub_address: ${trusted_ip}
vpn_client_ip: ${ifconfig_pool_remote_ip}
datetime: $(date +'%Y/%m/%d %H:%M:%S')"| /usr/local/bin/php /usr/local/bin/mail.php -s"${common_name} has connected to the office network via O
penVPN"
elif [ "$script_type" = "client-disconnect" ]; then
command="/sbin/pfctl -a 'openvpn/$common_name' -F rules"
eval $command
/sbin/pfctl -k $ifconfig_pool_remote_ip
/sbin/pfctl -K $ifconfig_pool_remote_ip
/usr/bin/env > /tmp/blabla.exit
/bin/echo " datetime: $(date +'%Y/%m/%d %H:%M:%S')
${username} has disconnected from the office network." | /usr/local/bin/php /usr/local/bin/mail.php -s"${username} has disconnected from the office network!"
fi
Comments