build: allow for non-linux executors

This commit is contained in:
Ariadne Conill 2020-07-26 03:16:52 -06:00
parent c1e1d30a58
commit 43c147c6cf
4 changed files with 4 additions and 2 deletions

56
executor-scripts/linux/dhcp Executable file
View file

@ -0,0 +1,56 @@
#!/bin/sh
set -e
determine_implementation() {
[ -x /sbin/dhcpcd ] && echo "dhcpcd" && return
[ -x /usr/sbin/dhclient ] && echo "dhclient" && return
[ -x /sbin/udhcpc ] && echo "udhcpc" && return
echo "could not find a supported DHCP implementation"
exit 1
}
start() {
case "$1" in
dhcpcd)
[ -z "$IF_HOSTNAME" ] && optargs="$optargs -h $IF_HOSTNAME"
[ -z "$IF_VENDOR" ] && optargs="$optargs -i $IF_VENDOR"
[ -z "$IF_CLIENT" ] && optargs="$optargs -i $IF_CLIENT"
[ -z "$IF_LEASETIME" ] && optargs="$optargs -l $IF_LEASETIME"
/sbin/dhcpcd $optargs $IFACE
dhclient)
/usr/sbin/dhclient -pf /var/run/dhclient.$IFACE.pid $IFACE
;;
udhcpc)
/sbin/udhcpc -b -R -p /var/run/udhcpc.$IFACE.pid -i $IFACE
;;
*)
;;
esac
}
stop() {
case "$1" in
dhcpcd)
/sbin/dhcpcd -k $IFACE
;;
dhclient)
kill -9 $(cat /var/run/dhclient.$IFACE.pid) 2>/dev/null
;;
udhcpc)
kill $(cat /var/run/udhcpc.$IFACE.pid)
;;
*)
;;
esac
}
impl=$(determine_implementation)
[ -z "$VERBOSE" ] || set -x
case "$PHASE" in
up) start $impl ;;
down) stop $impl ;;
*) ;;
esac

17
executor-scripts/linux/ipv6-ra Executable file
View file

@ -0,0 +1,17 @@
#!/bin/sh
start() {
echo 1 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
}
stop() {
echo 0 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
}
[ -z "$VERBOSE" ] || set -x
case "$PHASE" in
up) start $impl ;;
down) stop $impl ;;
*) ;;
esac

29
executor-scripts/linux/static Executable file
View file

@ -0,0 +1,29 @@
#!/bin/sh
case "$PHASE" in
up) cmd="add" ;;
down) cmd="del" ;;
*) exit 0 ;;
esac
addr_family() {
if [ "$1" != "${1#*[0-9].[0-9]}" ]; then
echo "-4"
elif [ "$1" != "${1#*:[0-9a-fA-F]}" ]; then
echo "-6"
else
exit 1
fi
}
for i in $(ifquery -p address -i $INTERFACES_FILE $IFACE); do
addrfam=$(addr_family $i)
${MOCK} ip $addrfam addr $cmd $i dev $IFACE
done
for i in $(ifquery -p gateway -i $INTERFACES_FILE $IFACE); do
addrfam=$(addr_family $i)
${MOCK} ip $addrfam route $cmd default via $i
done