Created
July 26, 2014 18:10
-
-
Save SpComb/c1bb74609827ff516212 to your computer and use it in GitHub Desktop.
openwrt:/etc/hotplug.d/iface/01-dhcp-hostname
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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