b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | #!/bin/sh |
| 2 | |
| 3 | [ -f "$USER_DHCPSCRIPT" ] && . "$USER_DHCPSCRIPT" "$@" |
| 4 | |
| 5 | . /usr/share/libubox/jshn.sh |
| 6 | |
| 7 | json_init |
| 8 | json_add_array env |
| 9 | hotplugobj="" |
| 10 | |
| 11 | case "$1" in |
| 12 | add | del | old | arp-add | arp-del) |
| 13 | json_add_string "" "MACADDR=$2" |
| 14 | json_add_string "" "IPADDR=$3" |
| 15 | ;; |
| 16 | esac |
| 17 | |
| 18 | case "$1" in |
| 19 | add) |
| 20 | json_add_string "" "ACTION=add" |
| 21 | json_add_string "" "HOSTNAME=$4" |
| 22 | hotplugobj="dhcp" |
| 23 | ;; |
| 24 | del) |
| 25 | json_add_string "" "ACTION=remove" |
| 26 | json_add_string "" "HOSTNAME=$4" |
| 27 | hotplugobj="dhcp" |
| 28 | ;; |
| 29 | old) |
| 30 | json_add_string "" "ACTION=update" |
| 31 | json_add_string "" "HOSTNAME=$4" |
| 32 | hotplugobj="dhcp" |
| 33 | ;; |
| 34 | arp-add) |
| 35 | json_add_string "" "ACTION=add" |
| 36 | hotplugobj="neigh" |
| 37 | ;; |
| 38 | arp-del) |
| 39 | json_add_string "" "ACTION=remove" |
| 40 | hotplugobj="neigh" |
| 41 | ;; |
| 42 | tftp) |
| 43 | json_add_string "" "ACTION=add" |
| 44 | json_add_string "" "TFTP_SIZE=$2" |
| 45 | json_add_string "" "TFTP_ADDR=$3" |
| 46 | json_add_string "" "TFTP_PATH=$4" |
| 47 | hotplugobj="tftp" |
| 48 | ;; |
| 49 | esac |
| 50 | |
| 51 | json_close_array env |
| 52 | |
| 53 | [ -n "$hotplugobj" ] && ubus call hotplug.${hotplugobj} call "$(json_dump)" |