tr069prog.sh.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?xml version='1.0' encoding='iso-8859-1'?>
  2. <!doctype html public '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
  3. <html xmlns='http://www.w3c.org/1999/xhtml' lang='en-us'>
  4. <head>
  5. <title>
  6. tr069prog.sh
  7. </title>
  8. <meta http-equiv='content-type' content='text/html;iso-8859-1'/>
  9. <meta name='generator' content='motley-tools 1.9.4 13:40:33 Feb 18 2015'/>
  10. <meta name='author' content='cmaier@cmassoc.net'/>
  11. <meta name='robots' content='noindex,nofollow'/>
  12. <link href='toolkit.css' rel='stylesheet' type='text/css'/>
  13. </head>
  14. <body>
  15. <div class='headerlink'>
  16. [<a href='start.sh.html' title=' start.sh '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='traffic.sh.html' title=' traffic.sh '>NEXT</a>]
  19. </div>
  20. <pre>
  21. #!/bin/sh
  22. # file: tr069prog.sh
  23. # ====================================================================
  24. #
  25. # This script programs a unique TR-069 ACS Username and ACS Password
  26. # into a INT6400 powerline device and updates the Mfg feed file;
  27. # the original MAC, DAK and NMK are preserved; the MFG, NET and USR
  28. # HFIDs are set to the values defined in this file; the ACS Username
  29. # is derived from the original MAC; the ACS Password is derived from
  30. # the local host random number generator;
  31. #
  32. # devices should be programmed and tested using the PTS then updated
  33. # using his script; Atheros Powerline Toolkit 1.3.1 is needed;
  34. #
  35. # --------------------------------------------------------------------
  36. #
  37. # Define environment;
  38. #
  39. ETH=eth0 # PC ethernet port
  40. NVMFILE=tr069.nvm # This is the NVM file to program
  41. REFPIB=tr069.pib # This is the PIB template to use
  42. PIBFILE=tmp.pib # Temp PIB to modify
  43. MFGFILE=mfgfeed.txt # Manufacturing Feed File
  44. #
  45. # Determine device identity;
  46. #
  47. MAC=$(int6kid -Ai ${ETH})
  48. DAK=$(int6kid -Di ${ETH})
  49. NMK=$(int6kid -Mi ${ETH})
  50. #
  51. # Define default HFIDs;
  52. #
  53. MFG=&quot;MANUFACTURER MODEL-AB-02-01&quot;
  54. NET=&quot;MANUFACTURER MODEL-AB-02-01&quot;
  55. USR=&quot;MANUFACTURER MODEL-AB-02-01&quot;
  56. #
  57. # Make a copy of PIB to edit
  58. #
  59. cp ${REFPIB} ${PIBFILE}
  60. #
  61. # Set MAC, DAK, NMK, MFG_HFID, NET_HFID and USR_HFID in PIB file
  62. #
  63. modpib ${PIBFILE} -M ${MAC} -D ${DAK} -N ${NMK} -S &quot;${MFG}&quot; -T &quot;${NET}&quot; -U &quot;${USR}&quot;
  64. UMAC=$(echo $MAC | sed 'y/abcdef/ABCDEF/' | sed 's/://g' | sed 's/ //g')
  65. OUI=$(echo $UMAC | cut -c 1-6)
  66. #
  67. # Build the ACS Username
  68. #
  69. UNAME=&quot;$OUI&quot;-&quot;$UMAC&quot;
  70. #
  71. # Generate a 16 character lower case random ACS password
  72. #
  73. RANDOMPWORD=$(&lt;/dev/urandom tr -dc a-z0-9| (head -c $1 &gt; /dev/null 2&gt;&amp;1 || head -c 16))
  74. #
  75. # Set Username and Password in PIB file
  76. #
  77. setpib ${PIBFILE} 2DCC username ${UNAME}
  78. setpib ${PIBFILE} 2ECD password ${RANDOMPWORD}
  79. setpib ${PIBFILE} 2FCE byte 01
  80. #
  81. # Write NVM and PIB
  82. #
  83. int6kp -i ${ETH} -P ${PIBFILE} -N ${NVMFILE} -FF -D ${DAK}
  84. FW=$(int6k -qri ${ETH} | rev | cut -d &quot; &quot; -f1 | rev)
  85. #
  86. # Write the record to Mfg feed file
  87. #
  88. echo $UMAC&quot;|&quot;$FW&quot;|&quot;$RANDOMPWORD&quot;|1.0|&quot;$RANDOMPWORD&quot;|000000&quot; &gt;&gt; ${MFGFILE}
  89. </pre>
  90. <div class='footerlink'>
  91. [<a href='start.sh.html' title=' start.sh '>PREV</a>]
  92. [<a href='toolkit.html' title=' Index '>HOME</a>]
  93. [<a href='traffic.sh.html' title=' traffic.sh '>NEXT</a>]
  94. </div>
  95. </body>
  96. </html>