mirror of
https://github.com/edu4rdshl/linuxscripts.git
synced 2026-07-17 23:24:52 +00:00
Added randomvpn service and script
This commit is contained in:
parent
f2a3e2faf2
commit
f35da46f10
5 changed files with 70 additions and 2 deletions
|
|
@ -1,28 +0,0 @@
|
|||
#!/bin/sh
|
||||
# Script to check your internet connection and if it's not OK
|
||||
# then restart your network services. Make sure that you've the appropiates
|
||||
# service names in the $services variable
|
||||
#
|
||||
# Autor: Eduard Toloza
|
||||
|
||||
# Define variables
|
||||
services='Put here the service names that you want to restart if internet connection is not available, the services must be sepparated by spaces. Example: systemd-resolved systemd-networkd openvpn'
|
||||
|
||||
#Check if ping command is available
|
||||
if command -v ping > /dev/null; then
|
||||
# Check internet connection and if not OK then restart all networking services
|
||||
echo "Testing your connection..."
|
||||
if ! ping -q -c 1 -W 1 1.1.1.1 > /dev/null; then
|
||||
echo "Your connection is not working, restarting your network services: $services"
|
||||
sudo systemctl restart $services
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Services restarted sucessfully, leaving."
|
||||
else
|
||||
echo "An error has occurred, make sure that service names are correct."
|
||||
fi
|
||||
else
|
||||
echo "Your connection is OK"
|
||||
fi
|
||||
else
|
||||
echo "ping command is not available, aborting."
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue