Skip to content

Instantly share code, notes, and snippets.

@benkulbertis
Created April 14, 2015 03:50
Show Gist options
  • Save benkulbertis/35475f3710d1c2d3114a to your computer and use it in GitHub Desktop.
Save benkulbertis/35475f3710d1c2d3114a to your computer and use it in GitHub Desktop.
Automatically configures netctl to use wired DHCP with a chosen interface.
#!/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
@mohwazn
Copy link

mohwazn commented Sep 3, 2017

#0592544345

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment