]> git.pld-linux.org Git - packages/systemd.git/blame - udev-net.helper
up to 246.4
[packages/systemd.git] / udev-net.helper
CommitLineData
63adfaa5 1#!/bin/sh
2#
3# Kernel NET hotplug params include:
4#
5# ACTION=%s [register or unregister]
6# INTERFACE=%s
7
dac36d58 8. /etc/sysconfig/network-scripts/functions.network
63adfaa5 9
10mesg() {
11 /usr/bin/logger -t $(basename $0)"[$$]" "$@"
12}
13
14debug_mesg() {
15 :
16}
17
18# returns true if device is either wireless, usbnet or is named eth* and supports ethtool
19ethernet_check() {
20 [ -d /sys/class/net/$1/wireless/ ] && return 0
21 [[ "$1" == bnep* ]] && return 0
22 # eagle-usb/firewire create a fake ethX interface
23 if [ -x /usr/sbin/ethtool ] && ! /usr/sbin/ethtool $1 > /dev/null 2>&1;
24 then return 1;
25 fi
26 return 0;
27}
28
29if [ "$INTERFACE" = "" ]; then
30 mesg Bad NET invocation: \$INTERFACE is not set
31 exit 1
32fi
33
34export IN_HOTPLUG=1
35
36case $ACTION in
37add|register)
38 case $INTERFACE in
39 # interfaces that are registered after being "up" (?)
40 ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*)
41 debug_mesg assuming $INTERFACE is already up
42 exit 0
43 ;;
44 # interfaces that are registered then brought up
45 *)
46 # NOTE: network configuration relies on administered state,
47 # we can't do much here without distro-specific knowledge
48 # such as whether/how to invoke DHCP, set up bridging, etc.
63adfaa5 49 # conform to network service (AUTOMATIC_IFCFG)
2815768f 50
63adfaa5 51 [ -r /etc/sysconfig/network ] && . /etc/sysconfig/network
52
53 # don't do anything for non ethernet devices
54 ethernet_check $INTERFACE || exit 0;
55
56 # automatically create an interface file
89573670 57 CFG=/etc/sysconfig/interfaces/ifcfg-$INTERFACE
63adfaa5 58 if [ "$AUTOMATIC_IFCFG" != no -a ! -r $CFG ]; then
59 debug_mesg creating config file for $INTERFACE
60 cat > $CFG <<EOF
61DEVICE=$INTERFACE
62BOOTPROTO=dhcp
e9539da5 63ONBOOT=no
63adfaa5 64EOF
65 fi
66
67 if [ ! -f /var/lock/subsys/network ] || [ ! -r $CFG ]; then
68 # Don't do anything if the network is stopped or interface isn't configured
69 exit 0
70 fi
71
72 if [ -x /sbin/ifup ]; then
73 debug_mesg invoke ifup $INTERFACE
56a1ce57 74 exec /sbin/ifup $INTERFACE hotplug
63adfaa5 75 fi
76 ;;
77 esac
78 mesg $1 $ACTION event not handled
79 ;;
80
81remove|unregister)
82 case $INTERFACE in
83 # interfaces that are unregistered after being "down" (?)
84 ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*)
85 debug_mesg assuming $INTERFACE is already down
86 exit 0
87 ;;
88 *)
89 if [ -x /sbin/ifdown ]; then
90 debug_mesg invoke ifdown $INTERFACE
c11ba617 91 exec /sbin/ifdown $INTERFACE hotplug
63adfaa5 92 fi
93 ;;
94 esac
95 mesg $1 $ACTION event not handled
96 ;;
97
98*)
99 debug_mesg NET $ACTION event for $INTERFACE not supported
100 exit 1 ;;
101
102esac
This page took 0.271889 seconds and 4 git commands to generate.