diff --git a/functions b/functions index 97167b4..f472389 100644 --- a/functions +++ b/functions @@ -196,6 +196,12 @@ iface_is_up() $IP -o link show dev $NAME 2>/dev/null | cut -d' ' -f3 | grep -qs '[<,]UP[,>]' } +iface_have_ipaddr() +{ + local NAME=${1:?missing 1st argument to $FUNCNAME} + $IP -o addr show dev $NAME 2>/dev/null | egrep -qs " $NAME +inet ([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2} " +} + # Invoke program which understands the "-o NAME" option - # insmod for modutils, modprobe for module-init-tools. modprobe_with_rename() @@ -494,7 +500,7 @@ eval_string() declare -frx is_yes is_no SourceIfNotEmpty ExecIfExecutable supported_type name2type declare -frx pickup_options print_error print_message print_progress print_nack -declare -frx iface_is_up try_rmmod get_mapped_ifname profiled_filename init_netprofile +declare -frx iface_is_up iface_have_ipaddr try_rmmod get_mapped_ifname profiled_filename init_netprofile declare -frx init_nethost foreach_child ifdown_children ifup_children ifup_parents declare -frx ifdown_parents iface_exists seen_iface add_seen_iface xargise_file declare -frx have_ifplugd pickup_defaults trim need_detection stop_dhcp_client diff --git a/ifup-removable b/ifup-removable index 0bcb556..e788ae3 100755 --- a/ifup-removable +++ b/ifup-removable @@ -52,6 +52,10 @@ export IFACEDIR MYIFACEDIR SCRIPTDIR NAME NETPROFILE SEEN_IFACES init_netprofile if [ ! -d "$MYIFACEDIR" ]; then if is_yes "$ALLOW_UNKNOWN"; then + if iface_is_up $NAME && iface_have_ip $NAME; then + print_message -n "unknown interface '$NAME' already configured - skipping (lookup ALLOW_UNKNOWN_RESET option or create a usable configuration)" + exit 1 + fi if [ -d $IFACEDIR/unknown@$NETHOST ]; then MYIFACEDIR=$IFACEDIR/unknown@$NETHOST else