#!/bin/bash do_start() { echo "starting dhcp daemon" udhcpd -S /etc/udhcpd.conf } do_stop() { echo "stopping dhcp daemon" killall udhcpd } usage() { echo "Usage: $(basename $0) start|stop|restart" exit 1 } # main if [[ $# != 1 ]]; then usage fi case $1 in start) if [[ ! -f "/etc/udhcpd.conf" ]] then echo "/etc/udhcpd.conf does not exist" exit 1 fi do_start ;; stop) do_stop ;; restart) do_stop sleep 1 do_start ;; *) usage ;; esac exit 0