Skip to main content

Attendedsysupgrade Server for OpenWrt (GSoC 2017)

codecov Code style: black PyPi

This project simplifies the sysupgrade process for upgrading the firmware of devices running OpenWrt or distributions based on it. These tools offer an easy way to reflash the router with a new firmware version (including all packages) without the need to use opkg.

It's called Attended SysUpgrade (ASU) because the upgrade process is not started automatically, but is initiated by a user who waits until it's done.

ASU is based on an API (described below) to request custom firmware images with any selection of packages pre-installed. This avoids the need to set up a build environment, and makes it possible to create a custom firmware image even using a mobile device.

Clients of the Sysupgrade Server

OpenWrt Firmware Selector

Simple web interface using vanilla JavaScript currently developed by @mwarning. It offers a device search based on model names and show links either to official images or requests images via the asu API. Please join in the development at GitLab repository

ofs

LuCI app

The package luci-app-attendedsysupgrade offers a simple tool under System > Attended Sysupgrade. It requests a new firmware image that includes the current set of packages, waits until it's built and flashes it. If "Keep Configuration" is checked in the GUI, the device upgrades to the new firmware without any need to re-enter any configuration or re-install any packages.

luci

CLI

The auc package performs the same process as the luci-app-attendedsysupgrade from SSH/the command line.

auc

Server

The server listens for image requests and, if valid, automatically generates them. It coordinates several OpenWrt ImageBuilders and caches the resulting images in a Redis database. If an image is cached, the server can provide it immediately without rebuilding.

Active server

Run your own server

Redis is required to store image requests:

sudo apt install redis-server tar

Install asu:

pip install asu

Create a config.py. You can use misc/config.py as an example.

Start the server via the following commands:

export FLASK_APP=asu.asu  # set Flask app to asu
flask janitor update      # download upstream profiles/packages - this runs forever
flask run                 # run development server - this runs forever

Start the worker via the following comand:

rq worker                 # this runs forever

Docker

Run the service inside multiple Docker containers. The services include the _ ASU_ server itself, a janitor service which fills the Redis database with known packages and profiles as well as a rqworker which actually builds images.

Currently all services share the same folder and therefore a very "open" access is required. Suggestions on how to improve this setup are welcome.

mkdir -p ./asu-service/public/
chmod -R 777 ./asu-service/
cp ./misc/config.py ./asu-service/
docker-compose up

A webserver should proxy API calls to port 8000 of the server service while the asu/ folder should be file hosted as-is.

Production

It is recommended to run ASU via gunicorn proxied by nginx or caddyserver. Find a possible server configurations in the misc/ folder.

The ASU server will try $PWD/config.py and /etc/asu/config.py to find a configuration. Find an example configuration in the misc/ folder.

pip install gunicorn
gunicorn "asu.asu:create_app()"

Ideally use the tool squid to cache package indexes, which are reloaded every time an image is built. Find a basic configuration in at misc/squid.conf which should be copied to /etc/squid/squid.conf.

If you want to use systemd find the service files asu.service and worker@.service in the misc folder as well.

Development

After cloning this repository, create a Python virtual environment and install the dependencies:

python3 -m venv .direnv
source .direnv/bin/activate
pip install -r requirements.txt
export FLASK_APP=asu.asu  # set Flask app to asu
export FLASK_APP=tests.conftest:mock_app FLASK_DEBUG=1 # run Flask in debug mode with mock data
flask run

API

The API is documented via OpenAPI and can be viewed interactively on the server:

https://sysupgrade.openwrt.org/ui/

Metadata

Release files for asu 0.7.20

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asu 0.7.20
File Size Uploaded
asu-0.7.20.tar.gz 88.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for asu 0.7.20
File Interpreter ABI Platform
asu-0.7.20-py3-none-any.whl Python 3 none any Details

Total release size: 176.5 kB

Release files / asu-0.7.20.tar.gz

Download URL asu-0.7.20.tar.gz
Size 88.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2daddaa790234632670ba09663b2222ccceb592ef589e3f46004713f0091768c
BLAKE2b-256 checksum
How to use checksums
3002b6ff255a200ca4d1acd0580aaaa9b7e6f08a1ff036e00765ffece71c4c07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.11.3 Linux/5.15.0-1035-azure

Release files / asu-0.7.20-py3-none-any.whl

Download URL asu-0.7.20-py3-none-any.whl
Size 88.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eed76f758c1cec082ea8ab727f6897bd4268b19f784bcbeb753be4f30f8d05c0
BLAKE2b-256 checksum
How to use checksums
7d7767c0cabc0f1df377c121fe79c015cb4cb2db27f91b75bb531f2e3c5ddc90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.11.3 Linux/5.15.0-1035-azure

Release history Release notifications | RSS feed

This release

0.7.20 This release

2 release files

0.7.19

2 release files

0.7.18

2 release files

0.7.17

2 release files

0.7.16

2 release files

0.7.15

2 release files

0.7.13

2 release files

0.7.12

2 release files

0.7.11

2 release files

0.7.10

2 release files

0.7.9

2 release files

0.7.8

2 release files

0.7.7

2 release files

0.7.6

2 release files

0.7.5

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.7

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.10

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page