lima-city: Webhosting, Domains und Cloud
1 Pluspunkt 0 Minuspunkte

Ich habe ein Bash Script das einige Setup Parameter abfragt

echo '[info] set up default macvlan'
read -p 'Please specify subnet (CIDR): ' subnet
read -p 'Please specify the gateway (IP): ' gateway
read -p 'Please specify the interface: ' device
docker network create -d macvlan --subnet=$subnet --gateway=$gateway -o parent=$device macvlan_net

Wie kann ich bei "Please specify the interface" eine Liste mit verfügbaren Interfaces anzeigen? So wie

Please specify the interface (eth0, eth1, wlan0):

von  

1 Antwort

0 Pluspunkte 0 Minuspunkte

Du kannst die verfügbaren Interfaces aus dem Verzeichnis /sys/class/net auslesen.

available_interfaces=$(ls /sys/class/net | grep -v lo | tr '\n' ' ')
von (605 Punkte)