You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been adding the following service to my Pi images so that I can use a file /boot/hostname to set the hostname the Pi will boot with before putting the SD card into the Pi.
I'm curious if you would consider adding this script to this package, or alternatively, if there was a different package that this would be good for.
Here is the service file:
[Unit]Description=Change hostname by /boot file
ConditionFileNotEmpty=/boot/hostname
Before=network-pre.target
Wants=network-pre.target
[Service]Type=oneshot
# Print current hostname for logsExecStart=/usr/bin/hostname
# Copy hostname fileExecStart=/bin/cp /boot/hostname /etc/hostname
# Ensure file ends with a newlineExecStart=/usr/bin/sed -i -e $$a\\ /etc/hostname
# Set hostname from fileExecStart=/usr/bin/hostname -F /etc/hostname
# Remove default hostname from /etc/hosts# Should this be changed to work for any hostname that is currently in `/etc/hosts`, instead of hard coded "raspberrypi"?ExecStart=/usr/bin/sed -i.orig -E /^127.0.1.1\\s+raspberrypi\\s*$$/d /etc/hosts
# Add new hostname to /etc/hostsExecStart=/bin/sh -c 'echo 127.0.1.1\\t$(hostname) >> /etc/hosts'# Reset hostname file in /bootExecStart=/usr/bin/truncate -s 0 /boot/hostname
[Install]WantedBy=multi-user.target
I opted to keep the file around and just empty it to indicate that it's been used.
The text was updated successfully, but these errors were encountered:
I've been adding the following service to my Pi images so that I can use a file
/boot/hostname
to set the hostname the Pi will boot with before putting the SD card into the Pi.I'm curious if you would consider adding this script to this package, or alternatively, if there was a different package that this would be good for.
Here is the service file:
I opted to keep the file around and just empty it to indicate that it's been used.
The text was updated successfully, but these errors were encountered: