1.0.3 • Published 2 years ago

netplan-js v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Netplan-JS - read and update netplan configurations

This is Node JS library for reading Netplan configurations and updating config files from NodeJS applications.

Installation

npm install netplan-js

Usage

Reading Netplan configurations:

const Netplan = require('netplan-js');

const netplan = new Netplan();
netplan.loadConfigs().then(() => {
  const config = netplan.getInterface('ethernets', 'ens33');
  console.log('Current config:', JSON.stringify(config));
});

Updating Netplan configurations:

const Netplan = require('netplan-js');

const netplan = new Netplan();
netplan.loadConfigs().then(() => {
  netplan.setInterface('ethernets', 'ens33', {
    dhcp4: false,
    addresses: ['192.168.1.105/24'],
    nameservers: { addresses: ['192.168.1.1'] },
    gateway4: '192.168.1.1',
  });
  netplan.writeConfigs().then(() => {
    netplan.apply()
      .then(() => console.log('Success'))
      .catch((err) => console.error(err.message));
  });
});
1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago