Git Product home page Git Product logo

air-link's Introduction

Air Link

Air Link is a standalone service to manage remote access to an edge device and to install user apps.

PyPI PyPI downloads GitHub license GitHub commit activity GitHub issues GitHub forks GitHub stars

Prerequisites

The edge device needs to run a Linux-based OS and have Python >=3.8 installed.

Note

To install a recent Python version like 3.11, you can use pyenv:

# install dependencies
sudo apt update
sudo apt install build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

# install pyenv
curl https://pyenv.run | bash

# add pyenv to login shell .profile, maybe also .bashrc, .zshrc, etc. depending on your shell
# see https://github.com/pyenv/pyenv?tab=readme-ov-file#set-up-your-shell-environment-for-pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile
echo 'eval "$(pyenv init -)"' >> ~/.profile

# source the bashrc
source ~/.bashrc

# install Python 3.11
pyenv install 3.11
pyenv global 3.11

Setup

1. Install the Air Link app on an edge device

Air link can be installed using pip. To run the app automatically after a reboot, you can install it as a system service using its install command.

pip install air-link
air-link install

The app is accessible on port 8080 and can be reached via the IP address of the edge device.

Note

To make the app accessible over an SSH tunnel, you can log into the edge device with the following command:

ssh -L 8888:localhost:8080 <target device>

The app will then be reachable at localhost:8888 on the developer machine.

Tip

To display the logs of the Air Link service, use the following command:

journalctl -u air_link -f

The -f flag will follow the logs in real-time.

2. Access via NiceGUI On Air

To make the Air Link app accessible via NiceGUI On Air, follow these three steps:

  1. Register a new device with a fixed region at https://on-air.nicegui.io.
  2. Enter the token in the top right corner of the Air Link web interface.
  3. Restart the Air Link service using the button next to the token.

Air Link will be reachable through the URL provided by NiceGUI On Air, for example https://europe.on-air.io/zauberzeug/rodja-air-link. We strongly suggest to set a fixed region for the device at https://on-air.nicegui.io to keep the URL stable.

3. Manage SSH keys (optional)

To allow SSH access without a password, you can add SSH keys to the edge device using the Air Link web interface. Use the key icon in the top right corner to open the SSH key management.

Usage

Install User Apps

You can install user apps via the Air Link web interface. The web interface lists all available packages and provides a button to upload additional ZIP files. The install button runs the install.sh script from the ZIP file and outputs the process in the web interface.

SSH Login via NiceGUI On Air

Establish an SSH connection to the machine where Air Link is running via proxy jump over the On Air server:

ssh -J <your_organization>/<your_device_name>@<your_region>.on-air.io <username_on_device>@localhost

Explanation: The combination of organization and device name before the @<region>.on-air.io tells the On Air server where to route the SSH login. The last bit tells SSH with which user you want to log into the edge device (which is localhost after Air Link received the tunneled data from the On Air server).

Tip

You can also put the proxy jump into your ~/.ssh/config to establish a connection with the bash command ssh my-device:

Host my-device
    User <your_username>
    HostName localhost
    ProxyJump <your_organization>/<your_device_name>@<your_region>.on-air.io

It may also be beneficial to add the following configuration to the host entry:

    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null
    ServerAliveInterval 30
    ForwardAgent yes
    SetEnv GIT_AUTHOR_NAME="Your Name" EMAIL="[email protected]"

Development

Design Decisions

  • Assume an edge device with a Linux-based OS and Python >=3.8.
  • Run side-by-side with user apps, because deploying/breaking a user app should not affect remote access.
  • Provide SSH access to the edge device through the websocket tunnel from NiceGUI On Air.

Testing Locally

  1. Start On Air server with ./main.py.
  2. Start Air Link locally with ./main.py (and let it point to the local On Air server "localhost").
  3. Establish an SSH connection to your local machine via proxy jump over the On Air server: ssh -J zauberzeug/rodja@localhost:2222 rodja@localhost.

Formatting

We use pre-commit to make sure the coding style is enforced. You first need to install pre-commit and the corresponding git commit hooks by running the following commands:

python3 -m pip install pre-commit
pre-commit install

After that you can make sure your code satisfies the coding style by running the following command:

pre-commit run --all-files

These checks will also run automatically before every commit.

Deployment

To deploy a new version of Air Link, add a new tag with the format vX.Y.Z and push it to the repository. The CI pipeline will then build the new version, upload it to PyPI, and create a new draft release on GitHub.

air-link's People

Contributors

rodja avatar falkoschindler avatar codingpaula avatar github-actions[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar Olaf Sabatschus avatar  avatar Zauberzeug Developers avatar

air-link's Issues

Allow pruning Docker images and containers

In order to avoid accumulating images and containers, we should provide a button for pruning the system.

Maybe it's also possible to show a list of dangling containers, images etc. ChatGPT proposed the following script:

#!/bin/bash

echo "### Unused Images ###"
docker images --filter "dangling=true"

echo "### Stopped Containers ###"
docker ps --filter "status=exited" --filter "status=created"

echo "### Unused Volumes ###"
docker volume ls --filter "dangling=true"

echo "### Unused Networks ###"
docker network ls | grep "bridge"

There's also an official --dry-run option in the making: moby/moby#30623 (a bit stale though).

On Jetson Nano (18.04, Beaver): Starlette/Jinja2 produces SystemError: no locals when loading 'str'

Using Jinja2Templates in NiceGUI fails with the error

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/zauberzeug/.local/lib/python3.8/site-packages/starlette/templating.py", line 110, in __init__
    self._setup_env_defaults(self.env)
  File "/home/zauberzeug/.local/lib/python3.8/site-packages/starlette/templating.py", line 127, in _setup_env_defaults
    name: str,
SystemError: no locals when loading 'str'

Which can be reproduced by calling

python3.8 -c "from starlette.templating import Jinja2Templates; Jinja2Templates('.')"

The core error seems to be type annotation parsing of Python 3.8.0. The error is gone in 3.8.2 which can be verified by running the specific Python versions in a docker container.

Show free disk space

For installing packages via Air Link, we should display the current disk usage.
If there is less than, e.g., 10% free space, we should show a warning.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.