Linux Install via Bash Script



Installation Instructions

Please follow the instructions below to install and setup your Monocle Gateway service using a scripted base installer.

Note: The following instructions are using the Compressed Archive (Bash Script) installer package. If you would prefer to use the simpler Debian package installer method, please visit this page.

1.) Download latest Monocle Gateway

Download the latest Monocle Gateway build for your system here. Make sure to download the Compressed Archive installer package: *.tar.gz > Monocle Gateway - Download Latest Release

This is a special build compiled specifically for compatibility across the Raspberry Pi 32-bit platform and various models.

32-bit Linux Debian Package (.deb) RaspberryPi 32-bit Linux Compressed Archive (.tar.gz) RaspberryPi

Note: SHA1 and MD5 Hashes are available here

Or use the following command to download the latest Monocle Gateway build directly to your system:

mkdir ~/monocle-gateway
cd ~/monocle-gateway
curl -O https://files.monoclecam.com/monocle-gateway/linux/monocle-gateway-linux-raspi-v0.0.4.tar.gz

Please follow the instructions below to install and setup your Monocle Gateway service.

2.) Create Configuration Directory.

Use the following command to create the monocle system configuration directory:

sudo mkdir /etc/monocle

3.) Monocle API token for Authentication

Generate and download your Monocle API token from your user account page in the Monocle web portal. See this topic for more details on how to generate your API token: Monocle API Token

Once you have downloaded your monocle API token file, move or copy it to the Monocle system configuration directory: /etc/monocle/monocle.token


4.) Extract the contents of the archive file.

cd ~/monocle-gateway
tar -xvzf monocle-gateway-linux-raspi-v0.0.4.tar.gz

5.) Launch the "monocle-gateway" application from command line to verify its working properly.

cd ~/monocle-gateway
sudo ./monocle-gateway

If Monocle Gateway starts up successfully and established a connection to the Monocle platform , then you will get a print out that looks similar to the following. Make sure to look for any errors on startup that may indicate a problem that would prevent Monocle Gateway from working correctly.

 ******************************************************************
 *             __  __  ___  _  _  ___   ___ _    ___              *
 *            |  \/  |/ _ \| \| |/ _ \ / __| |  | __|             *
 *            | |\/| | (_) | .` | (_) | (__| |__| _|              *
 *            |_|  |_|\___/|_|\_|\___/ \___|____|___|             *
 *                                                                *
 ******************************************************************

-------------------------------------------------
MONOCLE RUNTIME ENVIRONMENT
-------------------------------------------------
VERSION   = 0.0.6
OS/ARCH   = linux/arm
PROCESS   = monocle-gateway (PID=9652)
TIMESTAMP = 2018-06-08T18:36:04.256Z

-------------------------------------------------
MONOCLE GATEWAY SERVICE         (Version: 0.0.6)
-------------------------------------------------
[Monocle Starting]
[Monocle Connecting]
[Monocle Started]
[RTSP Server Starting]
[RTSP Server Listening] 0.0.0.0:8555 (RTSP)
[RTSP Server Listening] 0.0.0.0:443 (RTSP-TLS)
[RTSP Proxy Started] (PID=468)
[RTSP Server Listening] 0.0.0.0:8554 (PROXY)
[RTSP Server Started]
[Monocle Connected]
[RTSP Server Registered]

-------------------------------------------------
MONOCLE RTSP SERVICE - INITIALIZED
-------------------------------------------------
FQDN = c5b4w3q2-bv4f-4sdf9-dsf-28a852ecae54.mproxy.io
HOST = 192.168.1.22
PORT = 443
-------------------------------------------------

Look for the MONOCLE RTSP SERVICE - INITIALIZED message; this means that everything started successfully and the gateway is fully running.  


6.) Configure one or more cameras for use with the Monocle Gateway service.

The Monocle web portal has not yet been updated to include a user interface for configuring which cameras should use the Monocle Gateway service.

Please see the Tagging Cameras for Monocle Gateway topic for the interim solution.


7.) Test your configured cameras with the Monocle Gateway service.

Now you are ready to test our your camera(s) using your Alexa device and Monocle via the Monocle Gateway. Just ask Alexa to show you one of your named cameras that have been configured to use the Monocle Gateway service.

You should see the named camera displayed in the Monocle Gateway service command console followed by some details logging information as well as the camera stream displayed on your Alexa device.

-------------------------------------------------
INITIALIZE RTSP STREAM:  Kitchen
-------------------------------------------------
 - NAME  : Kitchen
 - LABEL : PRIMARY
 - URL   : rtsp://192.168.1.251:554/cam/realmonitor?channel=1&subtype=0
 - UUID  : STREAM:99d01a23-c6sd-46-bb11-v1d9edda4523
 - SESS  : e28ba6f0-3c2a-481e-a715-4f989c615a0a
 - MODIF : Thu May 17 2018 16:38:55 GMT-0400 (Eastern Daylight Time)
-------------------------------------------------

2018-06-08T18:48:54.971Z [INFO]  [10.1.2.217:40172 <BJkj18ulm>] RTSP CLIENT SOCKET CONNECTED
2018-06-08T18:48:55.103Z [INFO]  [10.1.2.217:40172 <BJkj18ulm>] RTSP CLIENT ATTACHED TO STREAM: Kitchen (STREAM:99d01a23-c6sd-46-bb11-v1d9edda4523)
2018-06-08T18:48:55.120Z [INFO]  [10.1.2.217:40172 <BJkj18ulm>] RTSP ENDPOINT SOCKET CONNECTED {192.168.1.251:554}
2018-06-08T18:48:55.130Z [DEBUG] [10.1.2.217:40172 <BJkj18ulm>] [CLIENT REQUEST]  --> [DESCRIBE] rtsp://c5b4w3q2-bv4f-4sdf9-dsf-28a852ecae54.mproxy.io:443/STREAM:99d01a23-c6sd-46-bb11-v1d9edda4523?session=e28ba6f0-3c2a-481e-a715-4f989c615a0a
...

Once you have successfully tested your cameras, you can stop the Monocle Gateway service by pressing CTRL-C (you may have to press it several times) and then install Monocle Gateway as a service as demonstrated in the next topic.

8.) Install the Monocle Gateway service daemon on your system

The following command will install the Monocle Gateway service using systemd.

cd ~/monocle-gateway
sudo ./install.sh

The install script will copy the required executables to the /usr/local/bin directory, copy the monocle-gateway.service file to the systemd configuration directory, create a monocle service user account, enable access to protected IP ports to bind to port 443 and enable the daemon to start on boot.

(Feel free to review the install script prior to running the script to ensure you are comfortable with the actions/tasks performed.)

The following is an example of the installation process.

-----------------------------------
Installing Monocle Gateway
-----------------------------------
Creating 'monocle' system user account
Creating configuration directory at '/etc/monocle/'
Unpacking monocle-gateway (0.0.6) ...
Setting up monocle-gateway (0.0.6) ...
Configuring bind access to system reserved port 443
Reloading systemd daemon
Starting Monocle Gateway service daemon
Enabling Monocle Gateway service deamon to start automatically
Created symlink /etc/systemd/system/multi-user.target.wants/monocle-gateway.service → /etc/systemd/system/monocle-gateway.service.
-----------------------------------
Monocle Gateway Installed
-----------------------------------

Service/Daemon Management

The following commands can be executed in start, stop and restart the Monocle Gateway service daemon. You must run the command with sudo privileges.

  • Start the Monocle Gateway servicet:

    sudo monocle-gateway --start
    Alternatively, you can also use the following native command:
    sudo systemctl start monocle-gateway

  • Stop the Monocle Gateway service:

    sudo monocle-gateway --stop
    Alternatively, you can also use the following native command:
    sudo systemctl stop monocle-gateway

  • Restart the Monocle Gateway service:

    sudo monocle-gateway --restart
    Alternatively, you can also use the following native command:
    sudo systemctl restart monocle-gateway

  • Get the Status of the Monocle Gateway service:

    sudo monocle-gateway --status
    Alternatively, you can also use the following native command:
    sudo systemctl status monocle-gateway

  • Enable the Monocle Gateway service on system boot:

    sudo monocle-gateway --enable
    Alternatively, you can also use the following native command:
    sudo systemctl enable monocle-gateway

  • Disable the Monocle Gateway service on system boot:

    sudo monocle-gateway --disable
    Alternatively, you can also use the following native command:
    sudo systemctl disable monocle-gateway

Logging

If running the Monocle Gateway as a systemd service the application will write its output to the journald service.

To monitor ("tail") the log file while the service is running you can use the following command:

sudo monocle-gateway --tail
Alternatively, you can also use the following native command:
sudo journalctl -f -u monocle-gateway

Removal Instructions

Uninstalling and removing the Monocle Gateway from the computer is very simple. You can use the uninstall.sh script included in the downloaded archive package to automate the remove of the Monocle Gateway service. This script will delete the executable binaries on the system, disable and remove the systemd service configuration and remove the monocle system user account.

cd ~/monocle-gateway
sudo ./uninstall.sh

If you prefer to manually remove the service or don't have access to the uninstall.sh script, you can run the following command to disable and stop the daemon service.

sudo systemctl stop monocle-gateway
sudo systemctl disable monocle-gateway

Next, remove the privileged port access from the service executable:

sudo setcap -r /usr/local/bin/monocle-gateway

Then delete the following files:

sudo rm /usr/local/bin/monocle-gateway
sudo rm /usr/local/bin/monocle-proxy
sudo rm /etc/systemd/system/monocle.service

Next, remove the monocle system user account with the following command:

sudo deluser --system monocle

Lastly you can optionally remove the monocle.token file and monocle system configuration directory if you don't plan on re-using it in the future:

sudo rm -R /etc/monocle