Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REVIEW] - udhcp.user uci commit only new hostnames #785

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions openwrt/files/etc/udhcpc.user
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions tests/unit/openwrt/golden/ar71xx/etc/udhcpc.user
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions tests/unit/openwrt/golden/ipq806x/etc/udhcpc.user
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading