mirror of
https://github.com/edu4rdshl/linuxscripts.git
synced 2026-07-17 23:24:52 +00:00
Update
This commit is contained in:
parent
f861b7da1a
commit
73c0b80493
2 changed files with 40 additions and 21 deletions
|
|
@ -6,28 +6,47 @@
|
||||||
# Autor: Eduard Toloza
|
# Autor: Eduard Toloza
|
||||||
|
|
||||||
# Define variables
|
# Define variables
|
||||||
services='systemd-networkd iwd systemd-resolved randomvpn'
|
services='systemd-networkd systemd-resolved randomvpn' # iwd
|
||||||
|
bond_active=$(ip -o link show type bond | awk -F': ' '{print $2}')
|
||||||
|
|
||||||
if [ "$1" == "f" ]; then
|
restart_network() {
|
||||||
sudo systemctl restart $services
|
|
||||||
|
#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 9.9.9.9 > /dev/null; then
|
||||||
|
echo "Your connection is not working, restarting your network services: $services"
|
||||||
|
# Delete bond interfaces if they exists
|
||||||
|
if [ ! -z "$bond_active" ] ; then
|
||||||
|
for bond_iface in "$bond_active"; do
|
||||||
|
ip link delete $bond_iface
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
# Restart services
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$UID" != 0 ]; then
|
||||||
|
echo "You don't have root permisions."
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Check if ping command is available
|
# Check if the f options was passed to force restart of services
|
||||||
if command -v ping > /dev/null; then
|
if [ "$1" == "f" ]; then
|
||||||
# Check internet connection and if not OK then restart all networking services
|
systemctl restart $services
|
||||||
echo "Testing your connection..."
|
exit
|
||||||
if ! ping -q -c 1 -W 1 9.9.9.9 > /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
|
fi
|
||||||
|
|
||||||
|
restart_network
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ ethernet _first_ {
|
||||||
|
|
||||||
path_exists bond {
|
path_exists bond {
|
||||||
format = "Bonding: active"
|
format = "Bonding: active"
|
||||||
format_down = "Bond: down"
|
format_down = "Bonding: down"
|
||||||
path = "/proc/net/bonding/bond1"
|
path = "/proc/net/bonding/bond1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue