From baf5bc4d363d93f74123014ff7e8da551fc50582 Mon Sep 17 00:00:00 2001 From: Torben Haack Date: Wed, 9 Oct 2024 15:23:13 +0200 Subject: [PATCH] add network switch script --- .../reservation-platform/switch_network.sh | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 packages/reservation-platform/switch_network.sh diff --git a/packages/reservation-platform/switch_network.sh b/packages/reservation-platform/switch_network.sh new file mode 100644 index 0000000..c2cffd2 --- /dev/null +++ b/packages/reservation-platform/switch_network.sh @@ -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