[yast-devel] [PATCH yast-network] Use /etc/hostname instead of /etc/HOSTNAME
--- src/clients/save_network.ycp | 2 +- src/lan/help.ycp | 2 +- src/modules/DNS.ycp | 8 ++++---- testsuite/tests/Network_YaPI.out | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/clients/save_network.ycp b/src/clients/save_network.ycp index 429051d..5a5a0a4 100644 --- a/src/clients/save_network.ycp +++ b/src/clients/save_network.ycp @@ -376,7 +376,7 @@ void CreateOtherNetworkFiles(){ // create hostname if (size(InstallInf["hostname"]:"")>0){ y2milestone("Write HOSTNAME: %1", InstallInf["hostname"]:""); - SCR::Write(.target.string, "/etc/HOSTNAME", InstallInf["hostname"]:""); + SCR::Write(.target.string, "/etc/hostname", InstallInf["hostname"]:""); } if(InstallInf["bootproto"]:"dhcp"=="static") diff --git a/src/lan/help.ycp b/src/lan/help.ycp index 762b6a1..35e1e1d 100644 --- a/src/lan/help.ycp +++ b/src/lan/help.ycp @@ -255,7 +255,7 @@ DHCP servers update name server zones (forward and reverse records) according to this hostname (dynamic DNS).</p> Some DHCP servers require the <b>Hostname to Send</b> option field to contain a specific string in the DHCP messages from clients. Leave <b>AUTO</b> -to send the current hostname (for example, the one defined in <tt>/etc/HOSTNAME</tt>). +to send the current hostname (for example, the one defined in <tt>/etc/hostname</tt>). If you do not want to send a hostname, leave the field empty.</p> "), diff --git a/src/modules/DNS.ycp b/src/modules/DNS.ycp index b4a90c3..6d7499b 100644 --- a/src/modules/DNS.ycp +++ b/src/modules/DNS.ycp @@ -216,12 +216,12 @@ global void ReadHostname() { // the usual location if (fqhostname == "") { - if (SCR::Read (.target.size, "/etc/HOSTNAME") > 0) + if (SCR::Read (.target.size, "/etc/hostname") > 0) { - fqhostname = (string) SCR::Read (.target.string, "/etc/HOSTNAME"); + fqhostname = (string) SCR::Read (.target.string, "/etc/hostname"); //avoid passing nil argument when we get non-\n-terminated string (#445531) fqhostname = String::FirstChunk( fqhostname, "\n" ); - y2milestone("Got %1 from /etc/HOSTNAME", fqhostname); + y2milestone("Got %1 from /etc/hostname", fqhostname); } } @@ -347,7 +347,7 @@ global define boolean Write() { SCR::Execute(.target.bash, "/bin/hostname " + hostname); /* write hostname */ - SCR::Write(.target.string, "/etc/HOSTNAME", fqhostname + "\n"); + SCR::Write(.target.string, "/etc/hostname", fqhostname + "\n"); sleep(sl); /* Progress step 2/3 */ diff --git a/testsuite/tests/Network_YaPI.out b/testsuite/tests/Network_YaPI.out index 6dae320..563b7b4 100644 --- a/testsuite/tests/Network_YaPI.out +++ b/testsuite/tests/Network_YaPI.out @@ -5,8 +5,8 @@ Read .sysconfig.network.dhcp.WRITE_HOSTNAME_TO_HOSTS "no" Read .sysconfig.network.config.NETCONFIG_DNS_POLICY nil Read .sysconfig.network.config.NETCONFIG_DNS_STATIC_SERVERS "208.67.222.222 208.67.220.220" Read .sysconfig.network.config.NETCONFIG_DNS_STATIC_SEARCHLIST "suse.cz suse.de" -Read .target.size "/etc/HOSTNAME" 27 -Read .target.string "/etc/HOSTNAME" "laptop.suse.cz" +Read .target.size "/etc/hostname" 27 +Read .target.string "/etc/hostname" "laptop.suse.cz" Read .target.size "/etc/sysconfig/network/routes" 27 Read .routes [$["destination":"default", "gateway":"10.20.30.40"]] Execute .target.bash "rpm -q --whatprovides SuSEfirewall2" 0 -- 1.8.2.3 -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
Michal, please, check the diffs and proposed changes below. Does it make sense to you? Did you have any plans for unification? On 05/19/2013 11:19 PM, Cristian Rodríguez wrote:
--- src/clients/save_network.ycp | 2 +- src/lan/help.ycp | 2 +- src/modules/DNS.ycp | 8 ++++---- testsuite/tests/Network_YaPI.out | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/clients/save_network.ycp b/src/clients/save_network.ycp index 429051d..5a5a0a4 100644 --- a/src/clients/save_network.ycp +++ b/src/clients/save_network.ycp @@ -376,7 +376,7 @@ void CreateOtherNetworkFiles(){ // create hostname if (size(InstallInf["hostname"]:"")>0){ y2milestone("Write HOSTNAME: %1", InstallInf["hostname"]:""); - SCR::Write(.target.string, "/etc/HOSTNAME", InstallInf["hostname"]:""); + SCR::Write(.target.string, "/etc/hostname", InstallInf["hostname"]:""); }
Hostname.ycp in yast2.rpm seems like a better place
if(InstallInf["bootproto"]:"dhcp"=="static") diff --git a/src/lan/help.ycp b/src/lan/help.ycp index 762b6a1..35e1e1d 100644 --- a/src/lan/help.ycp +++ b/src/lan/help.ycp @@ -255,7 +255,7 @@ DHCP servers update name server zones (forward and reverse records) according to this hostname (dynamic DNS).</p> Some DHCP servers require the <b>Hostname to Send</b> option field to contain a specific string in the DHCP messages from clients. Leave <b>AUTO</b> -to send the current hostname (for example, the one defined in <tt>/etc/HOSTNAME</tt>). +to send the current hostname (for example, the one defined in <tt>/etc/hostname</tt>). If you do not want to send a hostname, leave the field empty.</p> "),
diff --git a/src/modules/DNS.ycp b/src/modules/DNS.ycp index b4a90c3..6d7499b 100644 --- a/src/modules/DNS.ycp +++ b/src/modules/DNS.ycp @@ -216,12 +216,12 @@ global void ReadHostname() { // the usual location if (fqhostname == "") { - if (SCR::Read (.target.size, "/etc/HOSTNAME") > 0) + if (SCR::Read (.target.size, "/etc/hostname") > 0) { - fqhostname = (string) SCR::Read (.target.string, "/etc/HOSTNAME"); + fqhostname = (string) SCR::Read (.target.string, "/etc/hostname"); //avoid passing nil argument when we get non-\n-terminated string (#445531) fqhostname = String::FirstChunk( fqhostname, "\n" ); - y2milestone("Got %1 from /etc/HOSTNAME", fqhostname); + y2milestone("Got %1 from /etc/hostname", fqhostname); } }
This also looks like we should unify that with Hostname.ycp in yast2.rpm. There's already code that does the reading and parsing.
@@ -347,7 +347,7 @@ global define boolean Write() { SCR::Execute(.target.bash, "/bin/hostname " + hostname);
/* write hostname */ - SCR::Write(.target.string, "/etc/HOSTNAME", fqhostname + "\n"); + SCR::Write(.target.string, "/etc/hostname", fqhostname + "\n"); sleep(sl);
This should be moved to Hostname.ycp, I'd say.
/* Progress step 2/3 */ diff --git a/testsuite/tests/Network_YaPI.out b/testsuite/tests/Network_YaPI.out index 6dae320..563b7b4 100644 --- a/testsuite/tests/Network_YaPI.out +++ b/testsuite/tests/Network_YaPI.out @@ -5,8 +5,8 @@ Read .sysconfig.network.dhcp.WRITE_HOSTNAME_TO_HOSTS "no" Read .sysconfig.network.config.NETCONFIG_DNS_POLICY nil Read .sysconfig.network.config.NETCONFIG_DNS_STATIC_SERVERS "208.67.222.222 208.67.220.220" Read .sysconfig.network.config.NETCONFIG_DNS_STATIC_SEARCHLIST "suse.cz suse.de" -Read .target.size "/etc/HOSTNAME" 27 -Read .target.string "/etc/HOSTNAME" "laptop.suse.cz" +Read .target.size "/etc/hostname" 27 +Read .target.string "/etc/hostname" "laptop.suse.cz" Read .target.size "/etc/sysconfig/network/routes" 27 Read .routes [$["destination":"default", "gateway":"10.20.30.40"]] Execute .target.bash "rpm -q --whatprovides SuSEfirewall2" 0
And the check then also belongs to Hostname.ycp -- Lukas Ocilka, Cloud & Systems Management Department SUSE LINUX s.r.o., Praha -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
El 20/05/13 05:13, Lukas Ocilka escribió:
Michal, please, check the diffs and proposed changes below. Does it make sense to you? Did you have any plans for unification?
On 05/19/2013 11:19 PM, Cristian Rodríguez wrote:
--- src/clients/save_network.ycp | 2 +- src/lan/help.ycp | 2 +- src/modules/DNS.ycp | 8 ++++---- testsuite/tests/Network_YaPI.out | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/clients/save_network.ycp b/src/clients/save_network.ycp index 429051d..5a5a0a4 100644 --- a/src/clients/save_network.ycp +++ b/src/clients/save_network.ycp @@ -376,7 +376,7 @@ void CreateOtherNetworkFiles(){ // create hostname if (size(InstallInf["hostname"]:"")>0){ y2milestone("Write HOSTNAME: %1", InstallInf["hostname"]:""); - SCR::Write(.target.string, "/etc/HOSTNAME", InstallInf["hostname"]:""); + SCR::Write(.target.string, "/etc/hostname", InstallInf["hostname"]:""); }
Hostname.ycp in yast2.rpm seems like a better place
Ok, so there is a single place in the universe where this is done but code does not call it.. good.. that should make everything less ugly and could be implemented in a different fashion. What is the right way for Yast to call systemd-hostnamed via DBUS ? It must call the SetHostname() in the "write hostname" operation and read the property Hostname to retrive the information. gdbus introspect --system --dest org.freedesktop.hostname1 --object-path /org/freedesktop/hostname1 node /org/freedesktop/hostname1 -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
Lukas, there is place for refactoring. As usual in network ;-) Cristian,
--- src/clients/save_network.ycp | 2 +- src/lan/help.ycp | 2 +- src/modules/DNS.ycp | 8 ++++---- testsuite/tests/Network_YaPI.out | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-)
Is there any reference why / when is such change needed? I know that HOSTNAME is SUSE specific and systemd specifies hostname as a "standard", but the change has to come from netcfg. Is the change there already (which version)? Thanks for details. Michal Filka -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
El 20/05/13 05:16, Michal Filka escribió:
Lukas, there is place for refactoring. As usual in network ;-)
Cristian,
--- src/clients/save_network.ycp | 2 +- src/lan/help.ycp | 2 +- src/modules/DNS.ycp | 8 ++++---- testsuite/tests/Network_YaPI.out | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-)
Is there any reference why / when is such change needed? I know that HOSTNAME is SUSE specific and systemd specifies hostname as a "standard", but the change has to come from netcfg. Is the change there already (which version)?
Thanks for details.
Michal Filka
Yes, all other distributions have /etc/hostname instead of /etc/HOSTNAME currently systemd carries a patch to please YAST, this is of course, absolute madness, so I am now trying the rational, sane approach of fixing YAST instead. but the change has to come from netcfg. Is the change there
already (which version)?
from netcfg ? netcfg is just a bunch of text files, why we should care about it ? (/etc/HOSTNAME could be removed later from the package no longer used) -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org To contact the owner, e-mail: yast-devel+owner@opensuse.org
participants (3)
-
Cristian Rodríguez
-
Lukas Ocilka
-
Michal Filka