So, I was setting up an automounter environ using NIS and redhat 5.x.  I
realized that the $HOST on redhat by default is fully qualified, which
makes using map entries like this: 

foobar   localhost:/disk/$HOST/0/foobar

kind of annoying.

My options were to end up creating a directory like:

/disk/foo.mydomain.com/0/

or to change the hostname to be just 'foo', or hack the autofs code.  I
chose to hack the code.  Thus, I added to variables to the available ones,
namely $NODE, which is the part of the hostname up to the first period,
and $NISDOMAIN, which is well, the NIS domain. 

It's included below.

While I'm here, does anyone know a way to fix the braindead-ism that
redhat seems to exhibit?  Namely, choosing the loopback interface as the
default instead of eth0... 

Darrell Fuhriman


diff -r -u autofs-3.1.1.old/man/autofs.5 autofs-3.1.1/man/autofs.5
--- autofs-3.1.1.old/man/autofs.5       Thu Apr  9 16:34:04 1998
+++ autofs-3.1.1/man/autofs.5   Mon Feb 15 17:11:55 1999
@@ -105,10 +105,12 @@
 .nf
 ARCH   Architecture (uname -m)
 CPU    Processor Type
-HOST   Hostname (uname -n)
+HOST   Full Hostname (uname -n)
 OSNAME Operating System (uname -s)
 OSREL  Release of OS (uname -r)
 OSVERS Version of OS (uname -v)
+NISDOMAIN      NIS Domainname (nisdomainname)
+NODE   Nodename (uname -n | sed 's/\\..*$//')
 .fi
 .RE
 .sp
diff -r -u autofs-3.1.1.old/modules/parse_sun.c autofs-3.1.1/modules/parse_sun.c
--- autofs-3.1.1.old/modules/parse_sun.c        Thu Apr  9 16:34:03 1998
+++ autofs-3.1.1/modules/parse_sun.c    Mon Feb 15 17:07:03 1999
@@ -54,6 +54,8 @@
 
 struct utsname un;
 char processor[65];            /* Not defined on Linux, so we make our own */
+char nisdomain[65];            /* This is a nice var to have */
+char nodename[65];     /* This is a nice var to have as well */
 
 static struct substvar         /* Predefined variables: tail of link chain */
   sv_arch   = { "ARCH",   un.machine,  NULL },
@@ -61,7 +63,10 @@
   sv_host   = { "HOST",   un.nodename, &sv_cpu },
   sv_osname = { "OSNAME", un.sysname,  &sv_host },
   sv_osrel  = { "OSREL",  un.release,  &sv_osname },
-  sv_osvers = { "OSVERS", un.version,  &sv_osrel };
+  sv_nisdomain = { "NISDOMAIN", nisdomain,  &sv_osrel },
+  sv_node = { "NODE", nodename,  &sv_nisdomain },
+  sv_osvers = { "OSVERS", un.version,  &sv_node };
+
 
 /* Default context pattern */
 
@@ -259,6 +264,7 @@
   const char *xopt;
   int optlen, len;
   int i, bval;
+  int j;
 
   /* Get processor information for predefined escapes */
 
@@ -270,7 +276,23 @@
     if ( processor[0] == 'i' && processor[1] >= '3' &&
         !strcmp(processor+2, "86") )
       processor[1] = '3';
+
+    /* Get NIS Domainname */
+    if ((getdomainname(nisdomain, 1024)) != 0)
+      nisdomain[0] = '\0';
+    /* Get our nodename, this is the hostname up to the first '.' */
+    uname(&un);
+    strcpy(nodename, un.nodename);
+    nodename[65] = '\0'; 
+    for(j=0; j <= 64; j++) {
+      if (nodename[j] == '.') {
+        nodename[j] = '\0'; 
+        break;
+      }
+    }
   }
+
+
 
   /* Set up context and escape chain */
   

Reply via email to