mirror of
https://github.com/pivpn/pivpn.git
synced 2025-05-14 11:54:09 +02:00
refactor(scripts): Structure code as per codestyle
Fix #1636 Refactor code according to code style Constants, Functions, Script
This commit is contained in:
parent
79f7caf4d3
commit
71f7ca9b3b
20 changed files with 377 additions and 342 deletions
|
@ -1,17 +1,14 @@
|
|||
#!/bin/bash
|
||||
# PiVPN: client status script
|
||||
|
||||
### Constants
|
||||
CLIENTS_FILE="/etc/wireguard/configs/clients.txt"
|
||||
|
||||
### Functions
|
||||
err() {
|
||||
echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
|
||||
}
|
||||
|
||||
if [[ ! -s "${CLIENTS_FILE}" ]]; then
|
||||
err "::: There are no clients to list"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
scriptusage() {
|
||||
echo "::: List any connected clients to the server"
|
||||
echo ":::"
|
||||
|
@ -83,6 +80,12 @@ listClients() {
|
|||
grep '\[disabled\] ### begin' wg0.conf | sed 's/#//g; s/begin//'
|
||||
}
|
||||
|
||||
### Script
|
||||
if [[ ! -s "${CLIENTS_FILE}" ]]; then
|
||||
err "::: There are no clients to list"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$#" -eq 0 ]]; then
|
||||
HR=1
|
||||
listClients
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue