executors: add dhcp executor (replacing the built in)

This commit is contained in:
Ariadne Conill 2020-07-25 02:36:11 -06:00
parent dca34ebba7
commit cf8ae46ca0

40
executors/dhcp Executable file
View file

@ -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