You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
880 B

3 months ago
'use client'
import fs from 'fs';
import { exec } from 'child_process';
const dhcpConfigPath = '/etc/dhcp/dhcpd.conf'; // Path to the DHCP server configuration file
export function readDhcpConfig() {
try {
const config = fs.readFileSync(dhcpConfigPath, 'utf8');
return config;
} catch (error) {
throw new Error('Error reading DHCP configuration file: ' + error.message);
}
}
export function writeDhcpConfig(newConfig) {
try {
fs.writeFileSync(dhcpConfigPath, newConfig, 'utf8');
} catch (error) {
throw new Error('Error writing to DHCP configuration file: ' + error.message);
}
}
export function restartDhcpServer() {
exec('sudo systemctl restart isc-dhcp-server', (error, stdout, stderr) => {
if (error) {
throw new Error(`Error restarting DHCP server: ${stderr}`);
}
});
}

Powered by TurnKey Linux.