@clysema/dhcpcd

[![npm (scoped)](https://img.shields.io/npm/v/@clysema/dhcpcd.svg)](https://www.npmjs.com/package/@clysema/dhcpcd) [![npm bundle size (minified)](https://img.shields.io/bundlephobia/min/@clysema/dhcpcd.svg)](https://www.npmjs.com/package/@clysema/dhcpcd)

Usage no npm install needed!

<script type="module">
  import clysemaDhcpcd from 'https://cdn.skypack.dev/@clysema/dhcpcd';
</script>

README

@clysema/dhcpcd

npm (scoped) npm bundle size (minified)

Updates /etc/dhcpcd.conf and reboots the device.

Usage

This module is intended to be used with the @clysema/http module in order to enable a /dhcpcd post endpoint.

npm install @clysema/dhcpcd @clysema/http

Use an http module config/http.json like this:

"host": "0.0.0.0",
"root": "/home/pi/app/www",
"post": ["dhcpcd"]
}

Create an empty config file for the dhcpcd module (no config is needed but the file must exist).

touch config/dhcpcd.json

Then, somewere in the app loop:

try { await app.modules.dhcpcd(app); }
catch (e) { ... }

Test

Using auth (USERNAME= PASSWORD= npm start)

curl -d \
'{interface: "eth0", dhcp: true, ip_address: "", routers: "", domain_name_servers: ""}' \
-u <username>:<password> \
-H "Content-Type: application/json" \
-X POST http://<device_ip>:4000/dhcpcd

GUI

You can place a production build of the dhcpcd-ui package in the root configured folder (/home/pi/app/www in the above example) to be served by the app.