Files
Server-scripts/raspberry/scripts/IFchange.sh
T

20 lines
495 B
Bash
Raw Normal View History

2026-04-14 23:55:26 +02:00
#!/bin/bash
if [ "$1" != "wlan0" ] && [ "$1" != "eth0" ]; then
printf "Wrong Interface, \$1 must be eth0 or wlan0\n";
exit 0
fi
if [ "$(whoami)" != "root" ]; then
printf "Script must be executed as root\n"
exit 0
fi
if [ "$(/sbin/ifconfig | grep eth0)" != "" ]; then
ifdown eth0
fi
if [ "$(/sbin/ifconfig | grep wlan0)" != "" ]; then
ifdown wlan0
fi
cp /etc/network/interfaces.$1 /etc/network/interfaces
ifup $1
/sbin/ifconfig
printf "Network interface has been changed to %s\n" "$1"