1#!/bin/sh 2# Usage: event.sh <event> <if-name> 3 4case "$1" in 5if-create) 6 ;; 7if-up) 8 if [ -x /sbin/dhclient3 ]; then 9 /sbin/dhclient3 -nw -pf /var/run/dhclient."$2".pid -lf /var/lib/dhcp3/dhclient."$2".leases "$2" >/dev/null 2>&1 10 elif [ -x /sbin/dhclient ]; then 11 /sbin/dhclient -pf /var/run/dhclient."$2".pid -lf /var/lib/dhcp/dhclient."$2".leases "$2" 12 elif [ -x /sbin/pump ]; then 13 /sbin/pump -i "$2" 14 elif [ -x /sbin/udhcpc ]; then 15 /sbin/udhcpc -n -p /var/run/udhcpc."$2".pid -i "$2" 16 elif [ -x /sbin/dhcpcd ]; then 17 /sbin/dhcpcd "$2" 18 fi 19 ;; 20if-down) 21 if [ -x /sbin/dhclient3 ]; then 22 /sbin/dhclient3 -r -pf /var/run/dhclient."$2".pid -lf /var/lib/dhcp3/dhclient."$2".leases "$2" >/dev/null 2>&1 23 elif [ -x /sbin/dhclient ]; then 24 kill -TERM $(cat /var/run/dhclient."$2".pid) 25 elif [ -x /sbin/pump ]; then 26 /sbin/pump -i "$2" -r 27 elif [ -x /sbin/udhcpc ]; then 28 kill -TERM $(cat /var/run/udhcpc."$2".pid) 29 elif [ -x /sbin/dhcpcd ]; then 30 /sbin/dhcpcd -k "$2" 31 fi 32 ;; 33if-release) 34 ;; 35*) 36 echo "Usage: $0 { if-create | if-up | if-down | if-release }" >&2 37 exit 3 38 ;; 39esac 40 41