Presets
Provisions
Below are the Provision Scripts:
ONTs
// Auditoria das ONTs\\
const now = Date.now();
const provisionado = declare("Tags.Provisionado", { value: 1 })?.value?.[0];
const bootstrap = args[0];
log(`provisionado: ${provisionado} || bootstrap: ${bootstrap}`);
if (provisionado && !bootstrap) {
bindLANToWAN();
log("CPE está (supostamente) configurada, retornando...");
return;
}
const serial = declare('DeviceID.SerialNumber', { value: 1 }).value[0];
const productClass = declare('DeviceID.ProductClass', { value: 1 }).value[0];
const pppoe = ext("cpe-config", "GetPPPoE", serial);
declareBasicDevices();
log("[1]");
refreshWlan();
log("[2]");
checkWAN();
log("[3]");
setupAdditionalConfigs();
updateTags();
log('>> Reiniciando CPE para finalizar configuração...');
declare("Reboot", null, { value: now });
function updateTags() {
declare("Tags.Provisionado", null, { value: true });
}
function refreshWlan() {
log('>> Refreshing WLAN...');
declareWLANConfiguration(1);
declareWLANConfiguration(5);
}
function checkWAN() {
declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*", { value: now });
const wanNames = [1, 2, 3].map(getWANName);
if (!wanNames[0] && !wanNames[1] && !wanNames[2]) {
setupBaseWanPppConnection(true, 1);
} else {
for (let i = 0; i < wanNames.length; i++) {
if (wanNames[i] && wanNames[i].includes("internet")) {
setupBaseWanPppConnection(false, i + 1);
break;
}
}
}
}
function getWANName(connectionDeviceNumber) {
const name = declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${connectionDeviceNumber}.WANPPPConnection.1.Name`, { value: now })?.value?.[0];
return name ? name.toLowerCase() : null;
}
function setupBaseWanPppConnection(createWan, WANConnectionDevicePATH) {
if (createWan) {
if (productClass.includes('EN8255X6s-8X')) {
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.*`, null, { path: 1 });
} else {
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*`, null, { path: 1 });
}
}
declareWanPppConnection(WANConnectionDevicePATH, pppoe.username, pppoe.password);
huaweiOntX6AdditionalConfigs(WANConnectionDevicePATH);
}
function declareWanPppConnection(WANConnectionDevicePATH, username, password) {
log('>> Atualizando valores WANPPP Base...');
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.Enable`, { value: now }, { value: true });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.MaxMTUSize`, { value: now }, { value: "1492" });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.MaxMRUSize`, { value: now }, { value: "1492" });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.CurrentMRUSize`, { value: now }, { value: "1492" });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.DNSEnabled`, { value: now }, { value: true });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.NATEnabled`, { value: now }, { value: true });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.DNSServers`, { value: now });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.Username`, { value: now }, { value: username });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.Password`, { value: now }, { value: password });
}
function huaweiOntX6AdditionalConfigs(WANConnectionDevicePATH) {
declare(`InternetGatewayDevice.WANDevice.1.WANCommonInterfaceConfig.EnabledForInternet`, { value: now }, { value: true });
declare(`InternetGatewayDevice.WANDevice.1.WANCommonInterfaceConfig.WANAccessType`, { value: now }, { value: "Ethernet" });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.X_HW_VLAN`, { value: now }, { value: 10 });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.X_HW_NatType`, { value: now }, { value: 0 });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.X_HW_IPv6Enable`, { value: now }, { value: true });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.X_HW_IPv6.IPv6Address.[]`, { value: now }, { path: 0 });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.X_HW_IPv6.IPv6Prefix.[]`, { value: now }, { path: 0 });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.X_HW_IPv6.IPv6Address.[]`, { value: now }, { path: 1 });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.X_HW_IPv6.IPv6Address.1.Origin`, { value: now }, { value: "AutoConfigured" });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.X_HW_IPv6.IPv6Prefix.[]`, { value: now }, { path: 1 });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.X_HW_IPv6.IPv6Prefix.1.Origin`, { value: now }, { value: "PrefixDelegation" });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.X_HW_LANBIND.*`, { value: now });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.X_HW_LANBIND.SSID1Enable`, { value: now }, { value: 1 });
declare(`InternetGatewayDevice.WANDevice.1.WANConnectionDevice.${WANConnectionDevicePATH}.WANPPPConnection.1.X_HW_LANBIND.SSID5Enable`, { value: now }, { value: 1 });
}
function setupAdditionalConfigs() {
log('>> Finalizando configurações adicionais...');
declare("InternetGatewayDevice.X_HW_MainUPnP.Enable", { value: now }, { value: true });
declare("InternetGatewayDevice.X_HW_SlvUPnP.Enable", { value: now }, { value: true });
declare("InternetGatewayDevice.X_HW_Security.*", { value: now });
declare("InternetGatewayDevice.X_HW_Security.*.*", { value: now });
declare("InternetGatewayDevice.X_HW_Security.AclServices.AccessControl", { value: now });
declare("InternetGatewayDevice.X_HW_Security.AclServices.AccessControl.*", { value: now });
declare("InternetGatewayDevice.X_HW_Security.AclServices.AccessControl.AccessControlListEnable", { value: now }, { value: true });
declare("InternetGatewayDevice.X_HW_Security.AclServices.AccessControl.AccessControlListNumberOfEntries", { value: now }, { value: 1 });
declare("InternetGatewayDevice.X_HW_Security.AclServices.AccessControl.List", { value: now });
declare("InternetGatewayDevice.X_HW_Security.AclServices.AccessControl.List.*", null, { path: 1 });
declare("InternetGatewayDevice.X_HW_Security.AclServices.AccessControl.List.*.*", { value: now });
declare("InternetGatewayDevice.X_HW_Security.AclServices.AccessControl.List.*.Mode", { value: now }, { value: 0 });
declare("InternetGatewayDevice.X_HW_Security.AclServices.AccessControl.List.*.Priority", { value: now }, { value: 1 });
declare("InternetGatewayDevice.X_HW_Security.AclServices.HTTPLanEnable", { value: now }, { value: true });
declare("InternetGatewayDevice.X_HW_Security.AclServices.HTTPSLanEnable", { value: now }, { value: true });
declare("InternetGatewayDevice.X_HW_Security.AclServices.SamBaLanEnable", { value: now }, { value: true });
declare("InternetGatewayDevice.X_HW_Security.AclServices.WanAccess", { value: now });
declare("InternetGatewayDevice.X_HW_Security.AclServices.WanAccess.*", null, { path: 1 });
declare("InternetGatewayDevice.X_HW_Security.AclServices.WanAccess.*", { value: now });
declare("InternetGatewayDevice.X_HW_Security.AclServices.WanAccess.*.*", { value: now });
declare("InternetGatewayDevice.X_HW_Security.AclServices.WanAccess.1.Enable", { value: now }, { value: 1 });
declare("InternetGatewayDevice.X_HW_Security.AclServices.AccessControl.List.*.ServicePort", { value: now }, { value: "HTTP,ICMP" });
declare("InternetGatewayDevice.X_HW_Security.AclServices.AccessControl.List.*.SrcIp", { value: now }, { value: "XXXX" });
declare("InternetGatewayDevice.X_HW_Security.AclServices.AccessControl.List.*.SrcPortName", { value: now }, { value: "ALL" });
declare("InternetGatewayDevice.X_HW_Security.AclServices.AccessControl.List.*.SrcPortType", { value: now }, { value: 2 });
declare("InternetGatewayDevice.X_HW_AppRemoteManage.CurrentMgtURL", { value: now }, { value: "XXXX" });
declare("InternetGatewayDevice.X_HW_AppRemoteManage.CurrentPort", { value: now }, { value: "XXXX" });
declare("InternetGatewayDevice.X_HW_AppRemoteManage.PhoneAppURL", { value: now }, { value: "XXXX" });
declare("InternetGatewayDevice.LANDevice.*", { value: now });
//declare("InternetGatewayDevice.LANDevice.1.LANEthernetInterfaceConfig.*", null, { path: 4 });
declare("InternetGatewayDevice.LANDevice.1.LANEthernetInterfaceConfig.*.X_HW_L3Enable", { value: now }, { value: true });
declare("InternetGatewayDevice.Time.*", { value: now });
declare("InternetGatewayDevice.Time.Enable", { value: now }, { value: true });
declare("InternetGatewayDevice.Time.LocalTimeZone", { value: now }, { value: "-03:00" });
declare("InternetGatewayDevice.Time.LocalTimeZoneName", { value: now }, { value: "Brasilia" });
declare("InternetGatewayDevice.Time.NTPServer1", { value: now }, { value: "clock.fmt.he.net" });
declare("InternetGatewayDevice.Time.NTPServer2", { value: now }, { value: "time.windows.com" });
declare("InternetGatewayDevice.Time.X_HW_SynInterval", { value: now }, { value: "3600" });
declare("InternetGatewayDevice.X_HW_Security.Firewall.Enable", { value: now }, { value: true });
const ont = ext("cpe-config", "GetONTPassword", pppoe.username);
declare("InternetGatewayDevice.UserInterface.X_HW_WebUserInfo.*", { value: now });
declare("InternetGatewayDevice.UserInterface.X_HW_WebUserInfo.*.*", { value: now });
declare("InternetGatewayDevice.UserInterface.X_HW_WebUserInfo.*.Enable", { value: now }, { value: true });
declare("InternetGatewayDevice.UserInterface.X_HW_WebUserInfo.2.Password", { value: 1 }, { value: ont.password });
}
function declareBasicDevices() {
declare("InternetGatewayDevice", { value: now });
declare("InternetGatewayDevice.*", { value: now });
declare("InternetGatewayDevice.WANDevice.*", { value: now });
declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*", { value: now });
}
function bindLANToWAN() {
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.*.WANPPPConnection.1.X_HW_LANBIND.Lan1Enable", { value: now }, { value: 1 });
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.*.WANPPPConnection.1.X_HW_LANBIND.Lan2Enable", { value: now }, { value: 1 });
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.*.WANPPPConnection.1.X_HW_LANBIND.Lan3Enable", { value: now }, { value: 1 });
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.*.WANPPPConnection.1.X_HW_LANBIND.Lan4Enable", { value: now }, { value: 1 });
//declare("InternetGatewayDevice.Layer3Forwarding.X_HW_policy_route.2.PhyPortName", { value: now }, { value: "LAN1,LAN2,LAN3,LAN4,SSID1,SSID5" });
declare("InternetGatewayDevice.X_HW_Security.AclServices.AccessControl.List.*.ServicePort", { value: now }, { value: "HTTP,ICMP" });
}
function declareWLANConfiguration(configNumber) {
declare(`InternetGatewayDevice.LANDevice.1.WLANConfiguration.${configNumber}.*`, { value: now });
declare(`InternetGatewayDevice.LANDevice.1.WLANConfiguration.${configNumber}.Enable`, { value: now }, { value: true });
declare(`InternetGatewayDevice.LANDevice.1.WLANConfiguration.${configNumber}.X_HW_AttachConf.X_HW_AirtimeFairness`, { value: now }, { value: true });
}
Routers
// Configs Checker Routers only \\
const now = Date.now();
let OK = declare("Tags.Provisionado", { value: 1 });
if (OK.value !== undefined) {
log("CPE está (supostamente) configurada, retornando...");
return;
}
log("[1]");
refreshWlan();
log("[2]");
setupBaseWanPppConnection();
log("[3]");
setupAdditionalConfigs();
//Refresh the mac and external ip
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.*.WANPPPConnection.*.MACAddress", { value: now });
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.*.WANPPPConnection.*.IpAddress", { value: now });
updateTags();
log('>> Reiniciando CPE para finalizar configuração...');
declare("Reboot", null, { value: now });
function updateTags() {
log('Auditoria realizada! Retornando Script...');
declare("Tags.Provisionado", null, { value: true });
}
function refreshWlan() {
log('>> Refreshing WLAN...');
declare("InternetGatewayDevice.LANDevice.*.WLANConfiguration.*", { value: now });
declare("InternetGatewayDevice.LANDevice.*.WLANConfiguration.*.*", { value: now });
declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.*.SSID", { value: now });
}
function setupBaseWanPppConnection() {
//Garantir que temos a instância WanPPPConnection
log('>> Criando instância WANPPPConnection...');
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*", null, { path: 1 });
//Common WanPPPConnection
log('>> Atualizando valores WANPPP Base...');
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Enable", { value: now }, { value: true });
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.MaxMTUSize", { value: now }, { value: "1492" })
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.MaxMRUSize", { value: now }, { value: "1492" });
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.CurrentMRUSize", { value: now }, { value: "1492" });
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.DNSEnabled", { value: now }, { value: true });
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.NATEnabled", { value: now }, { value: true });
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.DNSServers", { value: now });
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Username", { value: now });
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Password", { value: now });
declare("InternetGatewayDevice.WANDevice.1.WANCommonInterfaceConfig.EnabledForInternet", { value: now }, { value: true });
//Huawei Ax2/Ax2S
declare("InternetGatewayDevice.WANDevice.1.WANCommonInterfaceConfig.WANAccessType", { value: now }, { value: "Ethernet" });
//Tenda Tx2ProV1.0
declare("InternetGatewayDevice.WANDevice.1.WANCommonInterfaceConfig.EnabledUpnp", {value: now}, {value: true});
}
function setupAdditionalConfigs() {
log('>> Finalizando configurações adicionais...');
//Tenda Tx2ProV1.0
declare("InternetGatewayDevice.UserInterface.RemoteAccess.Enable", { value: now }, { value: true });
declare("InternetGatewayDevice.UserInterface.RemoteAccess.IP", { value: now }, { value: "XXXX" });
declare("InternetGatewayDevice.UserInterface.RemoteAccess.Port", { value: now }, { value: "XXXX" });
declare("InternetGatewayDevice.UserInterface.RemoteAccess.Protocol", { value: now }, { value: "HTTP" })
//Huawei Ax2/Ax2S
declare("InternetGatewayDevice.Services.X_HUAWEI_WANRemoteAccess.Enable", { value: now }, { value: true });
declare("InternetGatewayDevice.Services.X_HUAWEI_WANRemoteAccess.IPAddress1", { vale: now }, { value: "XXXX" });
declare("InternetGatewayDevice.Services.X_HUAWEI_WANRemoteAccess.Port", { value: now }, { value: "XXXX" });
}