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 8, 2024
1 parent ef74408 commit 5af17e4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions openwrt/files/etc/udhcpc.user
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ case "$1" in
fi

if [ ! -z "$hostname" ]; then
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
# set new hostname
uci set 'system.@system[0].hostname'="$hostname"
uci commit

# reload/restart whatever needs the hostname updated
/etc/init.d/system reload
service zabbix_agentd restart
Expand Down

0 comments on commit 5af17e4

Please sign in to comment.