Menu

#559 startup scripts does not work when called by link

Broad_impact
closed
nobody
GitHub (1)
6
2016-09-19
2016-09-19
No

The startup scripts use dirname to get the installation directory. This does not work when called by link. To fix readlink should be used:

The scripts should use:
SCRIPTDIR=$(cd "$( dirname "$( readlink -e "${0}" )
instead of
SCRIPTDIR=$(cd "$( dirname "${0}" )" && pwd)

To reproduce install in /opt. Use sudo ln -s /opt/JMRI/DecoderPro /usr/local/bin/decoderpro and start by decoderpro.

Discussion

  • Martin Pischky

    Martin Pischky - 2016-09-19

    sorry missed some chars by cut&past
    SCRIPTDIR=$(cd "$( dirname "$( readlink -e "${0}" )" )" && pwd)

    See also https://github.com/JMRI/JMRI/issues/1978

     
  • Randall Wood

    Randall Wood - 2016-09-19

    The proposed fix breaks these scripts on macOS, although it implements readlink, it does not use GNU readlink.

    The startup scripts are intended to be able to run on any POSIX system that supports bash 3, and the readlink command is not specified in POSIX, so there may be other operating systems that do not have it (nor is it a requirement that a Linux distribution include it, so there is no guarentee that readlink is available on a Linux system either).

    BTW, is there a reason, you cannot run DecoderPro directly out of /opt/JMRI or add /opt/JMRI to your PATH environment variable?

     
    • Ken Cameron

      Ken Cameron - 2016-09-19

      Running add-on code by having /usr/local/bin is an age old Unix standard
      method. It would usually be a bunch of links to other things in
      /usr/local/. The other classic method was /usr/bin having lots of links to
      other places, like /opt/
      .

      At least in the old days it was considered poor form for Unix management to
      add everything to the PATH. Granted it was very common for the launch script
      to add thing to the PATH, but that was only for that process.

      The reason from my memory was twofold:

      1st to keep the length of the PATH to a reasonable size (environment
      variables sometimes had limits on char length like 5120) which helped make
      debugging simpler, think of the length of log messages.

      2nd was as you keep adding things to PATH, the odds of name duplication
      between different packages would increase and that meant that you would not
      execute what you thought you wanted depending on exactly which order things
      existed in the PATH.

      But it seems a lot of that organization seemed to get lost during the 90's
      as Linux grew and a lot of the old architecture was lost from the collective
      memory.

      -Ken Cameron, Member JMRI Dev Team

      www.jmri.org

      www.fingerlakeslivesteamers.org

      www.cnymod.com

      www.syracusemodelrr.org

       
  • Randall Wood

    Randall Wood - 2016-09-19
    • labels: --> GitHub
    • status: open --> closed
     
  • Randall Wood

    Randall Wood - 2016-09-19
     
MongoDB Logo MongoDB