add network switch script
This commit is contained in:
parent
67ec8eebc8
commit
baf5bc4d36
31
packages/reservation-platform/switch_network.sh
Normal file
31
packages/reservation-platform/switch_network.sh
Normal file
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Define the state file
|
||||
STATE_FILE="/tmp/network_toggle_state"
|
||||
|
||||
# Check if the state file exists
|
||||
if [ -f "$STATE_FILE" ]; then
|
||||
# If the state file exists, read the state
|
||||
STATE=$(cat "$STATE_FILE")
|
||||
else
|
||||
# If the state file does not exist, initialize it to "down"
|
||||
STATE="down"
|
||||
echo "$STATE" > "$STATE_FILE"
|
||||
fi
|
||||
|
||||
# Toggle the state
|
||||
if [ "$STATE" == "down" ]; then
|
||||
echo "Bringing interfaces down and up..."
|
||||
sudo ip link set macvlan0 down
|
||||
sudo ip link set macvlan1 down
|
||||
sudo ip link set eth0 down
|
||||
sudo ip link set wlan1 up
|
||||
echo "up" > "$STATE_FILE" # Update the state to "up"
|
||||
else
|
||||
echo "Bringing interfaces up and down..."
|
||||
sudo ip link set wlan1 down
|
||||
sudo ip link set eth0 up
|
||||
sudo ip link set macvlan1 up
|
||||
sudo ip link set macvlan0 up
|
||||
echo "down" > "$STATE_FILE" # Update the state to "down"
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user