aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/services/dnsmasq/files/dhcp-script.sh
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2021-01-01 12:47:11 +0000
committerDaniel Golle <daniel@makrotopia.org>2021-02-08 00:57:14 +0000
commitaed95c4cb8d5a55a795910a759d08e1393f8d967 (patch)
tree9751fbfb0f7475fcce4544934d6e71ac413ac4ac /package/network/services/dnsmasq/files/dhcp-script.sh
parent29a6a71d52738af9552bd77763f10e912a7eb9f0 (diff)
downloadupstream-aed95c4cb8d5a55a795910a759d08e1393f8d967.tar.gz
upstream-aed95c4cb8d5a55a795910a759d08e1393f8d967.tar.bz2
upstream-aed95c4cb8d5a55a795910a759d08e1393f8d967.zip
dnsmasq: switch to ubus-based hotplug call
Use new ubus-based hotplug call in dhcp-script.sh As sysntpd now makes use of the new ubus-based hotplug calls, dnsmasq no longer needs to ship ACL to cover ntpd-hotplug. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'package/network/services/dnsmasq/files/dhcp-script.sh')
-rwxr-xr-xpackage/network/services/dnsmasq/files/dhcp-script.sh63
1 files changed, 35 insertions, 28 deletions
diff --git a/package/network/services/dnsmasq/files/dhcp-script.sh b/package/network/services/dnsmasq/files/dhcp-script.sh
index 86032694c1..470097bf6b 100755
--- a/package/network/services/dnsmasq/files/dhcp-script.sh
+++ b/package/network/services/dnsmasq/files/dhcp-script.sh
@@ -2,45 +2,52 @@
[ -f "$USER_DHCPSCRIPT" ] && . "$USER_DHCPSCRIPT" "$@"
+. /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
+
case "$1" in
add)
- export ACTION="add"
- export MACADDR="$2"
- export IPADDR="$3"
- export HOSTNAME="$4"
- exec /sbin/hotplug-call dhcp
+ json_add_string "" "ACTION=add"
+ json_add_string "" "HOSTNAME=$4"
+ hotplugobj="dhcp"
;;
del)
- export ACTION="remove"
- export MACADDR="$2"
- export IPADDR="$3"
- export HOSTNAME="$4"
- exec /sbin/hotplug-call dhcp
+ json_add_string "" "ACTION=remove"
+ json_add_string "" "HOSTNAME=$4"
+ hotplugobj="dhcp"
;;
old)
- export ACTION="update"
- export MACADDR="$2"
- export IPADDR="$3"
- export HOSTNAME="$4"
- exec /sbin/hotplug-call dhcp
+ json_add_string "" "ACTION=update"
+ json_add_string "" "HOSTNAME=$4"
+ hotplugobj="dhcp"
;;
arp-add)
- export ACTION="add"
- export MACADDR="$2"
- export IPADDR="$3"
- exec /sbin/hotplug-call neigh
+ json_add_string "" "ACTION=add"
+ hotplugobj="neigh"
;;
arp-del)
- export ACTION="remove"
- export MACADDR="$2"
- export IPADDR="$3"
- exec /sbin/hotplug-call neigh
+ json_add_string "" "ACTION=remove"
+ hotplugobj="neigh"
;;
tftp)
- export ACTION="add"
- export TFTP_SIZE="$2"
- export TFTP_ADDR="$3"
- export TFTP_PATH="$4"
- exec /sbin/hotplug-call tftp
+ 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"
;;
esac
+
+json_close_array env
+
+[ -n "$hotplugobj" ] && ubus call hotplug.${hotplugobj} call "$(json_dump)"