This allows all users who are given permission in sudoers to take the network up and down with a quick command, without logging in as root.
Call it int, and stick it in /usr/bin
Code:
#!/bin/sh
testIfUp() {
sudo /sbin/ifconfig | awk 'BEGIN {found = 0}
/^eth0/ {found=1}
END {printf("%s",found)} '
}
FOUND=$(testIfUp)
if [ $FOUND -eq 0 ]
then
echo Bringing up
sudo /sbin/ifup eth0
else
echo Taking down
sudo /sbin/ifdown eth0
fi