Skip to content

Over-the-air update portal for JAMScript-connected devices

Notifications You must be signed in to change notification settings

citelab/JAMScript-OTA

 
 

Repository files navigation

Setting up

Create .env file

Make a copy of .env.example and rename it to .env.

  • REDIS_MASTERPWD is the master password for the redis CLI. Through docker-compose.yml, this gets forwarded to the environment variable REDISCLI_AUTH, which will automatically be used when starting redis-cli.
  • PORTAL_HTTPS_PKEY_PATH and PORTAL_HTTPS_CERT_PATH: see here
  • PORTAL_ADMIN_USERNAME, PORTAL_ADMIN_EMAIL, and PORTAL_ADMIN_PASSWORD are the credentials and account information for an administrator user on the portal.

Generate key pairs

The control center will need to have two sets of key pairs, one for the HTTPS web portal (optional), and one for the registration server (required). You can generate these key pairs using OpenSSL via the script provided. Navigate to your certificate directory (one has been created at ota-portal/bin/pem). Run the script with the command below. For the HTTPS pair, in the options, you can leave everything as default, but you must enter a hostname for the Common Name. For example, you can use localhost if no custom URL is set, or if you map a different URL like ota.jamscript.com to localhost on your machine (i.e. in your hosts file), you should enter that URL.

./gen_keys.sh

Then update the .env file to point to your key and certificate files in the fields PORTAL_HTTPS_PKEY_PATH and PORTAL_HTTPS_CERT_PATH for the portal, and RSA_PKEY_PATH and RSA_CERT_PATH for the registration server. The paths are relative to ota-portal/bin.

Running

One-time startup command

cd path/to/repository/JAMScript-OTA

# build the Docker image
docker build -t ijam-cc .

# build and start the containers
docker compose up --build

Subsequent startups

cd path/to/repository/JAMScript-OTA
docker compose up

Running this command will startup the Docker container and only the Redis database.

Starting the web portal

docker exec -it ijam-cc /bin/bash

# inside the container
cd JAMOTA/ota-portal/bin
./www

Running these commands starts the web server to be accessible in your browser. The configuration from the .env file determines the listening port (PORTAL_PORT), the protocol (PORTAL_PROTOCOL), and the HTTPS certificate and key files (PORTAL_HTTPS_CERT_PATH and PORTAL_HTTPS_PKEY_PATH), if using HTTPS.

Starting the other servers

docker exec -it ijam-cc /bin/bash

# inside the container
cd JAMOTA/ota-portal/bin
./cert_server&
./reg_server&
./state_server

Running these commands will start the certificate and registration servers in the background, and the state server in the foreground. You can run this configuration to have all three running in one container bash session. If you want to view the three outputs separately, you must open three different bash sessions (run docker exec ... thrice) then you can start the servers in the foreground in each separate session.

Accessing the Redis client

# open a terminal in the Redis container
docker exec -it ijam-cc /bin/bash

# inside the container
redis-cli

# inside the Redis CLI, connect to docker redis, replace with environment variables set in .env [here](#create-env-file)
connect ijam-redis ${REDIS_PORT}

# inside the Redis CLI, replace with environment variables set in .env [here](#create-env-file)
auth ${REDIS_USER} ${REDIS_PASSWORD}

About

Over-the-air update portal for JAMScript-connected devices

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 56.6%
  • C 23.7%
  • Shell 12.8%
  • Pug 5.6%
  • CSS 0.6%
  • Dockerfile 0.5%
  • Makefile 0.2%