summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-03-25 14:06:05 +0000
committerRoy Marples <roy@marples.name>2008-03-25 14:06:05 +0000
commit55eb3794fb4ad563102d5ab30c1d5337a599b2e5 (patch)
tree0d052faeb050c1e18ba56f6f6189bff3ffca28c9 /net
parent08aff6ef44ac5dc438d916b53aa61385f6d299f3 (diff)
downloadopenrc-55eb3794fb4ad563102d5ab30c1d5337a599b2e5.tar.gz
openrc-55eb3794fb4ad563102d5ab30c1d5337a599b2e5.tar.bz2
openrc-55eb3794fb4ad563102d5ab30c1d5337a599b2e5.tar.xz
Rework our folder structure so that we don't have OS specific dirs, making it easier to share init and conf files per OS.
Diffstat (limited to 'net')
-rw-r--r--net/Makefile2
-rw-r--r--net/Makefile.FreeBSD0
-rw-r--r--net/Makefile.Linux0
-rw-r--r--net/Makefile.NetBSD1
-rw-r--r--net/ifwatchd.sh60
5 files changed, 63 insertions, 0 deletions
diff --git a/net/Makefile b/net/Makefile
index 944c3fc..e2eb4d3 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -3,4 +3,6 @@ INC= dhclient.sh dhcpcd.sh macchanger.sh macnet.sh \
ssidnet.sh system.sh wpa_supplicant.sh
MK= ../mk
+include ${MK}/os.mk
+include Makefile.${OS}
include ${MK}/scripts.mk
diff --git a/net/Makefile.FreeBSD b/net/Makefile.FreeBSD
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/net/Makefile.FreeBSD
diff --git a/net/Makefile.Linux b/net/Makefile.Linux
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/net/Makefile.Linux
diff --git a/net/Makefile.NetBSD b/net/Makefile.NetBSD
new file mode 100644
index 0000000..cda89ef
--- /dev/null
+++ b/net/Makefile.NetBSD
@@ -0,0 +1 @@
+INC+= ifwatchd.sh
diff --git a/net/ifwatchd.sh b/net/ifwatchd.sh
new file mode 100644
index 0000000..44c6ea3
--- /dev/null
+++ b/net/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 $?
+}