mirror of
https://github.com/Ascyii/scripts.git
synced 2026-01-01 12:54:24 -05:00
20 lines
392 B
Bash
Executable File
20 lines
392 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Check if an interface name is provided
|
|
#if [ -z "$1" ]; then
|
|
# echo "Usage: $0 <interface_name>"
|
|
# exit 1
|
|
#fi
|
|
|
|
INTERFACE="wlo1"
|
|
|
|
# Parse the interface state from `ip a`
|
|
STATE=$(ip a show "$INTERFACE" 2>/dev/null | grep -oP '(?<=state )\w+')
|
|
|
|
# Check if the interface exists
|
|
if [ $STATE = "UP" ]; then
|
|
sudo ip link set $INTERFACE down
|
|
else
|
|
sudo ip link set $INTERFACE up
|
|
fi
|