WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Suggestion: Allow a parameter to specify host name for sethostname()  (Read 3053 times)

Offline maro

  • Hero Member
  • *****
  • Posts: 1228
The following idea is a consequence of reading about a users problems with changing the host name:

The sethostname() function (in '/etc/init.d/tc-functions') always uses the value from the 'host=...' boot code or defaults to 'box'. I'd like to suggest a change insofar as to allow for a parameter supplied to sethostname() to overwrite this. I'd imagine that [ -z "$1" ] && HOSTNAME="$(getbootparam host 2>/dev/null)" || HOSTNAME=$1 instead of HOSTNAME="$(getbootparam host 2>/dev/null)" should achieve just that.

With this in place it would be just a matter of executing something like sudo sh -c '. /etc/init.d/tc-functions ; sethostname box2' to change the host name more easily without having to use the boot code.

Offline roberts

  • Administrator
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: Suggestion: Allow a parameter to specify host name for sethostname()
« Reply #1 on: March 15, 2011, 04:28:27 PM »
I have implemented this idea. Although in a slightly different way, Look for it starting with v3.6.
10+ Years Contributing to Linux Open Source Projects.