diff --git a/openwrt/files/etc/udhcpc.user b/openwrt/files/etc/udhcpc.user index 812db4f7..f2267441 100644 --- a/openwrt/files/etc/udhcpc.user +++ b/openwrt/files/etc/udhcpc.user @@ -35,17 +35,18 @@ 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") fi diff --git a/tests/unit/openwrt/golden/ar71xx/etc/udhcpc.user b/tests/unit/openwrt/golden/ar71xx/etc/udhcpc.user index ce3b7424..5cd71567 100644 --- a/tests/unit/openwrt/golden/ar71xx/etc/udhcpc.user +++ b/tests/unit/openwrt/golden/ar71xx/etc/udhcpc.user @@ -21,17 +21,18 @@ 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") fi diff --git a/tests/unit/openwrt/golden/ipq806x/etc/udhcpc.user b/tests/unit/openwrt/golden/ipq806x/etc/udhcpc.user index ce3b7424..5cd71567 100644 --- a/tests/unit/openwrt/golden/ipq806x/etc/udhcpc.user +++ b/tests/unit/openwrt/golden/ipq806x/etc/udhcpc.user @@ -21,17 +21,18 @@ 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") fi