Created
August 28, 2024 15:29
-
-
Save tommyv1987/66eaf08aac7307d37234cfeeff6a48bf to your computer and use it in GitHub Desktop.
check client ports nym
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
check_dependencies() { | |
if ! command -v wscat &> /dev/null; then | |
echo "wscat is not installed. Installing wscat..." | |
sudo npm install -g wscat | |
else | |
echo "wscat is already installed." | |
fi | |
if ! command -v telnet &> /dev/null; then | |
echo "telnet is not installed. Installing telnet..." | |
sudo apt-get update | |
sudo apt-get install -y telnet | |
else | |
echo "telnet is already installed." | |
fi | |
} | |
check_wss() { | |
read -p "Enter your hostname (e.g., your-nym-node.nym.ch): " hostname | |
read -p "Enter your WSS port (default 9001): " wss_port | |
wss_port=${wss_port:-9001} | |
echo "Checking WSS connection with wscat..." | |
wscat -c wss://$hostname:$wss_port | |
} | |
# Function to test Telnet connection | |
check_telnet() { | |
read -p "Enter your hostname (e.g., your-nym-node.nym.ch): " hostname | |
read -p "Enter your Telnet port (default 9000): " telnet_port | |
telnet_port=${telnet_port:-9000} | |
echo "Checking Telnet connection..." | |
telnet $hostname $telnet_port | |
} | |
renew_certbot() { | |
read -p "Enter your hostname (e.g., your-nym-node.nym.ch): " hostname | |
echo "Stopping Nginx..." | |
sudo systemctl stop nginx | |
echo "Renewing SSL certificates..." | |
sudo certbot certonly --nginx -d $hostname | |
echo "Starting Nginx..." | |
sudo systemctl start nginx | |
echo "SSL certificate renewal process completed." | |
} | |
while true; do | |
echo "Checking dependencies..." | |
check_dependencies | |
echo "Choose an option:" | |
echo "1. Check WSS connection" | |
echo "2. Test Telnet connection" | |
echo "3. Renew SSL certificates with Certbot" | |
echo "4. Exit" | |
read -p "Enter your choice: " choice | |
case $choice in | |
1) | |
check_wss | |
;; | |
2) | |
check_telnet | |
;; | |
3) | |
renew_certbot | |
;; | |
4) | |
echo "Exiting..." | |
exit 0 | |
;; | |
*) | |
echo "Invalid choice, please try again." | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment