slackware-current/source/a/udev/config/scripts/nethelper.sh
Patrick J Volkerding 5a12e7c134 Slackware 13.0
Wed Aug 26 10:00:38 CDT 2009
Slackware 13.0 x86_64 is released as stable!  Thanks to everyone who
helped make this release possible -- see the RELEASE_NOTES for the
credits.  The ISOs are off to the replicator.  This time it will be a
6 CD-ROM 32-bit set and a dual-sided 32-bit/64-bit x86/x86_64 DVD.
We're taking pre-orders now at store.slackware.com.  Please consider
picking up a copy to help support the project.  Once again, thanks to
the entire Slackware community for all the help testing and fixing
things and offering suggestions during this development cycle.
As always, have fun and enjoy!  -P.
2018-05-31 22:41:17 +02:00

62 lines
1.9 KiB
Bash
Executable file

#!/bin/sh
DEVNAME="$1"
COMMAND="$2"
testwrite() {
if touch /var/run/checkrw 2>/dev/null ; then
rm -rf /var/run/checkrw
RW=1
fi
}
case $DEVNAME in
eth*|ath*|wlan*|ra*|sta*|ctc*|lcs*|hsi*)
case $COMMAND in
'start')
testwrite
if [ $RW ]; then
if [ -x /etc/rc.d/rc.inet1 ]; then
if ! /sbin/ifconfig | /bin/grep -q "^${DEVNAME} "; then
/etc/rc.d/rc.inet1 ${DEVNAME}_start
fi
fi
exit 0
else
exit 1
fi
;;
'stop')
if [ -x /etc/rc.d/rc.inet1 ]; then
if /sbin/ifconfig | /bin/grep -q "^${DEVNAME} "; then
/etc/rc.d/rc.inet1 ${DEVNAME}_stop
fi
fi
# Does dhcpcd appear to still be running on the
# interface? If so, try to stop it.
if [ -r /etc/dhcpc/dhcpcd-$DEVNAME.pid -o -r /var/run/dhcpcd-$DEVNAME.pid ]; then
/sbin/dhcpcd -k -d $DEVNAME
# Force garbage removal, if needed:
if [ -r /etc/dhcpc/dhcpcd-$DEVNAME.pid ]; then
/bin/rm -f /etc/dhcpc/dhcpcd-$DEVNAME.pid
elif [ -r /var/run/dhcpcd-$DEVNAME.pid ]; then
/bin/rm -f /var/run/dhcpcd-$DEVNAME.pid
fi
fi
# If the interface is now down, exit with a status of 0:
if /sbin/ifconfig | /bin/grep -q "^${DEVNAME} " ; then
exit 0
fi
;;
*)
echo "usage $0 interface start|stop"
exit 1
;;
esac
;;
*)
echo "Interface $DEVNAME not supported."
exit 1
;;
esac
exit 0