#!/bin/bash
# Filename:      ${GRML_FAI_CONFIG}/config/scripts/GRMLBASE/38-udev
# Purpose:       configure udev of live-system
# Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
# Bug-Reports:   see http://grml.org/bugs/
# License:       This file is licensed under the GPL v2 or any later version.
################################################################################

set -u
set -e

CONFFILE="$target/etc/udev/rules.d/70-persistent-net.rules"
STRING='This file was automatically generated by the /lib/udev/write_net_rules'

# We do not want to get a predefined entry for eth0 of the *build* system, like:
#   Unknown net device (/devices/virtio-pci/virtio0/net/eth0) (virtio_net)
#   SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="XX:XX:XX:XX:XX:XX", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# so therefore remove such an automatically generated file instead.
if ! [ -r "$CONFFILE" ] ; then
   echo "$CONFFILE does not exist, nothing to do."
else
   if grep -q "$STRING" "$CONFFILE" ; then
      echo "Automatically generated /etc/udev/rules.d/70-persistent-net.rules found, removing it."
      rm -f "$CONFFILE"
   fi
fi

## END OF FILE #################################################################
# vim:ft=sh expandtab ai tw=80 tabstop=4 shiftwidth=2
