Skip to content

Commit

Permalink
Add support for sending HOSTNAME from config.txt back to DHCP server
Browse files Browse the repository at this point in the history
  • Loading branch information
coretl committed Apr 12, 2021
1 parent 8f4b57f commit 5313fb0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rootfs/network/default.script
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ case "$1" in

if [ -n "$hostname" ]; then
hostname "$hostname"
echo Hostname set to $(hostname)
echo Hostname set to $(hostname), supplied by DHCP server
elif [ -e /etc/hostname ]; then
hostname "$(cat /etc/hostname)"
elif [ "$(hostname -s)" == "panda" ]; then
Expand All @@ -66,6 +66,7 @@ case "$1" in
hostname="$(python -c "$cmd")"
if [ -n "$hostname" ]; then
hostname "$hostname"
echo Hostname set to $(hostname), looked up in DNS
else
echo "Cannot lookup hostname from $ip in DNS"
fi
Expand Down
9 changes: 9 additions & 0 deletions rootfs/network/parse-config
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,18 @@ EOF
else
echo 'iface eth0 inet dhcp'
echo -n ' udhcpc_opts -t 10 -O search'
if HOSTNAME="$(parse_config HOSTNAME)"; then
# Send hostname to DHCP server
echo -n " -x hostname:$HOSTNAME"
else
# Ask for hostname from DHCP server
echo -n " -O hostname"
fi
if NTP="$(parse_config NTP)"; then
# Use defined NTP servers
echo
else
# Ask for NTP servers from DHCP server
echo ' -O timesrv'
fi
fi
Expand Down

0 comments on commit 5313fb0

Please sign in to comment.