Created
November 5, 2012 01:33
-
-
Save polachok/4014764 to your computer and use it in GitHub Desktop.
wireless/wired with failover
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
function run(cmd) { | |
if (system(cmd) != 0) | |
exit 1 | |
} | |
BEGIN { | |
networks["my-super-network"] = "u1tr@SecURep@ssw0rd111" | |
iface = "wpi0" | |
wired = "em0" | |
printf("Network to connect:\n") | |
for (n in networks) { | |
printf(" %d.%s\n", i++, n) | |
} | |
getline reply | |
i = 0 | |
for (n in networks) { | |
if (reply == i++) | |
break | |
} | |
run(sprintf("sudo ifconfig %s nwid \"%s\" wpakey \"%s\"", iface, n, networks[n])) | |
run(sprintf("sudo ifconfig %s up", wired)) | |
run(sprintf("sudo ifconfig %s up", iface)) | |
run(sprintf("sudo ifconfig trunk0 destroy")) | |
run(sprintf("sudo ifconfig trunk0 trunkport %s trunkport %s trunkproto failover", wired, iface)) | |
run(sprintf("sudo dhclient trunk0", iface)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment