openhab / openhab-linuxpkg

Repo for Linux packages
Eclipse Public License 2.0
18 stars 33 forks source link

Provide info command for openhab-cli #83

Closed BClark09 closed 6 years ago

BClark09 commented 6 years ago

A command that can be used for quick diagnostic information should be added to the CLI:

user@server:~ $ openhab-cli info

Version:        2.2.0-SNAPSHOT
User Groups:    The user 'openhab' belongs to groups 'openhab tty dialout'
Directories:    Folder Name      | Path                           | User:Group
                -----------      | ----                           | ----------
                OPENHAB_HOME     | /usr/share/openhab2            | openhab:openhab
                OPENHAB_RUNTIME  | /usr/share/openhab2/runtime    | openhab:openhab
                OPENHAB_USERDATA | /var/lib/openhab2              | openhab:openhab
                OPENHAB_CONF     | /etc/openhab2                  | openhab:openhab
                OPENHAB_LOGDIR   | /var/log/openhab2              | openhab:openhab
                OPENHAB_BACKUPS  | /var/lib/openhab2/backups      | openhab:openhab

@ThomDietrich, can you think of any other stat that may be useful here?

ThomDietrich commented 6 years ago

Good idea. Above "User Groups" maybe add "User"? How about the URL of the openHAB dashboard, uses might change the http port and forget about that.

BClark09 commented 6 years ago

So something like this:

user@server:~ $ openhab-cli info
Version:        2.2.0-SNAPSHOT (#1051)
User:           openhab (Active Process 18965)
User Groups:    openhab tty dialout

Directories:    Folder Name      | Path                           | User:Group
                -----------      | ----                           | ----------
                OPENHAB_HOME     | /usr/share/openhab2            | openhab:openhab
                OPENHAB_RUNTIME  | /usr/share/openhab2/runtime    | openhab:openhab
                OPENHAB_USERDATA | /var/lib/openhab2              | openhab:openhab
                OPENHAB_CONF     | /etc/openhab2                  | openhab:openhab
                OPENHAB_LOGDIR   | /var/log/openhab2              | openhab:openhab
                OPENHAB_BACKUPS  | /var/lib/openhab2/backups      | openhab:openhab

Dashboard URLS: http://192.168.0.10:8080
                https://192.168.0.10:8443
ThomDietrich commented 6 years ago

Looks good. What's the use case for the active process number?

In openHABian I'm already showing a few of these details. In the URL I'm using the hostname (I know that it can be less ideal in some scenarios).

BClark09 commented 6 years ago

The user might be different depending on how openHAB was started. So in priority order I search for the user by:

  1. Finding the username that owns the currently running process, if no process is running...
  2. Rely on a $OPENHAB_USER being set, but if nothing has been set...
  3. Find the owner of the $OPENHAB_HOME directory.

I'll put up a PR to show what I've done in a bit.