Add UPDOWN_INTERFACES option to ethercat.conf
This commit is contained in:
parent
805e407f6f
commit
bfd84c8f3e
|
|
@ -61,10 +61,6 @@ MASTER0_DEVICE=""
|
|||
# Note: The e100, e1000, e1000e, r8169, ccat, igb and igc drivers are not built by
|
||||
# default. Enable them with the --enable-<driver> configure switches.
|
||||
#
|
||||
# Attention: When using the generic driver, the corresponding Ethernet device
|
||||
# has to be activated (with OS methods, for example 'ip link set ethX up'),
|
||||
# before the master is started, otherwise all frames will time out.
|
||||
#
|
||||
DEVICE_MODULES=""
|
||||
|
||||
# If you have any issues about network interfaces not being configured
|
||||
|
|
@ -72,6 +68,19 @@ DEVICE_MODULES=""
|
|||
# Have a look at the service file, you'll find some details there.
|
||||
#
|
||||
|
||||
#
|
||||
# List of interfaces to bring up and down automatically.
|
||||
#
|
||||
# Specify a space-separated list of interface names (such as eth0 or
|
||||
# enp0s1) that shall be brought up on `ethercatctl start` and down on
|
||||
# `ethercatctl stop`.
|
||||
#
|
||||
# When using the generic driver, the corresponding Ethernet device has to be
|
||||
# activated before the master is started, otherwise all frames will time out.
|
||||
# This the perfect use-case for `UPDOWN_INTERFACES`.
|
||||
#
|
||||
UPDOWN_INTERFACES=""
|
||||
|
||||
#
|
||||
# Flags for loading kernel modules.
|
||||
#
|
||||
|
|
|
|||
|
|
@ -47,18 +47,22 @@ fi
|
|||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
is_mac_address() {
|
||||
local x='[0-9a-fA-F]'
|
||||
echo "$1" | grep -qE "^($x$x:){5}$x$x\$" -
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
parse_mac_address() {
|
||||
local DEVICENAMETOMAC
|
||||
if [ -z "${1}" ]; then
|
||||
MAC=""
|
||||
elif echo ${1} | grep -qE '^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$'; then
|
||||
MAC=${1}
|
||||
if [ -z "${1}" ] || is_mac_address "${1}"; then
|
||||
MAC="${1}"
|
||||
else
|
||||
DEVICENAMETOMAC=$("${IP}" address show dev "${1}" |
|
||||
awk '/link\/ether/ { print $2; }')
|
||||
if echo "${DEVICENAMETOMAC}" |
|
||||
grep -qE '^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$'; then
|
||||
MAC=${DEVICENAMETOMAC}
|
||||
if is_mac_address "${DEVICENAMETOMAC}"; then
|
||||
MAC="${DEVICENAMETOMAC}"
|
||||
else
|
||||
echo Invalid MAC address or interface name \""${1}"\" \
|
||||
in ${ETHERCAT_CONFIG}
|
||||
|
|
@ -72,6 +76,11 @@ parse_mac_address() {
|
|||
case "${1}" in
|
||||
|
||||
start)
|
||||
# bring up all updown interfaces before anything else
|
||||
for interface in $UPDOWN_INTERFACES; do
|
||||
$IP link set dev $interface up
|
||||
done
|
||||
|
||||
# construct DEVICES and BACKUPS from configuration variables
|
||||
DEVICES=""
|
||||
BACKUPS=""
|
||||
|
|
@ -167,6 +176,11 @@ stop)
|
|||
${MODPROBE} ${MODPROBE_FLAGS} "${MODULE}"
|
||||
done
|
||||
|
||||
# bring down all updown interfaces
|
||||
for interface in $UPDOWN_INTERFACES; do
|
||||
$IP link set dev $interface down
|
||||
done
|
||||
|
||||
exit 0
|
||||
;;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue