release/renew dhcp before start/before stop
This commit is contained in:
parent
7b7dad1d6b
commit
ab8c64bab8
24
tinc-down
Normal file
24
tinc-down
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
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
|
||||||
|
elif [[ -f "$pid_file" ]
|
||||||
|
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
|
||||||
|
exit 0
|
||||||
|
|
1
tinc-up
1
tinc-up
@ -67,6 +67,7 @@ set_ip() {
|
|||||||
start_dhclient() {
|
start_dhclient() {
|
||||||
local interface=$1
|
local interface=$1
|
||||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||||
|
dhclient -x
|
||||||
dhclient -nw "$interface"
|
dhclient -nw "$interface"
|
||||||
elif [[ "$OSTYPE" == "freebsd"* ]]; then
|
elif [[ "$OSTYPE" == "freebsd"* ]]; then
|
||||||
dhclient -b "$interface"
|
dhclient -b "$interface"
|
||||||
|
Loading…
Reference in New Issue
Block a user