Skip to content

Instantly share code, notes, and snippets.

@Maigre Maigre/dynhost.sh
Last active May 8, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.