view network/dhcpcd/dhcpcd @ 1311:131def02577e

core/kmod: upgrade to 29
author David Demelier <markand@malikania.fr>
date Fri, 19 Nov 2021 22:24:27 +0100
parents 3dfef64b81c1
children
line wrap: on
line source

#!/bin/busybox sh
#
# /etc/rc.d/dhcpcd -- run control script for dhcpcd
#
# Copyright (c) 2019 David Demelier <markand@malikania.fr>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#

if [ -f /etc/rc.conf ]; then
	. /etc/rc.conf
fi

: ${DHCPCD_CMD:=/bin/dhcpcd}
: ${DHCPCD_ARGS:=-q -b}
: ${DHCPCD_PID:=/var/run/dhcpcd.pid}

dhcpcd_start()
{
	if [ -s $DHCPCD_PID ]; then
		echo "dhcpcd is already running with pid: $(cat $DHCPCD_PID)"
	else
		echo "Starting dhcpcd: $DHCPCD_CMD $DHCPCD_ARGS"
		$DHCPCD_CMD $DHCPCD_ARGS
	fi
}

dhcpcd_status()
{
	if [ -s $DHCPCD_PID ]; then
		echo "dhcpcd is running with pid: $(cat $DHCPCD_PID)"
	else
		echo "dhcpcd is not running"
	fi
}

dhcpcd_stop()
{
	if [ -s $DHCPCD_PID ]; then
		echo "Stopping dhcpcd."
		kill -QUIT $(cat $DHCPCD_PID)
	fi
}

dhcpcd_restart()
{
	dhcpcd_stop
	sleep 3
	dhcpcd_start
}

case $1 in
start)
	dhcpcd_start
	;;
status)
	dhcpcd_status
	;;
stop)
	dhcpcd_stop
	;;
restart)
	dhcpcd_restart
	;;
*)
	echo "usage: $(basename $0) restart|start|status|stop"
	;;
esac