35 lines
1.3 KiB
JavaScript
35 lines
1.3 KiB
JavaScript
// Automated OS & Provisioning Config Generator Client
|
|
async function downloadZfsProvisioningScript() {
|
|
const hostname = document.getElementById('cfg-hostname')?.value || 'nas-core';
|
|
const domain = document.getElementById('cfg-domain')?.value || 'atyg.org';
|
|
const raid = document.getElementById('cfg-raid')?.value || 'raidz2';
|
|
const bays = document.getElementById('cfg-bays')?.value || '8';
|
|
const serial = document.getElementById('cfg-serial')?.value || 'NAS-6U-2026-0001';
|
|
|
|
try {
|
|
const res = await fetch('/api/config/zfs-script', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({
|
|
hostname,
|
|
domain,
|
|
raid_level: raid,
|
|
drive_bays: parseInt(bays),
|
|
serial_number: serial
|
|
})
|
|
});
|
|
|
|
const scriptText = await res.text();
|
|
const blob = new Blob([scriptText], { type: 'text/x-shellscript' });
|
|
const url = window.URL.createObjectURL(blob);
|
|
const a = document.createElement('a');
|
|
a.setAttribute('href', url);
|
|
a.setAttribute('download', `${hostname}-provision.sh`);
|
|
a.click();
|
|
} catch (err) {
|
|
console.error("Config generation error:", err);
|
|
}
|
|
}
|
|
|
|
window.downloadZfsProvisioningScript = downloadZfsProvisioningScript;
|