Skip to main content
WideWired
Docs

Plugins

Use plugin configs to install, monitor and uninstall third-party software on your devices. Write scripts and when they run yourself, or import a template and edit it directly.

Before you start

Plugins run scripts on devices you have already joined to your network. A device can have several plugin configs. One config is one complete job, for example running a tunnel on a gateway or keeping a proxy service alive, and it can be saved, disabled and removed as a whole.

A config follows the software's lifecycle in sections: Variables, Install, Monitor, Other and Uninstall. Each section is a script and the times it runs; there can be several monitors and other scripts.

Third-party open-source software can import a template: a ready-made set of scripts and execution times whose content is fully visible, and whose scripts you edit directly after importing it. You can also start from an empty config and write your own.

Common uses:

Plugin scripts run directly on your devices. You are responsible for the software and system configuration they change, and for rollback.

What each section does

Section Per config How the result is used
Variables 0 or 1 Never runs on its own; every script in the config loads it first
Install 0 or 1 If it fails the config is marked install failed and no other script in the config runs
Monitor Several The exit code decides whether the config is healthy; the set number of failures in a row raises an alert
Other Several Only recorded
Uninstall 0 or 1 Runs best effort on removal if this device started the install script, including a trial run

Each script has its own interpreter, which follows the device's system: PowerShell on Windows; sh or bash on Linux (including OpenWrt). When the variables script uses sh, other scripts can use sh or bash; when it uses bash, every other script must use bash.

Execution times

Each execution time has a trigger, an interval and a timeout. There are two kinds of trigger: a moment runs the script once, a period runs it on an interval.

Trigger Runs Used by
When the config takes effect Once Install (fixed; only the timeout can change)
After service starts Once Other
Network connected Once Other
Network disconnected for 30 seconds Once Other
Before service stops Once Other
While the service runs Repeats on an interval Monitor, Other
While the network is connected Repeats on an interval Monitor, Other
When the config is removed Once Uninstall (fixed; only the timeout can change)

Create a config

Go to Configuration → Plugins. The page lists every config of the network with its device, status and last check. Before you create a config the page is empty; it does not list your devices in advance.

New config is the only action at the top right of the page. It opens no dialog: the config is created right away and its editing page opens. It is named "Config NNNN", disabled, and has no device yet. Choose the device, write scripts or import a template on the editing page.

Editing page

Every config has its own editing page with an address you can bookmark or share. Open it from the config's name or Edit in the list; the breadcrumb takes you back.

The page runs top to bottom: Device, Variables, Install, Monitor, Other, Uninstall.

Enable, disable and save

A config that has never been enabled: each Save changes stores that change without a confirmation. It may be incomplete. Select Run now to send a script to the device for a trial run. When it is ready, select Enable config: the whole config is checked, including its device, and the page scrolls to the first section with a problem, marks it red and states the reason. When nothing is wrong, the confirmation states which device runs what after enabling. After enabling, the device runs the current install revision when it receives the config, unless it already attempted that revision during a trial. A successful trial needs no repeat. If that trial failed, correct the script or use Run now to retry. If the device ran the install script, including a trial run, deleting the config attempts to run its uninstall script.

A config that has been enabled: after editing a section, select Save changes; the confirmation lists the scripts and execution times you changed and states what the device runs right away. Deleting a script asks the same way. While enabled, changing the variables script and the install script together reinstalls once; changing only monitors, other scripts or execution times does not reinstall. Disable config and Enable config ask for confirmation too. Leaving the page with unsaved changes asks for confirmation.

If someone else changed the config while you were editing, saving never overwrites their change: the page tells you, and you choose to overwrite with this page (save this change on top of the latest version) or load the latest (discard this change).

A device can have up to 32 configs, and a config up to 16 scripts and 32 execution times. A script can be up to 256 KiB, and the combined JSON payload delivered to a device can be up to 512 KiB, including fields, schedules and escaping.

Use a template

A template is a ready-made set of scripts and execution times that installs and runs a third-party open-source program. On a config's editing page, select Import template in the header and pick one in the dialog:

Templates only install the current version of open-source software from the distribution repository or the official upstream source, and never pin a version. The install script checks whether the distribution is supported and fails with a clear message when it is not. When a required variable is not set, the install script fails at its start and lists the missing variables.

Importing is a one-time copy: when the template gets a newer version later, configs that imported it do not change and are not notified. To use the new version, import it into the config again (this replaces all of its scripts and execution times, so note the values in your variables script first).

strongSwan site access

This template connects sites that have an IPsec firewall or router but cannot run the client. Use it on a Linux device that has joined the network. One config can connect several sites: each site is a peer in the Variables script, with its address, identity, networks and pre-shared key.

Variables

Variables are set by a script. Before each run, the client loads the variables script and then the target script in the same interpreter process, so assignments in the variables script are visible to the target script. It runs again every time and should only assign values and do light computation. When the variables script fails, the run is recorded as failed and marked as a variables script error.

Variables set by a script are gone when its process ends. To keep a value for later runs, append a line NAME=value to the variables file whose path is given by WWNET_CLIENT_PLUGIN_ENV_FILE:

Every run also receives these built-in variables:

Variable Meaning
WWNET_CLIENT_PLUGIN_EXECUTION_ID ID of this run
WWNET_CLIENT_PLUGIN_CONFIG_ID Config ID
WWNET_CLIENT_PLUGIN_SCRIPT_TYPE Script type
WWNET_CLIENT_PLUGIN_STAGE Trigger
WWNET_CLIENT_PLUGIN_SCRIPT_REVISION, WWNET_CLIENT_PLUGIN_SCRIPT_SHA256 Script revision and content digest
WWNET_CLIENT_PLUGIN_OVERLAY_IP The device's virtual network address
WWNET_CLIENT_PLUGIN_INTERFACE Virtual interface name
WWNET_CLIENT_PLUGIN_NETWORK_CIDR Virtual network range

Install

Status and alerts

A config is disabled, pending, installing, healthy, install failed or monitor failing. The list also shows when it was last checked.

Disable and uninstall

Run long-lived components

Scripts should finish one operation and exit. For a third-party component that must keep running, have the script install, start or stop it through the operating system's service manager: systemd on Linux, procd on OpenWrt, and the Windows service manager on Windows.

Do not use setsid or similar techniques to detach a child process from the run. WideWired would be unable to clean it up when the script times out, is canceled or the service exits.

View execution results

Select Executions on a config's row or under ⋯ on its editing page, to see that config's runs in reverse chronological order. Filter by type and status, and page through the list. Open a record to see its status, script revision, trigger reason, start and end time, exit code, stdout and stderr. Trial runs also have execution records.

Security boundaries

Quick troubleshooting

Symptom Checks and actions
The device has no plugins entry Upgrade the client on the device; macOS and mobile devices do not run scripts
A config stays pending An offline device runs it once it is back online; confirm the config is enabled
Install failed Open the config's most recent install record and read the end of the output, then fix and save the script or select Run now in the install script's ⋯
A monitor or other script does not run None of them runs until the current install succeeds; confirm its execution time actually happened
A run is marked as a variables script error Keep the variables script to assignments and light computation; check its syntax and exit status
Monitor failing Check the monitor's recent failure records; the first success afterwards restores the config
A record shows canceled The period ended, a new moment began, or the background service started exiting; installs and uninstalls are not affected by trigger changes
Leftovers after deleting a config Uninstalling is best effort; check the device for leftovers and clean up manually if needed
All site routes fail after removing a strongSwan peer or deleting the config Delete the site route before removing the peer or the config; deleting the leftover site route restores the others
The install of a config from a template fails because required variables are not set Set the variables listed in the output in the Variables script and save