summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'net/dummy.sh')
-rw-r--r--net/dummy.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/net/dummy.sh b/net/dummy.sh
new file mode 100644
index 0000000..3050216
--- /dev/null
+++ b/net/dummy.sh
@@ -0,0 +1,41 @@
+# Copyright (c) 2015 Gentoo Foundation
+# All rights reserved. Released under the 2-clause BSD license.
+
+dummy_depend()
+{
+ program ip
+ after interface
+ before dhcp macchanger
+}
+
+_is_dummy() {
+ is_interface_type dummy
+}
+
+dummy_pre_start()
+{
+ local dummy=
+ eval dummy=\$type_${IFVAR}
+ [ "${dummy}" = "dummy" ] || return 0
+
+ ebegin "Creating dummy interface ${IFACE}"
+ cmd="ip link add name "${IFACE}" type dummy"
+ veinfo $cmd
+ if $cmd ; then
+ eend 0 && _up && set_interface_type dummy
+ else
+ eend 1
+ fi
+}
+
+
+dummy_post_stop()
+{
+ _is_dummy || return 0
+
+ ebegin "Removing dummy ${IFACE}"
+ cmd="ip link delete "${IFACE}" type dummy"
+ veinfo "$cmd"
+ $cmd
+ eend $?
+}