diff --git a/auto_install/install.sh b/auto_install/install.sh index 8dbe4f5..6a11ce2 100755 --- a/auto_install/install.sh +++ b/auto_install/install.sh @@ -459,7 +459,7 @@ checkForDependencies() { echo ":::" echo "::: Checking dependencies:" - dependencies=( openvpn git dhcpcd5 tar wget iptables-persistent dnsutils expect whiptail ) + dependencies=( openvpn git dhcpcd5 tar wget grep iptables-persistent dnsutils expect whiptail ) for i in "${dependencies[@]}"; do echo -n "::: Checking for $i..." if [ "$(dpkg-query -W -f='${Status}' "$i" 2>/dev/null | grep -c "ok installed")" -eq 0 ]; then diff --git a/pivpn b/pivpn index 95d53e8..da11162 100644 --- a/pivpn +++ b/pivpn @@ -16,6 +16,11 @@ function makeOVPNFunc { exit 1 } +function listClientsFunc { + $SUDO /opt/pivpn/clientStat.sh + exit 1 +} + function listOVPNFunc { $SUDO /opt/pivpn/listOVPN.sh exit 1 @@ -42,7 +47,7 @@ function uninstallFunc { } function versionFunc { - printf "\e[1mVersion 1.7\e[0m\n" + printf "\e[1mVersion 1.8\e[0m\n" } function helpFunc { @@ -52,6 +57,7 @@ function helpFunc { echo ":::" echo "::: Commands:" echo "::: -a, add [nopass] Create a client ovpn profile, optional nopass" + echo "::: -c, clients List any connected clients to the server" echo "::: -d, debug Start a debugging session if having trouble" echo "::: -l, list List all valid and revoked certificates" echo "::: -r, revoke Revoke a client ovpn profile" @@ -67,6 +73,7 @@ fi # Handle redirecting to specific functions based on arguments case "$1" in "-a" | "add" ) makeOVPNFunc "$@";; +"-c" | "clients" ) listClientsFunc;; "-d" | "debug" ) debugFunc;; "-l" | "list" ) listOVPNFunc;; "-r" | "revoke" ) removeOVPNFunc;; diff --git a/scripts/bash-completion b/scripts/bash-completion index 96398bf..e217755 100644 --- a/scripts/bash-completion +++ b/scripts/bash-completion @@ -4,8 +4,8 @@ _pivpn() COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - dashopts="-a -d -l -r -h -u" - opts="debug add list revoke uninstall help" + dashopts="-a -c -d -l -r -h -u" + opts="debug add clients list revoke uninstall help" if [ "${#COMP_WORDS[@]}" -eq 2 ] then if [[ ${cur} == -* ]] ; then diff --git a/scripts/clientStat.sh b/scripts/clientStat.sh new file mode 100644 index 0000000..834b0dd --- /dev/null +++ b/scripts/clientStat.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# PiVPN: client status script + +STATUS_LOG="/var/log/openvpn-status.log" +printf "\n" +if [ ! -f "${STATUS_LOG}" ]; then + echo "The file: $STATUS_LOG was not found!" + exit 1 +fi + +printf ": NOTE : The output below is NOT real-time!\n" +printf ": : It may be off by a few minutes.\n" +printf "\n" +printf "\e[1m::: Client Status List :::\e[0m\n" +printf "\t\t\t\t\t\t\tBytes\t\tBytes\t\n" +printf "\e[4mName\e[0m\t\t\e[4mRemote IP\e[0m\t\t\e[4mVirtual IP\e[0m\t\e[4mReceived\e[0m\t\e[4mSent\e[0m\t\t\e[4mConnected Since\e[0m \n" +if grep -q "^CLIENT_LIST" "${STATUS_LOG}"; then + awk -F' ' -v s='CLIENT_LIST' '$1 == s {print $2"\t\t"$3"\t"$4"\t"$5"\t\t"$6"\t\t"$8" "$9" "$11" -- "$10}' ${STATUS_LOG} +else + printf "\nNo Clients Connected!\n" +fi +printf "\n" diff --git a/server_config.txt b/server_config.txt index cfa9733..70625e7 100644 --- a/server_config.txt +++ b/server_config.txt @@ -36,6 +36,7 @@ persist-key persist-tun #crl-verify /etc/openvpn/crl.pem status /var/log/openvpn-status.log 20 +status-version 3 log /var/log/openvpn.log verb 1 # Generated for use by PiVPN.io