Configuration of headless devices by flash disk (or any mountable disk) with Network-Manager support.
This library allows UI-less devices (usually a Raspberry Pi, Orange Pi etc...) to be easily configured just by inserting USB flash disk or SD card to port. The library watches device mounts and when it finds the desired configuration file, a user code is called.
To give user a feedback about operation result, the library either:
- renames configuration file by inserting
done-prefix if operation succeeded.
- creates new file with
failed-prefix if the user callback thrown an exception. The file contains error message of that exception.
The generic configuration API is very simple:
const flashConfig = ;flashConfigstart;
Because most common task is to configure WiFi connection, there is a built-in support to configure Network-Manager.
const flashConfig = ;const networkManager = ;flashConfigstart;
Check example.js for complete code.
format property of watch parameter. This is a reference to converter function, which takes file content as string and returns a js value. There are two built-in converters:
json which is just
text which consumes key-value map with # comments, e.g.:
# this is an example of WiFi configuration ssid MySweetHome password abcd1234 # ip and gw is optional, if missing we use DHCP ip 10.1.0.15 gw 10.1.0.2
The library uses
debug module for logging. To get full log, set environment variable
Command line usage
You can use the library directly from command line to configure WiFi: