From cf8ae46ca01f7ff0d48d043a4e7365cf6cce0c2f Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Sat, 25 Jul 2020 02:36:11 -0600 Subject: [PATCH] executors: add dhcp executor (replacing the built in) --- executors/dhcp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 executors/dhcp diff --git a/executors/dhcp b/executors/dhcp new file mode 100755 index 0000000..a88927f --- /dev/null +++ b/executors/dhcp @@ -0,0 +1,40 @@ +#!/bin/sh + +set -e + +determine_implementation() { + [ -x /sbin/udhcpc ] && echo "udhcpc" && return + echo "???" +} + +start() { + case "$1" in + udhcpc) + /sbin/udhcpc -b -R -p /var/run/udhcpc.$IFACE.pid -i $IFACE + ;; + *) + echo "implementation $1 not supported" + exit 1 + esac +} + +stop() { + case "$1" in + udhcpc) + kill $(cat /var/lib/udhcpc.$IFACE.pid) + ;; + *) + echo "implementation $1 not supported" + exit 1 + esac +} + +impl=$(determine_implementation) + +[ -z "$VERBOSE" ] || set -x + +case "$MODE" in +start) start $impl ;; +stop) stop $impl ;; +*) echo "unknown mode $MODE" ;; +esac