evenet/tinc-down

26 lines
549 B
Plaintext
Raw Permalink Normal View History

#!/usr/bin/env bash
2015-01-25 19:37:34 +00:00
has() {
command -v "$1" >/dev/null 2>&1
}
stop_dhclient() {
local interface="$1"
local pid_file="/var/run/dhclient.${interface}.pid"
if [[ "$OSTYPE" == "linux-gnu" ]]; then
dhclient -r -x
2015-01-21 14:58:13 +00:00
elif [[ -f "$pid_file" ]]; then
kill "$(< $pid_file)"
fi
}
if has dhcpcd; then
dhcpcd -k "$INTERFACE"
elif has dhclient; then
stop_dhcpclient "$INTERFACE"
elif [[ "$OSTYPE" == "darwin"* ]]; then # TODO untested
ipconfig set "$interface" NONE
fi
2015-02-09 08:37:14 +00:00
[ -x "${DIR}/tinc-down.local" ] && "${DIR}/tinc-down.local" || true