Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=frugalwareutils.git;a=commitdiff;h=51ef2e43c5eb084d9eca78cf0fc175193921cb09

commit 51ef2e43c5eb084d9eca78cf0fc175193921cb09
Author: Miklos Vajna <vmik...@frugalware.org>
Date:   Sun Dec 12 02:58:07 2010 +0100

netconfig: write first part of hostname to /etc/hostname

This is necessary on systemd and is backwards-compatible. Note the
lowercase filename.

diff --git a/libfwnetconfig/libfwnetconfig.c b/libfwnetconfig/libfwnetconfig.c
index e0359ab..d400453 100644
--- a/libfwnetconfig/libfwnetconfig.c
+++ b/libfwnetconfig/libfwnetconfig.c
@@ -835,6 +835,19 @@ int fwnet_writeconfig(fwnet_profile_t *profile, char *host)
fclose(fp);
chmod("/etc/HOSTNAME", 0644);

+               // for systemd
+               fp = fopen("/etc/hostname", "w");
+               if(fp==NULL)
+                       return(1);
+               char *buf = strdup(host);
+               char *ptr = strchr(buf, '.');
+               if (ptr)
+                       *ptr = '\0';
+               fprintf(fp, "%s\n", buf);
+               free(buf);
+               fclose(fp);
+               chmod("/etc/hostname", 0644);
+
if(!staticip)
{
sprintf(ipaddr, "127.0.0.1");
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to