Last active
May 8, 2018 08:22
-
-
Save Maigre/f8290fd8c356e30fa98d62372098e6d1 to your computer and use it in GitHub Desktop.
RPi change hostname at boot
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
## | |
# 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