Advertisement
Guest User

SmartRG_515_Managed

a guest
Mar 16th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. log("SmartRG_515_Managed");
  2. const now = Date.now();
  3.  
  4. let serialNumber = declare("DeviceID.SerialNumber", {value: 1});
  5. let productClass = declare("DeviceID.ProductClass", {value: 1});
  6. let oui = declare("DeviceID.OUI", {value: 1});
  7. let args = {serial: serialNumber.value[0], productClass: productClass.value[0], oui: oui.value[0]};
  8.  
  9. //Remove the WANIPConnection instance from the ATM interface
  10. log('Disabling WANIPConnection');
  11. declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.*", null, {path: 0});
  12.  
  13. //Ensure we have a WANPPPConnection instance
  14. log('Creating WANPPPConnection (if necessary)');
  15. declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*", null, {path: 1});
  16.  
  17. let hasPpp = declare("Tags.HasPppCreds", {value: 1});
  18. if (hasPpp.value !== undefined) {
  19.   log('hasPpp, returning');
  20.   return;
  21. }
  22.  
  23. //Set a flag so we don't keep resetting the ppp creds
  24. declare("Tags.HasPppCreds", null, {value: true});
  25.  
  26. //Get the PPPoE creds
  27. let userConfig = ext('cpe-config', 'resetPppoe', JSON.stringify(args));
  28.  
  29. log('Setting up WANPPPConnection');
  30. declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.Name", {value: now}, {value: "Internet"});
  31. declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.ConnectionType", {value: now}, {value: "IP_Routed"});
  32. declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.X_BROADCOM_COM_IfName", {value: now}, {value: "ppp0.1"});
  33. declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.NATEnabled", {value: now}, {value: true});
  34. declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.X_BROADCOM_COM_FirewallEnabled", {value: now}, {value: true});
  35. declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.Enable", {value: now}, {value: true});
  36. declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.PPPoEServiceName", {value: now}, {value: "broadband"});
  37.  
  38. //{value: now} forces GenieACS to update the value of the username/password if the value hasn't been updated before now
  39. log('Setting un: ' + userConfig.username + ', pw: ' + userConfig.password);
  40. declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Username", {value: now}, {value: userConfig.username});
  41. declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Password", {value: now}, {value: userConfig.password});
  42.  
  43.  
  44. log('Setting connection services');
  45. declare("InternetGatewayDevice.Layer3Forwarding.X_BROADCOM_COM_DefaultConnectionServices", {value: now}, {value: "ppp0.1,ppp1.1"});
  46. declare("InternetGatewayDevice.X_BROADCOM_COM_NetworkConfig.DNSIfName", {value: now}, {value: "ppp0.1,ppp1.1"});
  47.  
  48. //Refresh the mac and external ip
  49. declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.1.WANPPPConnection.*.MACAddress", {value: now});
  50.  
  51. //Refresh the WLAN config
  52. log('Refreshing WLAN');
  53. declare("InternetGatewayDevice.LANDevice.*.WLANConfiguration.*.SSID", {value: now});
  54.  
  55. //Refresh the vParams
  56. declare("VirtualParameters.pppoeUsername", {value: now});
  57.  
  58. log('Setting tags');
  59. declare("Tags.Provisioned",null, {value: true});
  60. declare("Tags.HasPppCreds", null, {value: false});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement