Created
March 17, 2022 21:57
-
-
Save fegue/d1e0c1228fff9909758e4a55040a201c to your computer and use it in GitHub Desktop.
Set hostname on raspberry pi
This file contains hidden or 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
#!/bin/sh | |
if test $# -eq 0 | |
then | |
echo "No name on command line." | |
exit 1 | |
fi | |
echo $1 | |
NAME=$1 | |
echo $NAME | |
echo $NAME | sudo tee /etc/hostname | |
sudo sed -i -e 's/^.*hostname-setter.*$//g' /etc/hosts | |
echo "127.0.1.1 " $NAME " ### Set by hostname-setter" | sudo tee -a /etc/hosts | |
sudo service hostname.sh stop | |
sudo service hostname.sh start | |
echo "Hostname set. Log out to see it on the command line" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment