2017-05-06 10:56:26 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
[ -f "$USER_DHCPSCRIPT" ] && . "$USER_DHCPSCRIPT" "$@"
|
|
|
|
|
2021-01-01 12:47:11 +00:00
|
|
|
. /usr/share/libubox/jshn.sh
|
|
|
|
|
|
|
|
json_init
|
|
|
|
json_add_array env
|
|
|
|
hotplugobj=""
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
add | del | old | arp-add | arp-del)
|
|
|
|
json_add_string "" "MACADDR=$2"
|
|
|
|
json_add_string "" "IPADDR=$3"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2017-05-06 10:56:26 +00:00
|
|
|
case "$1" in
|
|
|
|
add)
|
2021-01-01 12:47:11 +00:00
|
|
|
json_add_string "" "ACTION=add"
|
|
|
|
json_add_string "" "HOSTNAME=$4"
|
|
|
|
hotplugobj="dhcp"
|
2017-05-06 10:56:26 +00:00
|
|
|
;;
|
|
|
|
del)
|
2021-01-01 12:47:11 +00:00
|
|
|
json_add_string "" "ACTION=remove"
|
|
|
|
json_add_string "" "HOSTNAME=$4"
|
|
|
|
hotplugobj="dhcp"
|
2017-05-06 10:56:26 +00:00
|
|
|
;;
|
|
|
|
old)
|
2021-01-01 12:47:11 +00:00
|
|
|
json_add_string "" "ACTION=update"
|
|
|
|
json_add_string "" "HOSTNAME=$4"
|
|
|
|
hotplugobj="dhcp"
|
2017-05-06 10:56:26 +00:00
|
|
|
;;
|
|
|
|
arp-add)
|
2021-01-01 12:47:11 +00:00
|
|
|
json_add_string "" "ACTION=add"
|
|
|
|
hotplugobj="neigh"
|
2017-05-06 10:56:26 +00:00
|
|
|
;;
|
|
|
|
arp-del)
|
2021-01-01 12:47:11 +00:00
|
|
|
json_add_string "" "ACTION=remove"
|
|
|
|
hotplugobj="neigh"
|
2017-05-06 10:56:26 +00:00
|
|
|
;;
|
|
|
|
tftp)
|
2021-01-01 12:47:11 +00:00
|
|
|
json_add_string "" "ACTION=add"
|
|
|
|
json_add_string "" "TFTP_SIZE=$2"
|
|
|
|
json_add_string "" "TFTP_ADDR=$3"
|
|
|
|
json_add_string "" "TFTP_PATH=$4"
|
|
|
|
hotplugobj="tftp"
|
2017-05-06 10:56:26 +00:00
|
|
|
;;
|
|
|
|
esac
|
2021-01-01 12:47:11 +00:00
|
|
|
|
|
|
|
json_close_array env
|
|
|
|
|
|
|
|
[ -n "$hotplugobj" ] && ubus call hotplug.${hotplugobj} call "$(json_dump)"
|