make all executor scripts testable/mockable
This commit is contained in:
parent
12307aeb9d
commit
05e8f9bbb5
2 changed files with 14 additions and 12 deletions
|
@ -3,6 +3,7 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
determine_implementation() {
|
determine_implementation() {
|
||||||
|
[ -n "$IF_DHCP_PROGRAM" ] && echo "$IF_DHCP_PROGRAM" && return
|
||||||
[ -x /sbin/dhcpcd ] && echo "dhcpcd" && return
|
[ -x /sbin/dhcpcd ] && echo "dhcpcd" && return
|
||||||
[ -x /usr/sbin/dhclient ] && echo "dhclient" && return
|
[ -x /usr/sbin/dhclient ] && echo "dhclient" && return
|
||||||
[ -x /sbin/udhcpc ] && echo "udhcpc" && return
|
[ -x /sbin/udhcpc ] && echo "udhcpc" && return
|
||||||
|
@ -13,16 +14,17 @@ determine_implementation() {
|
||||||
start() {
|
start() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
dhcpcd)
|
dhcpcd)
|
||||||
[ -z "$IF_HOSTNAME" ] && optargs="$optargs -h $IF_HOSTNAME"
|
[ -n "$IF_HOSTNAME" ] && optargs="$optargs -h $IF_HOSTNAME"
|
||||||
[ -z "$IF_VENDOR" ] && optargs="$optargs -i $IF_VENDOR"
|
[ -n "$IF_VENDOR" ] && optargs="$optargs -i $IF_VENDOR"
|
||||||
[ -z "$IF_CLIENT" ] && optargs="$optargs -i $IF_CLIENT"
|
[ -n "$IF_CLIENT" ] && optargs="$optargs -i $IF_CLIENT"
|
||||||
[ -z "$IF_LEASETIME" ] && optargs="$optargs -l $IF_LEASETIME"
|
[ -n "$IF_LEASETIME" ] && optargs="$optargs -l $IF_LEASETIME"
|
||||||
/sbin/dhcpcd $optargs $IFACE
|
${MOCK} /sbin/dhcpcd $optargs $IFACE
|
||||||
|
;;
|
||||||
dhclient)
|
dhclient)
|
||||||
/usr/sbin/dhclient -pf /var/run/dhclient.$IFACE.pid $IFACE
|
${MOCK} /usr/sbin/dhclient -pf /var/run/dhclient.$IFACE.pid $IFACE
|
||||||
;;
|
;;
|
||||||
udhcpc)
|
udhcpc)
|
||||||
/sbin/udhcpc -b -R -p /var/run/udhcpc.$IFACE.pid -i $IFACE
|
${MOCK} /sbin/udhcpc -b -R -p /var/run/udhcpc.$IFACE.pid -i $IFACE
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
;;
|
;;
|
||||||
|
@ -32,13 +34,13 @@ start() {
|
||||||
stop() {
|
stop() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
dhcpcd)
|
dhcpcd)
|
||||||
/sbin/dhcpcd -k $IFACE
|
${MOCK} /sbin/dhcpcd -k $IFACE
|
||||||
;;
|
;;
|
||||||
dhclient)
|
dhclient)
|
||||||
kill -9 $(cat /var/run/dhclient.$IFACE.pid) 2>/dev/null
|
${MOCK} kill -9 $(cat /var/run/dhclient.$IFACE.pid) 2>/dev/null
|
||||||
;;
|
;;
|
||||||
udhcpc)
|
udhcpc)
|
||||||
kill $(cat /var/run/udhcpc.$IFACE.pid)
|
${MOCK} kill $(cat /var/run/udhcpc.$IFACE.pid)
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
echo 1 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
|
${MOCK} echo 1 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
echo 0 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
|
${MOCK} echo 0 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra
|
||||||
}
|
}
|
||||||
|
|
||||||
[ -z "$VERBOSE" ] || set -x
|
[ -z "$VERBOSE" ] || set -x
|
||||||
|
|
Loading…
Reference in a new issue