Skip to content

Commit

Permalink
udhcp.user uci commit only new hostnames
Browse files Browse the repository at this point in the history
Instead of always committing a provided hostname, only commit new hostnames, where
the new hostname doesn't match the current hostname.

Resolves #442
  • Loading branch information
ruebenramirez committed Oct 10, 2024
1 parent ef74408 commit c4c2352
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions openwrt/files/etc/udhcpc.user
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit c4c2352

Please sign in to comment.