mirror of
https://github.com/triffid/pia-wg.git
synced 2026-03-31 06:24:18 -04:00
Add small script to check which server is currently in use
This commit is contained in:
39
pia-currentserver.sh
Executable file
39
pia-currentserver.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z "$CONFIGDIR" ]
|
||||
then
|
||||
if [ $EUID -eq 0 ]
|
||||
then
|
||||
CONFIGDIR="/var/cache/pia-wg"
|
||||
else
|
||||
CONFIGDIR="$HOME/.config/pia-wg"
|
||||
fi
|
||||
mkdir -p "$CONFIGDIR"
|
||||
fi
|
||||
|
||||
if [ -z "$CONFIG" ]
|
||||
then
|
||||
if [ $EUID -eq 0 ]
|
||||
then
|
||||
CONFIG="/etc/pia-wg/pia-wg.conf"
|
||||
else
|
||||
CONFIG="$CONFIGDIR/pia-wg.conf"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$DATAFILE_NEW" ]
|
||||
then
|
||||
DATAFILE_NEW="$CONFIGDIR/data_new.json"
|
||||
fi
|
||||
|
||||
if [ -z "$REMOTEINFO" ]
|
||||
then
|
||||
REMOTEINFO="$CONFIGDIR/remote.info"
|
||||
fi
|
||||
|
||||
if [ -r "$CONFIG" ]
|
||||
then
|
||||
source "$CONFIG"
|
||||
fi
|
||||
|
||||
jq '.regions | .[] | select(.servers.wg[0].ip == "'"$(jq -r .server_ip "$REMOTEINFO")"'")' "$DATAFILE_NEW"
|
||||
Reference in New Issue
Block a user