Skip to content

Instantly share code, notes, and snippets.

@Maigre
Last active May 8, 2018 08:22
Show Gist options
  • Save Maigre/f8290fd8c356e30fa98d62372098e6d1 to your computer and use it in GitHub Desktop.
Save Maigre/f8290fd8c356e30fa98d62372098e6d1 to your computer and use it in GitHub Desktop.
RPi change hostname at boot
##
# DYNHOST SCRIPT
##
> nano /root/dynhost.sh
#!/bin/bash
name=rpi
source /boot/config.txt
hostnamectl set-hostname "$name"
# ADD name=the-name in /boot/config.txt
##
# SYSTEMD UNIT
##
> nano /etc/systemd/system/dynhost.service
[Unit]
Description=Dynamic Hostname
After=systemd-hostnamed.service
[Service]
Type=oneshot
ExecStart=/root/dynhost.sh
[Install]
WantedBy=multi-user.target
> systemctl enable dynhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment