Knowledge Base
Searching in : Article
ID: AR01H00550
Applies to: NX Software
Added on: 2010-01-04
Last Update: 2013-10-23

How to install NX Server 3.5.0 if the user nx already exists in LDAP or NIS directory

The NX server installation creates the nx user on the system and can't be completed successfully when that user is already present. This could be due to an unclean uninstallation of the software or to the fact that the nx user already exists in a directory (LDAP or NIS).

In order to proceed with a clean installation of the NX software, the administrator should first ensure that the nx user is not present on the system.

If the user is already on the system, the administrator could try to modify the NX server installation script in such a way so that the script does not interrupt the installation if the nx user is present.

We suggest to apply these modifications:

1. Undo previous installation attempts by removing the directory
    /usr/NX completely.

2. Make sure the nx user exists in your directory, has
    '/usr/NX/bin/nxserver' as SHELL, and has set
    /usr/NX/home/nx' as home directory.

3. Install nxnode.

4. Unpack the NoMachine server distribution into the /usr directory.
    If you are installing from the RPM packages, run rpm with the
    '--noscripts' argument.

   rpm -i --noscripts nxserver-*.rpm

5. Add a routine into the installation script

    /usr/NX/scripts/setup/nxserver

that checks for a valid nx user, HOME and SHELL. So if there's an nx user, bail out if   HOME or SHELL are wrong, otherwise continue.
   
If there's no nx user, create it. To add that routine, save the attached lines from below to a file,

    e.g. /tmp/nxserver.patch

and apply it with the following commands:

  cd /usr/NX/scripts/setup
     patch < /tmp/nxserver.patch

6. Complete the NoMachine NX server installation.

   '/usr/NX/scripts/setup/nxserver --install'.

Here's a sample patch that could be applied to the NX server installation script, that can be easily tuned by the administrator to fit their own needs:

--- /usr/NX/scripts/setup/nxserver    2009-09-29 09:02:32.000000000 +0200
+++ /usr/NX/scripts/setup/nxserver.patch    2009-12-28 17:29:22.703282633 +0100
@@ -2794,6 +2794,39 @@
   fi
 
 
+checkForNXUser ()
+  result=`id nx 2>&1`
+  if [ $? = 0 ]
+  then
+    printMsg "User 'nx' exists."
+    result=0
+    FOUND_NXHOME=`getent passwd | awk -F:  '/^nx:/print $6'`
+    if [ "$FOUND_NXHOME" != "$NODE_ROOT/home/nx" ]
+    then
+      printMsg "The HOME directory for user 'nx' is set incorrectly." "error"
+      result=1
+    fi
+    FOUND_NXSHELL=`getent passwd | awk -F:  '/^nx:/print $7'`
+    if [ "$FOUND_NXSHELL" != "$NXSHELL" ]
+    then
+      printMsg "User 'nx' does not have the correct shell." "error"
+      result=1
+    fi
+    if [ $result == 1 ]
+    then
+      printMsgNoDot "To fix the problem, you may try to completely"
+      printMsgNoDot "uninstall NX Server. Please set for user 'nx':"
+      printMsgNoDot "- the home directory to '$NODE_ROOT/home/nx'"
+      printMsgNoDot "- the SHELL to '$NXSHELL'"
+      printMsgNoDot "Then proceed with a new installation of NX Server"
+      exit 1
+    fi
+  else
+    result=1
+  fi
+  return $result
+
+
 procedureInstallServer()
   umask 022   
   if [ -f "$CONFIG_FILE" ];
@@ -2807,20 +2840,9 @@
     fi
   fi
 

-  result=`id nx 2>&1`
-  if [ $? = 0 ];
-  then
-#     printMsg "Cannot add user: nx. User: nx already exists" "error"
-#     printMsg "Please try to fix the problem by reinstalling the server" "error"
-    printMsg "Cannot add user: nx" "error"
-    printMsg "User: nx already exists" "error"
-    printMsgNoDot "To fix the problem, you may try to completely uninstall NX"
-    printMsgNoDot "Server and install it from scratch. If this is not enough,"
-    printMsgNoDot "please delete the nx user by using the system commands and"
-    printMsg "proceed with a new installation of NX Server"
-    exit 1
-  fi
+  # See if there's a user nx with the appropriate $HOME and $SHELL
+  checkForNXUser
+  result=$?
 
   LOGFILE="$INSTALLOG"
   createLogdirectory
@@ -2831,13 +2853,16 @@
   printMsg "Install log is: $LOGFILE"
 #  printMsg "Installing $PRODUCT_NAME."
 
-  if [ "$system" != "solaris" ];
+  if [ $result -gt 0 ]
   then
-    addNXUserLinux
-  else
-    addNXUserSolaris
+    if [ "$system" != "solaris" ];
+    then
+      addNXUserLinux
+    else
+      addNXUserSolaris
+    fi
+    setShell
   fi
-  setShell
   genNXUsersKeys
   makeNXConfigServer
   checkNXUsersFile