Skip to content

Instantly share code, notes, and snippets.

@SpComb
Created July 26, 2014 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SpComb/c1bb74609827ff516212 to your computer and use it in GitHub Desktop.
Save SpComb/c1bb74609827ff516212 to your computer and use it in GitHub Desktop.
openwrt:/etc/hotplug.d/iface/01-dhcp-hostname
log () {
logger -p user.info -t ifup "/etc/hotplug.d/iface/01-dhcp-hostname: $*"
}
if [ ifup = "$ACTION" -a dhcp = "$PROTO" ]; then
hostname=$(uci_get system '@system[0]' hostname '')
lease_hostname=$(uci_get_state network "$INTERFACE" lease_hostname '')
if [ -n "$lease_hostname" ]; then
log "hostname: $lease_hostname"
echo "$lease_hostname" > /proc/sys/kernel/hostname
# set persistently?
case "$hostname" in
$lease_hostname)
;;
*-test)
log "commit uci system hostname: $lease_hostname"
uci_set system '@system[0]' hostname "$lease_hostname"
uci_commit
# hooks
service collectd restart
;;
*)
;;
esac
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment