tomeshnet / prototype-cjdns-pi

Prototype system for mesh networks on single board computers
https://chat.tomesh.net/#/room/#software:tomesh.net
GNU General Public License v3.0
218 stars 42 forks source link

Control file to change hostname #376

Open darkdrgn2k opened 5 years ago

darkdrgn2k commented 5 years ago
oldhostname=$(hostname)
NEWHOSTNAME="test123"

sudo echo "$NEWHOSTNAME" | sudo tee /etc/hostname > /dev/null
sudo sed -i -e "s/$oldhostname/$NEWHOSTNAME/" /etc/hosts
sudo sed -i -e "s/$oldhostname/$NEWHOSTNAME/" /etc/yggdrasil.conf
sudo sed -i -e "s/$oldhostname/$NEWHOSTNAME/" /opt/tomesh/nodeinfo.json
sudo sed -i -e "s/$oldhostname/$NEWHOSTNAME/" /etc/hostapd/hostapd.conf
makew0rld commented 5 years ago

No CJDNS needed I assume?

makew0rld commented 5 years ago

Maybe we should have a module that aliases the hostname command to do this in /etc/profile or something? Do we want to make this a module?

darkdrgn2k commented 5 years ago

I don't think you want to do hostname. changed I profile.

to many services depend on it. hostnames shouldn't be changed randomly either.

in a config screnario it should suggest a reboot after being changed.

makew0rld commented 5 years ago

I don't think you want to do hostname. changed I profile.

I don't know what you are saying here.

to many services depend on it. hostnames shouldn't be changed randomly either.

Why did you make this script in the first place? Just in case?

darkdrgn2k commented 5 years ago

Why did you make this script in the first place? Just in case?

Came as part of my backup/restore script i was toying with. You would need to rename the node when you restore your cjdns keys.

I don't think you want to do hostname. changed I profile.

I meant you dont want to change the host-name in the profile. This requires the user to login to trigger this. Hostnames are set/changed much earlier in the boot process.

But its not a problem if we dont need to keep changing them :)

makew0rld commented 5 years ago

I meant you dont want to change the host-name in the profile. This requires the user to login to trigger this. Hostnames are set/changed much earlier in the boot process.

Alright then a systemd unit maybe?

But maybe this issue should just be closed, and you can add this as a contrib script.

makew0rld commented 5 years ago

What are you thinking of doing with this file? There is some hostname stuff going on now in #394, and this should be a contrib file if #394 doesn't do enough. Can this issue be closed?