WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: change the hostname, make it permanent and replace tc@box when booting from CD  (Read 24074 times)

Offline beerstein

  • Hero Member
  • *****
  • Posts: 530
Hi:
I changed the name "box" in /etc/hostname from "box" to "box2" and put the
hostname file into the /opt/.filetool.lst
After reboot hostname is still "box2"

but in my Terminal I still see tc@box instaed of tc@box2

How can I change that?

Thank you so much in advance

roberts edited title. Added: "when booting from CD"
« Last Edit: March 15, 2011, 04:30:30 PM by roberts »
t(w)o be(ers) or not t(w)o be(ers) that is the question

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: change the hostname, make it permanent and replace tc@box
« Reply #1 on: February 27, 2011, 12:41:37 PM »
Hi beerstein
I set up a script file in /opt for my file server to do this with the following commands.

#!/bin/sh
NEWNAME="BitBucket"
echo $NEWNAME > /etc/hostname
hostname -F /etc/hostname
cat > /etc/hosts <<EOT
127.0.0.1 $NEWNAME localhost
EOF

Don't forget to make it executable and add it to filetool.lst.

Offline combo3

  • Full Member
  • ***
  • Posts: 148
Re: change the hostname, make it permanent and replace tc@box
« Reply #2 on: February 27, 2011, 01:09:24 PM »
Or you can just append host=box2 as a boot option and let the init.d scripts set /etc/hosts and /etc/hostname for you automagically.  ;) 

Offline beerstein

  • Hero Member
  • *****
  • Posts: 530
Re: change the hostname, make it permanent and replace tc@box
« Reply #3 on: February 28, 2011, 02:49:00 AM »
thank you so much for your help. I will try it out.
In another post I have red that it is not necessary to change the "box" , but what do you think?

I have several machines running TC and they all have the name "box" but different IP addresses?
That may get a mess when I try to connect via host names.  Is this correct?

Or does the name "box" in tc@box  not affect the machine host-named "box2" which also has tc@box in its CL?

 
t(w)o be(ers) or not t(w)o be(ers) that is the question

Online Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14516
Re: change the hostname, make it permanent and replace tc@box
« Reply #4 on: February 28, 2011, 03:08:54 AM »
I've seen problems on a local network which automatically resolved local host names when more than one machine is called "box"

Offline beerstein

  • Hero Member
  • *****
  • Posts: 530
Re: change the hostname, make it permanent and replace tc@box
« Reply #5 on: February 28, 2011, 01:16:22 PM »
Hi:
Rich I tried your script and tried to test it from the CL - it worked and my tc@box changed to
tc@box2
BUT: After that I was not able to click on anything on my screen and could not backup.
The terminal was still working. So I put "box" back into the file hostname
did the following:
$ hostname -L /etc/hostname

so my old tc@box was back and with it all my applications .

BTW: On another PC where I have a frugal install I put host=box2 into the kernel line in menu.lst
And that is working.
But On the CD boot system I can not make this permanent - that way

Any suggestions?

Thank you and have a good day

t(w)o be(ers) or not t(w)o be(ers) that is the question

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: change the hostname, make it permanent and replace tc@box
« Reply #6 on: February 28, 2011, 03:15:57 PM »
Hi beerstein
I see I had a typo in my script, change EOT to EOF and see if that helps.

Offline beerstein

  • Hero Member
  • *****
  • Posts: 530
Re: change the hostname, make it permanent and replace tc@box
« Reply #7 on: March 13, 2011, 01:11:35 PM »
Hi Rich:
thank you for your last post. I tried several things and I could not change the hostname from tc@box
into tc@box2. here is my script:

#!/bin/sh
#original script EOT changed to EOF
NEWNAME="box2"
echo $NEWNAME > /etc/hostname
hostname -F /etc/hostname
cat > /etc/hosts << EOF
127.0.0.1 $NEWNAME localhost
EOF

I saved it as changeh.sh into /opt/changeh.sh

I changed ownership to: root/staff
and permissions to 100775

I added to /opt/.filetool.lst   opt/changeh.sh
I also changed box into box2 in /etc/hosts   and /etc/hostname and added these two files also
to the .filetool.lst so that they do not loose its content after backup and reboot.

When I start the script in /opt/changeh.sh manually the terminal idenifier changes from tc@box into tc@box2, but
then may appliactions freeze



t(w)o be(ers) or not t(w)o be(ers) that is the question

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: change the hostname, make it permanent and replace tc@box
« Reply #8 on: March 13, 2011, 01:17:00 PM »
Add the boot option "host=box2".

Offline beerstein

  • Hero Member
  • *****
  • Posts: 530
Re: change the hostname, make it permanent and replace tc@box
« Reply #9 on: March 13, 2011, 01:51:57 PM »
Hi gerald_clark: Thank you for this. Yes - on a frugal install and boot via grub I have
added this into the kernel line in menue.lst. Works fine.

I also can use the bootcode: tinycore host=box2 when booting from CD, but I would like to have it
built in so I can save this input everytime I boot.

It should work somehow. May be I have to put something into the bootlocal file?
t(w)o be(ers) or not t(w)o be(ers) that is the question

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
Re: change the hostname, make it permanent and replace tc@box
« Reply #10 on: March 13, 2011, 05:50:48 PM »
@beerstein: Having a separate script (e.g. '/opt/changeh.sh') which does in fact a subset of the sethostname() function (in '/etc/init.d/tc-functions') might work for you, but only if this script is also called as part of the boot process. This probably should be done from '/opt/bootlocal.sh'. I'm not sure when reading your description that you've included such a call.

Whilst I agree with gerald_clark that probably the best (and easiest) way is to use a boot code I've just suggested an alternative. By enhancing in a minor way the Core functionality in this matter one would not need to rely on an additional script (which feels to me more like "re-inventing the wheel").

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: change the hostname, make it permanent and replace tc@box
« Reply #11 on: March 13, 2011, 06:37:16 PM »
Hi beerstein
I execute the script by calling it from bootlocal.sh. The script sets up the hosts and hostname files
so adding them to the filetool.lst will cause a conflict, don't do that.

@maro: That's exactly where I got it from, minus the IPv6 stuff. I did it this way because I didn't want
to burn a new CD just to change the name of my file server. I agree that the boot code is the
preferred way when it's practical.


Offline beerstein

  • Hero Member
  • *****
  • Posts: 530
Re: change the hostname, make it permanent and replace tc@box
« Reply #12 on: March 14, 2011, 05:22:09 AM »
Hi there:
Yes - I tried that too: I put my script named /opt/changeh.sh into bootlocal and in addition
into /opt/.filetool.lst.
When I backed up and rebooted, my screen was black and a white mouse cursor (shaped like white + )
was sitting in the middle of the screen. I could move the cursor, but was not able to see a result from right- or left clicking the mouse. (dead)
So I used <CTRL> <ALT> F1 to switch to the command Line (CL)
Here I saw that my system was named: tc@box2
When I switched back using  <CTRL> <ALT> F2 I still saw the black screen with the white cursor. So I went back to the command line using <CTRL> <ALT> F1 and started with startx - and all of the sudden I had my good old original TC screen back. (w-bar and everything worked) Even the terminal emulator now showed tc@box2.

But this procedure is not what I want.

Do you think I should remove the script from /opt/.filetool.lst ? and leve it only in /opt/bootlocal ?

I will play around in the meantime, but I am always scared that will get stuck and will not be able to backup in order to fix problems I have generated.

t(w)o be(ers) or not t(w)o be(ers) that is the question

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10957
Re: change the hostname, make it permanent and replace tc@box
« Reply #13 on: March 14, 2011, 05:35:43 AM »
Hm, right, if you do that with a script it should go in bootsync. X may not like if the hostname changes from under it.
The only barriers that can stop you are the ones you create yourself.

Offline beerstein

  • Hero Member
  • *****
  • Posts: 530
Re: change the hostname, make it permanent and replace tc@box
« Reply #14 on: March 14, 2011, 07:21:17 AM »
Hi there:
I put the script "changeh.sh" located in /opt into /opt/bootlocal.sh and removed it from /opt/.filetool.lst

Ouch this was bad thinking, because the script "changeh.sh" disappeared from the /opt/ folder due to the fact, that it was not listed in /opt/.filetool.lst any more. Now what?

So I left it in bootlocal.sh and put it back again into /opt/.filetool.lst.

After backup and reboot I see that black screen with the white mouse cursor in the middle. I can move the mouse cursor but no clicks recocnized.
Going to the command CL line and comming back using tc@box2~$startx I am in business and have what I wanted.

But I think there is a problem with X and or the WM.
I have no idea how to fix that. Can somebody please help me?





t(w)o be(ers) or not t(w)o be(ers) that is the question