Created
April 14, 2015 03:50
-
-
Save benkulbertis/35475f3710d1c2d3114a to your computer and use it in GitHub Desktop.
Automatically configures netctl to use wired DHCP with a chosen interface.
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
#!/bin/bash | |
interfaces=$(ip link | cut -d ":" -f 1-2 | sed 'n; d') | |
echo -e "Available Interfaces:\n$interfaces" | |
read -p "Please choose an interface: " choice | |
if [ "$choice" -ge 1 -a "$choice" -le $(echo "$interfaces" | wc -l) ]; then | |
interface=$(echo "$interfaces" | sed "${choice}q;d" | cut -d ":" -f 2 | sed 's/ //g') | |
sed "s/eth0/$interface/g" /etc/netctl/examples/ethernet-dhcp > /etc/netctl/ethernet-dhcp | |
echo "Now enabling the $interface interface..." | |
netctl start ethernet-dhcp | |
if [ $? -eq 0 ]; then | |
echo "Success!" | |
else | |
echo "An error occurred. Check the file '/etc/netctl/ethernet-dhcp' for issues." | |
fi | |
else | |
echo "Please enter the number prefixing the desired interface." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#0592544345