Skip to content

Commit bef6588

Browse files
authored
Merge pull request #135 from Tunnelsats/sub-display
bash-script for TS details
2 parents dcbfa41 + abc2c95 commit bef6588

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

FAQ.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@ In addition you can chat to our hosted [Tunnel⚡Sats Bot](https://t.me/TunnelSa
302302
### How can I verify that my VPN connection is online and active?
303303

304304
On console, run the following WireGuard command to see some connection statistics, especially check latest handshake for an active VPN connection: `sudo wg show`.
305+
You can also download a helper script to check your configuration:
306+
```
307+
$ wget -O tunnelsats-sub-details.sh https://github.com/tunnelsats/tunnelsats/raw/main/scripts/tunnelsats-sub-details.sh
308+
$ sudo bash tunnelsats-sub-details.sh
309+
```
305310

306311
If you're on Telegram, you can chat to our hosted [Tunnel⚡Sats Bot](https://t.me/TunnelSatsBot) and send a `/ping [pubkey@tor.onion]` or `/ping [pubkey@tunnelsats-clearnetIP:port]` to check for a positive connection and speed-report.
307312

scripts/tunnelsats-sub-details.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/bin/bash
2+
3+
# Check if script is run with sudo
4+
if [ "$EUID" -ne 0 ]; then
5+
echo "Please run as root: sudo bash tunnelsats-sub-details.sh"
6+
exit 1
7+
fi
8+
9+
# Help text
10+
if [[ "$1" == "-h" ]]; then
11+
echo "Usage: sudo bash tunnelsats-sub-details.sh"
12+
echo "This script provides details about your Tunnel⚡️Sats subscription."
13+
echo "Beware of scammers, don't ever share your private key."
14+
exit 0
15+
fi
16+
17+
# Function to check Wireguard status and config file
18+
check_wireguard_status() {
19+
wg_output=$(sudo wg show)
20+
if ! echo "$wg_output" | grep -q "interface: tunnelsatsv2"; then
21+
config_file="/etc/wireguard/tunnelsatsv2.conf"
22+
if [ ! -f "$config_file" ]; then
23+
echo "The wireguard tunnel seems to be offline, and no tunnelsatsv2.conf could be found in the wireguard directory."
24+
echo "Please try a reinstall per https://guide.tunnelsats.com"
25+
echo "Alternatively, visit the Tunnel⚡️Sats Telegram Chat: https://t.me/tunnelsats"
26+
return 1
27+
else
28+
echo "The wireguard tunnel seems to be offline. Please try restarting your node."
29+
return 1
30+
fi
31+
fi
32+
return 0
33+
}
34+
35+
# Call the function to check Wireguard status
36+
check_wireguard_status
37+
if [ $? -ne 0 ]; then
38+
exit 1
39+
fi
40+
41+
interface="tunnelsatsv2"
42+
latest_handshake=$(echo "$wg_output" | grep -A 12 "interface: $interface" | grep 'latest handshake' | awk -F': ' '{print $2}')
43+
transfer=$(echo "$wg_output" | grep -A 12 "interface: $interface" | grep 'transfer' | awk -F': ' '{print $2}')
44+
public_key=$(echo "$wg_output" | grep -A 5 "interface: $interface" | grep 'public key' | awk -F': ' '{print $2}')
45+
46+
# Display summary
47+
echo -e "\e[1;32m=================================\e[0m"
48+
echo -e "\e[1;32mTunnel⚡️Sats Subscription Summary\e[0m"
49+
echo -e "\e[1;32m=================================\e[0m"
50+
echo -e "My Wireguard Tunnel Public Key: \e[1;34m$public_key\e[0m"
51+
echo -e "My transfer since last tunnel restart: \e[1;34m$transfer\e[0m"
52+
echo -e "Latest handshake with the Tunnel Server: \e[1;34m$latest_handshake\e[0m"
53+
echo ""
54+
echo "To validate your subscription details, copy your Wireguard Tunnel Public Key and visit 'https://tunnelsats.com/ > Renew'."
55+
echo "Use Telegram Reminder Bot to add a secure and anon reminder when your subscription runs out: https://t.me/TunnelSatsReminderBot."
56+
echo ""
57+
echo "Thank you for using our Service"

0 commit comments

Comments
 (0)