summaryrefslogtreecommitdiff
path: root/net.NetBSD
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-03-10 21:34:46 +0000
committerRoy Marples <roy@marples.name>2008-03-10 21:34:46 +0000
commit8b23aaecff11723184bc4761bef68ed98a3ad7af (patch)
tree35a4541974582672febe65ab8cf555367d9fb53f /net.NetBSD
parentf20099bc337eee3238911b48981d82c0e63603ef (diff)
downloadopenrc-8b23aaecff11723184bc4761bef68ed98a3ad7af.tar.gz
openrc-8b23aaecff11723184bc4761bef68ed98a3ad7af.tar.bz2
openrc-8b23aaecff11723184bc4761bef68ed98a3ad7af.tar.xz
Add ifwatchd.sh to power the NetBSD ifwatchd program. Let wpa_supplicant work with it.
Diffstat (limited to 'net.NetBSD')
-rw-r--r--net.NetBSD/Makefile5
-rw-r--r--net.NetBSD/ifwatchd.sh60
2 files changed, 65 insertions, 0 deletions
diff --git a/net.NetBSD/Makefile b/net.NetBSD/Makefile
new file mode 100644
index 0000000..ebdb26f
--- /dev/null
+++ b/net.NetBSD/Makefile
@@ -0,0 +1,5 @@
+DIR= ${RC_LIB}/net
+INC= ifwatchd.sh
+
+MK= ../mk
+include ${MK}/scripts.mk
diff --git a/net.NetBSD/ifwatchd.sh b/net.NetBSD/ifwatchd.sh
new file mode 100644
index 0000000..44c6ea3
--- /dev/null
+++ b/net.NetBSD/ifwatchd.sh
@@ -0,0 +1,60 @@
+# Copyright 2007-2008 Roy Marples <roy@marples.name>
+# All rights reserved. Released under the 2-clause BSD license.
+
+_config_vars="$_config_vars plug_timeout"
+
+ifwatchd_depend()
+{
+ program start /usr/sbin/ifwatchd
+ after macnet rename wireless
+ before interface
+ provide plug
+}
+
+ifwatchd_pre_start()
+{
+ # We don't start ifwatchd if we're being called from the background
+ yesno ${IN_BACKGROUND} && return 0
+
+ _exists || return 0
+
+ # We need a valid MAC address
+ # It's a basic test to ensure it's not a virtual interface
+ if ! _get_mac_address >/dev/null 2>&1; then
+ vewarn "ifwatchd only works on interfaces with a valid MAC address"
+ return 0
+ fi
+
+ ebegin "Starting ifwatchd on ${IFACE}"
+
+ # Mark the us as inactive so ifwatchd can restart us
+ mark_service_inactive
+
+ # Start ifwatchd
+ export IN_BACKGROUND=yes
+ start-stop-daemon --start --exec /usr/sbin/ifwatchd \
+ -- -c "${RC_LIBDIR}/sh/ifwatchd-carrier.sh" \
+ -n "${RC_LIBDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}"
+ unset IN_BACKGROUND
+ eend "$?" || return 1
+
+ einfo "Backgrounding ..."
+ exit 1
+}
+
+ifwatchd_stop()
+{
+ yesno ${IN_BACKGROUND} && return 0
+
+ start-stop-daemon --test --quiet --stop --exec /usr/sbin/ifwatchd \
+ -- -c "${RC_LIBDIR}/sh/ifwatchd-carrier.sh" \
+ -n "${RC_LIBDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" \
+ || return 0
+
+ ebegin "Stopping ifwatchd on" "${IFACE}"
+ start-stop-daemon --stop --exec /usr/sbin/ifwatchd \
+ -- -c "${RC_LIBDIR}/sh/ifwatchd-carrier.sh" \
+ -n "${RC_LIBDIR}/sh/ifwatchd-nocarrier.sh" "${IFACE}" \
+ && return 0
+ eend $?
+}