From c4c23527e36f2c682c7789591807a28ae55d89db Mon Sep 17 00:00:00 2001 From: Rueben Ramirez Date: Tue, 8 Oct 2024 04:21:19 -0500 Subject: [PATCH] udhcp.user uci commit only new hostnames Instead of always committing a provided hostname, only commit new hostnames, where the new hostname doesn't match the current hostname. Resolves #442 --- openwrt/files/etc/udhcpc.user | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/openwrt/files/etc/udhcpc.user b/openwrt/files/etc/udhcpc.user index ce3b7424..103ae0f2 100644 --- a/openwrt/files/etc/udhcpc.user +++ b/openwrt/files/etc/udhcpc.user @@ -21,16 +21,16 @@ case "$1" in /root/bin/apinger-pop.sh "$router" fi - if [ ! -z "$hostname" ]; then + if [ ! -z "$hostname" ] && [ `echo "$HOSTNAME" | tr '[A-Z]' '[a-z]'` != `echo "$hostname" | tr '[A-Z]' '[a-z]'` ]; then + # set new hostname uci set 'system.@system[0].hostname'="$hostname" uci commit - if [ `echo "$HOSTNAME" | tr '[A-Z]' '[a-z]'` != `echo "$hostname" | tr '[A-Z]' '[a-z]'` ]; then - # reload/restart whatever needs the hostname updated - /etc/init.d/system reload - service zabbix_agentd restart - service rsyslog restart - service lldpd restart - fi + + # reload/restart whatever needs the hostname updated + /etc/init.d/system reload + service zabbix_agentd restart + service rsyslog restart + service lldpd restart fi if [ ! -z "$opt226" ]; then /root/bin/config-version.sh -c $(printf %d "0x$opt226")