Domino on Linux/Unix, Troubleshooting, Best Practices, Tips and more ...

alt

Daniel Nashed

Installing C-API Applications on Linux

Daniel Nashed – 4 October 2017 10:51:45
When installing binaries on Linux you have to be aware of the directory structure for the files installed in the opt directory.

For installing a servertask the recommended way is to copy it to the Domino binary directory and create a start link.

For myself I created a script that handles installation of servertasks and extension managers because I don't want to do those steps manually and my script comes with a wrapper script that benefits of sudo when installing binaries on my development environment.
Also you have to take care that binaries are not running when replacing them.

Linux does not prevent you from replacing the file but the Domino server might crash after your replaced the binary. This is true for extension managers and also servertasks.
In addition the script does check if the file changed at all before replacing the binary.

So I will add this new script into the "extras" directory of my start script. But let me quickly describe what you would do in general to install a binary correctly and post the first official version of my script.


In general Domino is usually installed by default today in

/opt/ibm/domino

Below that directory there is another directory  /opt/ibm/domino/notes.

Inside that directory we have the latest major version installed (linke 90010 in my case) and a link to the latest version


drwxr-xr-x 4 root root 4096 Apr 24  2014 90010
lrwxrwxrwx 1 root root    5 Sep 26  2015 latest -> 90010

Best practice is always to use the "latest" directory

So the actual directory the binaries located is:

/opt/ibm/domino/notes/latest/linux

This directory contains all the binaries and is the place where you should copy new binaries and make them executable:

cp mybinary  /opt/ibm/domino/notes/latest/linux
chmod 755 /opt/ibm/domino/notes/latest/linux/mybinary


For an extension manager there is nothing else to do. But for a servertask you have to create a startup-link in

/opt/ibm/domino/bin

The directory contains startup links pointing to a startup script for each servertask (OK not all IBM installed servetasks have a startup link so the installer is missing to create the links).
If you environment is setup correctly with the right path settings (for example when running my start-script) that's usually not an issue.


lrwxrwxrwx 1 root root 33 Sep 26  2015 server -> /opt/ibm/domino/bin/tools/startup


This symbolic link points to another symbolic link which finally points to the internal startup script in the binary directory:

lrwxrwxrwx 1 root root   42 Sep 26  2015 startup -> /opt/ibm/domino/notes/latest/linux/startup


Invoking the following commands generates your link for the servertask. Domino creates absolute links. But I prefer relative links.


cd /opt/ibm/domino/bin
ln -s tools/startup mybinary


So what finally happens when you invoke the file on your own or if you are using the load command on the server console, is that Linux starts the internal script leveraging the symbolic link which will set the right environment for your servertask etc and than start the actual binary.

I hope this helps a bit to understand the structure and how to install binaries on Linux.

-- Daniel





#!/bin/sh


check_binary_busy()
{
  if [ ! -e "$1" ]; then
    return 0
  fi

  TARGET_REAL_BIN=`readlink -f $1`
  FOUND_TARGETS=`lsof | awk '{print $9}' | grep "$TARGET_REAL_BIN"`

  if [ -n "$FOUND_TARGETS" ]; then
    return 1
  else
    return 0
  fi
}


install_binary()
{
  SOURCE_BIN=$1

  if [ -z "$SOURCE_BIN" ]; then
    echo "no file specified"
    return 0
  fi

  INSTALL_BIN_NAME=`basename $SOURCE_BIN`

  if [ -z "$INSTALL_BIN_NAME" ]; then
    echo "no file specified"
    return 0
  fi

  TARGET_BIN=$Notes_ExecDirectory/$INSTALL_BIN_NAME

  if [ -e "$TARGET_BIN" ]; then

    cmp -s "$SOURCE_BIN" "$TARGET_BIN"
    if [ $? -eq 0 ]; then
      echo "File did not change -- No update needed"
      return 0
    fi

    if [ ! -w "$TARGET_BIN" ]; then
      echo "Error - Can not update binary '$TARGET_BIN' -- No write permissions"
      return 1
    fi


    check_binary_busy "$TARGET_BIN"

    if [ $? -eq 1 ]; then
      echo "Error - Can not update binary '$TARGET_BIN' -- Binary in use"
      return 1
    fi
  fi
 
  cp -f "$SOURCE_BIN" "$TARGET_BIN"
  chmod 755 "$TARGET_BIN"

  case "$INSTALL_BIN_NAME" in
    *.so)
      echo "Installed '$INSTALL_BIN_NAME' Extension-Manager"
      ;;

    *)
      cd $LOTUS/bin
      ln -f -s tools/startup "$INSTALL_BIN_NAME"
      echo "Installed '$INSTALL_BIN_NAME' Servertask"
      ;;

  esac

  return 0
}


export LOTUS=/opt/ibm/domino
export Notes_ExecDirectory=$LOTUS/notes/latest/linux

install_binary "$1"

exit 0

Links

    Archives


    • [HCL Domino]
    • [Domino on Linux]
    • [Nash!Com]
    • [Daniel Nashed]